void CreateSmartTag (List<CodeAction> fixes, DocumentLocation loc) { Fixes = fixes; if (!QuickTaskStrip.EnableFancyFeatures) { RemoveWidget (); return; } var editor = document.Editor; if (editor == null || editor.Parent == null || !editor.Parent.IsRealized) { RemoveWidget (); return; } if (document.ParsedDocument == null || document.ParsedDocument.IsInvalid) { RemoveWidget (); return; } var container = editor.Parent; if (container == null) { RemoveWidget (); return; } bool first = true; DocumentLocation smartTagLocBegin = loc; foreach (var fix in fixes) { if (fix.DocumentRegion.IsEmpty) continue; if (first || loc < fix.DocumentRegion.Begin) { smartTagLocBegin = fix.DocumentRegion.Begin; } 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) { currentSmartTag.fixes = fixes; return; } RemoveWidget (); currentSmartTagBegin = smartTagLocBegin; var line = document.Editor.GetLine (smartTagLocBegin.Line); currentSmartTag = new SmartTagMarker ((line.NextLine ?? line).Offset, this, fixes, smartTagLocBegin); document.Editor.Document.AddMarker (currentSmartTag); }
void CreateSmartTag(List <CodeAction> fixes, DocumentLocation loc) { Fixes = fixes; if (!QuickTaskStrip.EnableFancyFeatures) { RemoveWidget(); return; } var editor = document.Editor; if (editor == null || editor.Parent == null || !editor.Parent.IsRealized) { RemoveWidget(); return; } if (document.ParsedDocument == null || document.ParsedDocument.IsInvalid) { RemoveWidget(); return; } var container = editor.Parent; if (container == null) { RemoveWidget(); return; } bool first = true; DocumentLocation smartTagLocBegin = loc; foreach (var fix in fixes) { if (fix.DocumentRegion.IsEmpty) { continue; } if (first || loc < fix.DocumentRegion.Begin) { smartTagLocBegin = fix.DocumentRegion.Begin; } 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) { currentSmartTag.fixes = fixes; return; } currentSmartTagBegin = smartTagLocBegin; RemoveWidget(); var line = document.Editor.GetLine(smartTagLocBegin.Line); currentSmartTag = new SmartTagMarker((line.NextLine ?? line).Offset, this, fixes, smartTagLocBegin); document.Editor.Document.AddMarker(currentSmartTag); }