void CreateWidget(IEnumerable <CodeAction> fixes, TextLocation loc) { Fixes = fixes; if (!QuickTaskStrip.EnableFancyFeatures) { return; } var editor = document.Editor; if (editor == null || editor.Parent == null || !editor.Parent.IsRealized) { return; } if (document.ParsedDocument == null || document.ParsedDocument.IsInvalid) { return; } if (!fixes.Any()) { ICSharpCode.NRefactory.Semantics.ResolveResult resolveResult; ICSharpCode.NRefactory.CSharp.AstNode node; if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node)) { var possibleNamespaces = ResolveCommandHandler.GetPossibleNamespaces(document, node, resolveResult); if (!possibleNamespaces.Any()) { return; } } else { return; } } var container = editor.Parent.Parent as TextEditorContainer; if (container == null) { return; } if (widget == null) { widget = new CodeActionWidget(this, Document); container.AddTopLevelWidget(widget, 2 + (int)editor.Parent.TextViewMargin.XOffset, -2 + (int)editor.Parent.LineToY(document.Editor.Caret.Line)); } else { container.MoveTopLevelWidget(widget, 2 + (int)editor.Parent.TextViewMargin.XOffset, -2 + (int)editor.Parent.LineToY(document.Editor.Caret.Line)); } widget.Show(); widget.SetFixes(fixes, loc); }
HashSet <MonoDevelop.Refactoring.ResolveCommandHandler.PossibleNamespace> GetResult(string input) { var doc = Setup(input); var location = doc.Editor.Caret.Location; ResolveResult resolveResult; AstNode node; doc.TryResolveAt(location, out resolveResult, out node); return(ResolveCommandHandler.GetPossibleNamespaces(doc, node, ref resolveResult)); }
public override void CursorPositionChanged() { CancelQuickFixTimer(); if (QuickTaskStrip.EnableFancyFeatures && Document.ParsedDocument != null && !Debugger.DebuggingService.IsDebugging) { quickFixCancellationTokenSource = new CancellationTokenSource(); var token = quickFixCancellationTokenSource.Token; quickFixTimeout = GLib.Timeout.Add(100, delegate { var loc = Document.Editor.Caret.Location; RefactoringService.QueueQuickFixAnalysis(Document, loc, token, delegate(List <CodeAction> fixes) { if (!fixes.Any()) { ICSharpCode.NRefactory.Semantics.ResolveResult resolveResult; AstNode node; if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node, token)) { var possibleNamespaces = ResolveCommandHandler.GetPossibleNamespaces(document, node, ref resolveResult); if (!possibleNamespaces.Any()) { if (currentSmartTag != null) { Application.Invoke(delegate { RemoveWidget(); }); } return; } } else { if (currentSmartTag != null) { Application.Invoke(delegate { RemoveWidget(); }); } return; } } Application.Invoke(delegate { if (token.IsCancellationRequested) { return; } CreateSmartTag(fixes, loc); quickFixTimeout = 0; }); }); return(false); }); } else { RemoveWidget(); } base.CursorPositionChanged(); }