void CreateSmartTag (CodeActionContainer fixes, int offset) { if (!AnalysisOptions.EnableFancyFeatures || fixes.IsEmpty) { RemoveWidget (); return; } var editor = Editor; if (editor == null) { RemoveWidget (); return; } if (DocumentContext.ParsedDocument == null || DocumentContext.ParsedDocument.IsInvalid) { RemoveWidget (); return; } // var container = editor.Parent; // if (container == null) { // RemoveWidget (); // return; // } bool first = true; var smartTagLocBegin = offset; foreach (var fix in fixes.CodeFixActions.Concat (fixes.CodeRefactoringActions)) { var textSpan = fix.ValidSegment; if (textSpan.IsEmpty) continue; if (first || offset < textSpan.Start) { smartTagLocBegin = textSpan.Start; } first = false; } // if (smartTagLocBegin.Line != loc.Line) // smartTagLocBegin = new DocumentLocation (loc.Line, 1); // got no fix location -> try to search word start // if (first) { // int offset = document.Editor.LocationToOffset (smartTagLocBegin); // while (offset > 0) { // char ch = document.Editor.GetCharAt (offset - 1); // if (!char.IsLetterOrDigit (ch) && ch != '_') // break; // offset--; // } // smartTagLocBegin = document.Editor.OffsetToLocation (offset); // } if (currentSmartTag != null && currentSmartTagBegin == smartTagLocBegin) { return; } RemoveWidget (); currentSmartTagBegin = smartTagLocBegin; var realLoc = Editor.OffsetToLocation (smartTagLocBegin); currentSmartTag = TextMarkerFactory.CreateSmartTagMarker (Editor, smartTagLocBegin, realLoc); currentSmartTag.CancelPopup += CurrentSmartTag_CancelPopup; currentSmartTag.ShowPopup += CurrentSmartTag_ShowPopup; currentSmartTag.Tag = fixes; currentSmartTag.IsVisible = fixes.CodeFixActions.Count > 0; editor.AddMarker (currentSmartTag); }
void CreateSmartTag(CodeActionContainer fixes, int offset) { if (!AnalysisOptions.EnableFancyFeatures || fixes.IsEmpty) { RemoveWidget(); return; } var editor = Editor; if (editor == null) { RemoveWidget(); return; } if (DocumentContext.ParsedDocument == null || DocumentContext.ParsedDocument.IsInvalid) { RemoveWidget(); return; } // var container = editor.Parent; // if (container == null) { // RemoveWidget (); // return; // } bool first = true; var smartTagLocBegin = offset; foreach (var fix in fixes.CodeFixActions.Concat(fixes.CodeRefactoringActions)) { var textSpan = fix.ValidSegment; if (textSpan.IsEmpty) { continue; } if (first || offset < textSpan.Start) { smartTagLocBegin = textSpan.Start; } first = false; } // if (smartTagLocBegin.Line != loc.Line) // smartTagLocBegin = new DocumentLocation (loc.Line, 1); // got no fix location -> try to search word start // if (first) { // int offset = document.Editor.LocationToOffset (smartTagLocBegin); // while (offset > 0) { // char ch = document.Editor.GetCharAt (offset - 1); // if (!char.IsLetterOrDigit (ch) && ch != '_') // break; // offset--; // } // smartTagLocBegin = document.Editor.OffsetToLocation (offset); // } if (currentSmartTag != null && currentSmartTagBegin == smartTagLocBegin) { return; } RemoveWidget(); currentSmartTagBegin = smartTagLocBegin; var realLoc = Editor.OffsetToLocation(smartTagLocBegin); currentSmartTag = TextMarkerFactory.CreateSmartTagMarker(Editor, smartTagLocBegin, realLoc); currentSmartTag.CancelPopup += CurrentSmartTag_CancelPopup; currentSmartTag.ShowPopup += CurrentSmartTag_ShowPopup; currentSmartTag.Tag = fixes; currentSmartTag.IsVisible = fixes.CodeFixActions.Count > 0; editor.AddMarker(currentSmartTag); }