~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SpecializedCodeAction.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
 
 
3
namespace ICSharpCode.NRefactory.CSharp.Refactoring
 
4
{
 
5
        /// <summary>
 
6
        /// A specialized code action creates a code action assoziated with one special type of ast nodes.
 
7
        /// </summary>
 
8
        public abstract class SpecializedCodeAction<T> : ICodeActionProvider where T : AstNode
 
9
        {
 
10
                /// <summary>
 
11
                /// Gets the action for the specified ast node.
 
12
                /// </summary>
 
13
                /// <returns>
 
14
                /// The code action. May return <c>null</c>, if no action can be provided.
 
15
                /// </returns>
 
16
                /// <param name='context'>
 
17
                /// The refactoring conext.
 
18
                /// </param>
 
19
                /// <param name='node'>
 
20
                /// The AstNode it's ensured that the node is always != null, if called.
 
21
                /// </param>
 
22
                protected abstract CodeAction GetAction(RefactoringContext context, T node);
 
23
 
 
24
                #region ICodeActionProvider implementation
 
25
                public System.Collections.Generic.IEnumerable<CodeAction> GetActions(RefactoringContext context)
 
26
                {
 
27
                        var node = context.GetNode<T>();
 
28
                        if (node == null)
 
29
                                yield break;
 
30
                        var action = GetAction(context, node);
 
31
                        if (action == null)
 
32
                                yield break;
 
33
                        yield return action;
 
34
                }
 
35
                #endregion
 
36
        }
 
37
}
 
38