コード例 #1
0
			public ContextActionRunner (MonoDevelop.CodeActions.CodeAction act, MonoDevelop.Ide.Gui.Document document, ICSharpCode.NRefactory.TextLocation loc)
			{
				this.act = act;
				this.document = document;
				this.loc = loc;
			}
コード例 #2
0
 public ContextActionRunner(MonoDevelop.CodeActions.CodeAction act, MonoDevelop.Ide.Gui.Document document, ICSharpCode.NRefactory.TextLocation loc)
 {
     this.act      = act;
     this.document = document;
     this.loc      = loc;
 }
コード例 #3
0
		public static void ApplyFix (CodeAction action, IRefactoringContext context)
		{
			using(var script = context.CreateScript ()) {
				action.Run (context, script);
			}
		}
コード例 #4
0
		internal static bool IsAnalysisOrErrorFix (CodeAction act)
		{
			return act is AnalysisContextActionProvider.AnalysisCodeAction || act.Severity == Severity.Error;
		} 
コード例 #5
0
		public static void ApplyFix (CodeAction action, object context)
		{
			if (context is IScriptProvider) {
				using(var script = ((IScriptProvider)context).CreateScript ()) {
					action.Run (context, script);
				}
			} else {
				action.Run (context, null);
			}
		}
コード例 #6
0
        static CodeFixMenuEntry CreateFixMenuEntry(TextEditor editor, CodeAction fix)
        {
            int mnemonic = -1;

            return(CreateFixMenuEntry(editor, fix, ref mnemonic));
        }
コード例 #7
0
        static void AddFixMenuItem(TextEditor editor, CodeFixMenu menu, ref int mnemonic, CodeAction fix)
        {
            var nested = fix as CodeAction.CodeActionWithNestedActions;

            if (nested != null)
            {
                AddNestedFixMenu(editor, menu, nested);
                return;
            }

            menu.Add(CreateFixMenuEntry(editor, fix, ref mnemonic));
        }
コード例 #8
0
 public ContextActionRunner(TextEditor editor, CodeAction act)
 {
     this.editor     = editor;
     this.act        = act;
     documentContext = editor.DocumentContext;
 }
コード例 #9
0
        static void AddFixMenuItem(TextEditor editor, CodeFixMenu menu, CodeAction fix)
        {
            int _m = 0;

            AddFixMenuItem(editor, menu, ref _m, fix);
        }
コード例 #10
0
 public ContextActionRunner(CodeAction act, TextEditor editor, DocumentContext documentContext)
 {
     this.editor          = editor;
     this.act             = act;
     this.documentContext = documentContext;
 }
コード例 #11
0
        static void AddFixMenuItem(TextEditor editor, CodeFixMenu menu, CodeFixMenu fixAllMenu, ref int mnemonic, CodeAction fix, FixAllState fixState, CancellationToken token)
        {
            if (fix is CodeAction.CodeActionWithNestedActions nested)
            {
                // Inline code actions if they are, otherwise add a nested fix menu
                if (nested.IsInlinable)
                {
                    int actionCount = nested.NestedCodeActions.Length;
                    foreach (var nestedFix in nested.NestedCodeActions)
                    {
                        var nestedFixState = actionCount > 1 && nestedFix.EquivalenceKey == null ? null : fixState;

                        AddFixMenuItem(editor, menu, fixAllMenu, ref mnemonic, nestedFix, nestedFixState, token);
                    }
                    return;
                }

                if (nested.NestedCodeActions.Length > 0)
                {
                    AddNestedFixMenu(editor, menu, fixAllMenu, nested, fixState, token);
                }
                return;
            }

            menu.Add(CreateFixMenuEntry(editor, fix, ref mnemonic));

            // TODO: Add support for more than doc when we have global undo.
            fixState = fixState?.WithScopeAndEquivalenceKey(FixAllScope.Document, fix.EquivalenceKey);
            var fixAllMenuEntry = CreateFixAllMenuEntry(editor, fixState, ref mnemonic, token);

            if (fixAllMenuEntry != null)
            {
                fixAllMenu.Add(new CodeFixMenuEntry(fix.Message, null));
                fixAllMenu.Add(fixAllMenuEntry);
            }
        }
コード例 #12
0
 internal static bool IsAnalysisOrErrorFix(CodeAction act)
 {
     return(act is AnalysisContextActionProvider.AnalysisCodeAction || act.Severity == Severity.Error);
 }
コード例 #13
0
		public static void ApplyFix (CodeAction action, IRefactoringContext context)
		{
			if (!CheckUserSettings ())
				return;
			using (var script = context.CreateScript ()) {
				action.Run (context, script);
			}
		}