void EditorCarethandlePositionChanged(object sender, DocumentLocationEventArgs e) { if (!editor.GetTextEditorData().HighlightCaretLine || e.Location.Line == editor.Caret.Line) { return; } editor.RedrawMarginLine(this, e.Location.Line); editor.RedrawMarginLine(this, editor.Caret.Line); }
public void InsertNewLine(TextEditor editor, NewLineInsertion insertion, ref int offset) { string str = null; switch (insertion) { case NewLineInsertion.Eol: str = editor.GetTextEditorData().EolMarker; break; case NewLineInsertion.BlankLine: str = editor.GetTextEditorData().EolMarker + editor.GetTextEditorData().EolMarker; break; default: return; } editor.Insert(offset, str); offset += str.Length; }
public void SetSegment(TextSegment segment, bool removeIndent) { int startLine = editor.Document.OffsetToLineNumber(segment.Offset); int endLine = editor.Document.OffsetToLineNumber(segment.EndOffset); bool pushedLineLimit = endLine - startLine > maxLines; if (pushedLineLimit) { segment = new TextSegment(segment.Offset, editor.Document.GetLine(startLine + maxLines).Offset - segment.Offset); } layout.Ellipsize = Pango.EllipsizeMode.End; layout.SetMarkup(editor.GetTextEditorData().GetMarkup(segment.Offset, segment.Length, removeIndent) + (pushedLineLimit ? Environment.NewLine + "..." : "")); QueueDraw(); }
int InsertLines(int offset, int start, int end, out int newStart, out int newEnd) { StringBuilder sb = new StringBuilder(); StackFrame ff = DebuggingService.CurrentFrame; List <AssemblyLine> lines = new List <AssemblyLine> (ff.Disassemble(start, end - start + 1)); int i = lines.FindIndex(al => !al.IsOutOfRange); if (i == -1) { newStart = int.MinValue; newEnd = int.MinValue; return(0); } newStart = i == 0 ? start : int.MinValue; lines.RemoveRange(0, i); int j = lines.FindLastIndex(al => !al.IsOutOfRange); newEnd = j == lines.Count - 1 ? end : int.MinValue; lines.RemoveRange(j + 1, lines.Count - j - 1); int lineCount = 0; int editorLine = editor.GetTextEditorData().OffsetToLineNumber(offset); foreach (AssemblyLine li in lines) { if (li.IsOutOfRange) { continue; } InsertAssemblerLine(sb, editorLine++, li); lineCount++; } editor.Insert(offset, sb.ToString()); editor.Document.CommitUpdateAll(); if (offset == 0) { this.cachedLines.InsertRange(0, lines); } else { this.cachedLines.AddRange(lines); } return(lineCount); }
internal protected override void MousePressed(MarginMouseEventArgs args) { base.MousePressed(args); if (args.Button != PointerButton.Left || args.LineNumber < DocumentLocation.MinLine) { return; } editor.LockedMargin = this; int lineNumber = args.LineNumber; bool extendSelection = (args.ModifierState & ModifierKeys.Shift) == ModifierKeys.Shift; if (lineNumber <= editor.Document.LineCount) { DocumentLocation loc = new DocumentLocation(lineNumber, DocumentLocation.MinColumn); DocumentLine line = args.LineSegment; if (args.RawEvent.MultiplePress == 2) { if (line != null) { editor.MainSelection = new Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber)); } } else if (extendSelection) { if (!editor.IsSomethingSelected) { editor.MainSelection = new Selection(loc, loc); } else { editor.MainSelection = editor.MainSelection.WithLead(loc); } } else { anchorLocation = loc; editor.ClearSelection(); } editor.Caret.PreserveSelection = true; editor.Caret.Location = loc; editor.Caret.PreserveSelection = false; } }
internal protected override void MousePressed(MarginMouseEventArgs args) { base.MousePressed(args); if (args.Button != 1 || args.LineNumber < DocumentLocation.MinLine) { return; } editor.LockedMargin = this; int lineNumber = args.LineNumber; bool extendSelection = (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask; if (lineNumber <= editor.Document.LineCount) { DocumentLocation loc = new DocumentLocation(lineNumber, DocumentLocation.MinColumn); LineSegment line = args.LineSegment; if (args.Type == EventType.TwoButtonPress) { if (line != null) { editor.MainSelection = new Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber)); } } else if (extendSelection) { if (!editor.IsSomethingSelected) { editor.MainSelection = new Selection(loc, loc); } editor.MainSelection.Lead = loc; } else { anchorLocation = loc; editor.ClearSelection(); } editor.Caret.PreserveSelection = true; editor.Caret.Location = loc; editor.Caret.PreserveSelection = false; } }
public override TooltipItem GetItem (TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) return null; if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) return null; StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) return null; var ed = (ExtensibleTextEditor)editor; int startOffset = 0, length = 0; DomRegion expressionRegion; string expression = null; ResolveResult res; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { expression = ed.SelectedText; startOffset = ed.SelectionRange.Offset; length = ed.SelectionRange.Length; } else if ((res = ed.GetLanguageItem (offset, out expressionRegion)) != null && !res.IsError && res.GetType () != typeof (ResolveResult)) { //Console.WriteLine ("res is a {0}", res.GetType ().Name); if (expressionRegion.IsEmpty) return null; if (res is NamespaceResolveResult || res is ConversionResolveResult || res is ConstantResolveResult || res is ForEachResolveResult || res is TypeIsResolveResult || res is TypeOfResolveResult || res is ErrorResolveResult) return null; if (res.IsCompileTimeConstant) return null; var start = new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn); var end = new DocumentLocation (expressionRegion.EndLine, expressionRegion.EndColumn); startOffset = editor.Document.LocationToOffset (start); int endOffset = editor.Document.LocationToOffset (end); length = endOffset - startOffset; if (res is LocalResolveResult) { expression = GetLocalExpression (editor, (LocalResolveResult) res, expressionRegion); length = expression.Length; } else if (res is InvocationResolveResult) { var ir = (InvocationResolveResult) res; if (ir.Member.Name != ".ctor") return null; expression = ir.Member.DeclaringType.FullName; } else if (res is MemberResolveResult) { expression = GetMemberExpression (editor, (MemberResolveResult) res, expressionRegion); } else if (res is NamedArgumentResolveResult) { // Fall through... } else if (res is ThisResolveResult) { // Fall through... } else if (res is TypeResolveResult) { // Fall through... } else { return null; } if (expression == null) expression = ed.GetTextBetween (start, end); } else { var data = editor.GetTextEditorData (); startOffset = data.FindCurrentWordStart (offset); int endOffset = data.FindCurrentWordEnd (offset); expression = ed.GetTextBetween (ed.OffsetToLocation (startOffset), ed.OffsetToLocation (endOffset)); } if (string.IsNullOrEmpty (expression)) return null; ObjectValue val; if (!cachedValues.TryGetValue (expression, out val)) { val = frame.GetExpressionValue (expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) return null; val.Name = expression; return new TooltipItem (val, startOffset, length); }
public override TooltipItem GetItem(TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) { return(null); } if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) { return(null); } StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) { return(null); } var ed = (ExtensibleTextEditor)editor; string expression = null; int startOffset; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { startOffset = ed.SelectionRange.Offset; expression = ed.SelectedText; } else { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.ParsedDocument == null) { return(null); } ResolveResult result; AstNode node; var loc = editor.OffsetToLocation(offset); if (!TryResolveAt(doc, loc, out result, out node)) { return(null); } expression = ResolveExpression(editor.GetTextEditorData(), result, node, out startOffset); } if (string.IsNullOrEmpty(expression)) { return(null); } ObjectValue val; if (!cachedValues.TryGetValue(expression, out val)) { val = frame.GetExpressionValue(expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) { return(null); } val.Name = expression; return(new TooltipItem(val, startOffset, expression.Length)); }
public override TooltipItem GetItem(TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) { return(null); } if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) { return(null); } StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) { return(null); } var ed = (ExtensibleTextEditor)editor; int startOffset = 0, length = 0; DomRegion expressionRegion; string expression = null; ResolveResult res; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { expression = ed.SelectedText; startOffset = ed.SelectionRange.Offset; length = ed.SelectionRange.Length; } else if ((res = ed.GetLanguageItem(offset, out expressionRegion)) != null && !res.IsError && res.GetType() != typeof(ResolveResult)) { //Console.WriteLine ("res is a {0}", res.GetType ().Name); if (expressionRegion.IsEmpty) { return(null); } if (res is NamespaceResolveResult || res is ConversionResolveResult || res is ConstantResolveResult || res is ForEachResolveResult || res is TypeIsResolveResult || res is TypeOfResolveResult || res is ErrorResolveResult) { return(null); } if (res.IsCompileTimeConstant) { return(null); } var start = new DocumentLocation(expressionRegion.BeginLine, expressionRegion.BeginColumn); var end = new DocumentLocation(expressionRegion.EndLine, expressionRegion.EndColumn); startOffset = editor.Document.LocationToOffset(start); int endOffset = editor.Document.LocationToOffset(end); length = endOffset - startOffset; if (res is LocalResolveResult) { expression = GetLocalExpression(editor, (LocalResolveResult)res, expressionRegion); length = expression.Length; } else if (res is InvocationResolveResult) { var ir = (InvocationResolveResult)res; if (ir.Member.Name != ".ctor") { return(null); } expression = ir.Member.DeclaringType.FullName; } else if (res is MemberResolveResult) { var mr = (MemberResolveResult)res; string member = null; if (mr.Member != null) { if (mr.Member is IProperty) { // Visual Studio will evaluate Properties if you hover over their definitions... var prop = (IProperty)mr.Member; if (prop.CanGet) { if (prop.IsStatic) { expression = prop.FullName; } else { member = prop.Name; } } else { return(null); } } else if (mr.Member is IField) { var field = (IField)mr.Member; if (field.IsStatic) { expression = field.FullName; } else { member = field.Name; } } else { return(null); } } if (expression == null) { if (member == null) { return(null); } if (mr.TargetResult != null) { if (mr.TargetResult is LocalResolveResult) { expression = GetLocalExpression(editor, (LocalResolveResult)mr.TargetResult, expressionRegion); } else { var targetRegion = mr.TargetResult.GetDefinitionRegion(); if (targetRegion.BeginLine != 0 && targetRegion.BeginColumn != 0) { start = new DocumentLocation(targetRegion.BeginLine, targetRegion.BeginColumn); end = new DocumentLocation(targetRegion.EndLine, targetRegion.EndColumn); expression = ed.GetTextBetween(start, end).Trim(); } } } if (!string.IsNullOrEmpty(expression)) { expression += "." + member; } else { expression = member; } } } else if (res is NamedArgumentResolveResult) { // Fall through... } else if (res is ThisResolveResult) { // Fall through... } else if (res is TypeResolveResult) { // Fall through... } else { return(null); } if (expression == null) { expression = ed.GetTextBetween(start, end); } } else { var data = editor.GetTextEditorData(); startOffset = data.FindCurrentWordStart(offset); int endOffset = data.FindCurrentWordEnd(offset); expression = ed.GetTextBetween(ed.OffsetToLocation(startOffset), ed.OffsetToLocation(endOffset)); } if (string.IsNullOrEmpty(expression)) { return(null); } ObjectValue val; if (!cachedValues.TryGetValue(expression, out val)) { val = frame.GetExpressionValue(expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) { return(null); } val.Name = expression; return(new TooltipItem(val, startOffset, length)); }
public override TooltipItem GetItem (TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) return null; if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) return null; StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) return null; var ed = (ExtensibleTextEditor) editor; string expression = null; int startOffset; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { startOffset = ed.SelectionRange.Offset; expression = ed.SelectedText; } else { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.ParsedDocument == null) return null; var resolver = doc.GetContent<IDebuggerExpressionResolver> (); var data = editor.GetTextEditorData (); if (resolver != null) { expression = resolver.ResolveExpression (data, doc, offset, out startOffset); } else { int endOffset = data.FindCurrentWordEnd (offset); startOffset = data.FindCurrentWordStart (offset); expression = data.GetTextAt (startOffset, endOffset - startOffset); } } if (string.IsNullOrEmpty (expression)) return null; ObjectValue val; if (!cachedValues.TryGetValue (expression, out val)) { var options = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); options.AllowMethodEvaluation = true; options.AllowTargetInvoke = true; val = frame.GetExpressionValue (expression, options); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) return null; val.Name = expression; return new TooltipItem (val, startOffset, expression.Length); }
public override TooltipItem GetItem (TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) return null; if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) return null; StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) return null; var ed = (ExtensibleTextEditor) editor; string expression = null; int startOffset; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { startOffset = ed.SelectionRange.Offset; expression = ed.SelectedText; } else { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.ParsedDocument == null) return null; ResolveResult result; AstNode node; var loc = editor.OffsetToLocation (offset); if (!TryResolveAt (doc, loc, out result, out node)) return null; expression = ResolveExpression (editor.GetTextEditorData (), result, node, out startOffset); } if (string.IsNullOrEmpty (expression)) return null; ObjectValue val; if (!cachedValues.TryGetValue (expression, out val)) { val = frame.GetExpressionValue (expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) return null; val.Name = expression; return new TooltipItem (val, startOffset, expression.Length); }
bool TextImplementor.AddSelection(int start_offset, int end_offset) { editor.GetTextEditorData().SetSelection(start_offset, end_offset); return(true); }
public override TooltipItem GetItem (TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) return null; if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) return null; StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) return null; var ed = (ExtensibleTextEditor)editor; DomRegion expressionRegion; string expression = null; ResolveResult res; int startOffset; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { startOffset = ed.SelectionRange.Offset; expression = ed.SelectedText; } else if ((res = ed.GetLanguageItem (offset, out expressionRegion)) != null && !res.IsError && res.GetType () != typeof (ResolveResult)) { if (!TryResolveExpression (editor.GetTextEditorData (), res, expressionRegion, out expression)) return null; startOffset = editor.LocationToOffset (new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn)); } else { var data = editor.GetTextEditorData (); startOffset = data.FindCurrentWordStart (offset); int endOffset = data.FindCurrentWordEnd (offset); expression = ed.GetTextBetween (ed.OffsetToLocation (startOffset), ed.OffsetToLocation (endOffset)); } if (string.IsNullOrEmpty (expression)) return null; ObjectValue val; if (!cachedValues.TryGetValue (expression, out val)) { val = frame.GetExpressionValue (expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) return null; val.Name = expression; return new TooltipItem (val, startOffset, expression.Length); }
public override TooltipItem GetItem (TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) return null; if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) return null; StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) return null; var ed = (ExtensibleTextEditor)editor; int startOffset = 0, length = 0; DomRegion expressionRegion; string expression = null; ResolveResult res; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { expression = ed.SelectedText; startOffset = ed.SelectionRange.Offset; length = ed.SelectionRange.Length; } else if ((res = ed.GetLanguageItem (offset, out expressionRegion)) != null && !res.IsError && res.GetType () != typeof (ResolveResult)) { //Console.WriteLine ("res is a {0}", res.GetType ().Name); if (expressionRegion.IsEmpty) return null; if (res is NamespaceResolveResult || res is ConversionResolveResult || res is ConstantResolveResult || res is ForEachResolveResult || res is TypeIsResolveResult || res is TypeOfResolveResult || res is ErrorResolveResult) return null; if (res.IsCompileTimeConstant) return null; var start = new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn); var end = new DocumentLocation (expressionRegion.EndLine, expressionRegion.EndColumn); startOffset = editor.Document.LocationToOffset (start); int endOffset = editor.Document.LocationToOffset (end); length = endOffset - startOffset; if (res is LocalResolveResult) { var lr = (LocalResolveResult) res; // In a setter, the 'value' variable will have a begin line/column of 0,0 which is an undefined offset if (lr.Variable.Region.BeginLine != 0 && lr.Variable.Region.BeginColumn != 0) { // Use the start and end offsets of the variable region so that we get the "@" in variable names like "@class" start = new DocumentLocation (lr.Variable.Region.BeginLine, lr.Variable.Region.BeginColumn); end = new DocumentLocation (lr.Variable.Region.EndLine, lr.Variable.Region.EndColumn); startOffset = editor.Document.LocationToOffset (start); endOffset = editor.Document.LocationToOffset (end); } expression = ed.GetTextBetween (startOffset, endOffset).Trim (); // Note: When the LocalResolveResult is a parameter, the Variable.Region includes the type if (lr.IsParameter) { int index = IndexOfLastWhiteSpace (expression); if (index != -1) expression = expression.Substring (index + 1); } length = expression.Length; } else if (res is InvocationResolveResult) { var ir = (InvocationResolveResult) res; if (ir.Member.Name != ".ctor") return null; expression = ir.Member.DeclaringType.FullName; } else if (res is MemberResolveResult) { var mr = (MemberResolveResult) res; if (mr.TargetResult == null) { // User is hovering over a member definition... if (mr.Member is IProperty) { // Visual Studio will evaluate Properties if you hover over their definitions... var prop = (IProperty) mr.Member; if (prop.CanGet) { if (prop.IsStatic) expression = prop.FullName; else expression = prop.Name; } else { return null; } } else if (mr.Member is IField) { var field = (IField) mr.Member; if (field.IsStatic) expression = field.FullName; else expression = field.Name; } else { return null; } } // If the TargetResult is not null, then treat it like any other ResolveResult. } else if (res is NamedArgumentResolveResult) { // Fall through... } else if (res is ThisResolveResult) { // Fall through... } else if (res is TypeResolveResult) { // Fall through... } else { return null; } if (expression == null) expression = ed.GetTextBetween (start, end); } else { var data = editor.GetTextEditorData (); startOffset = data.FindCurrentWordStart (offset); int endOffset = data.FindCurrentWordEnd (offset); expression = ed.GetTextBetween (ed.OffsetToLocation (startOffset), ed.OffsetToLocation (endOffset)); } if (string.IsNullOrEmpty (expression)) return null; ObjectValue val; if (!cachedValues.TryGetValue (expression, out val)) { val = frame.GetExpressionValue (expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) return null; val.Name = expression; return new TooltipItem (val, startOffset, length); }
public override TooltipItem GetItem(TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) { return(null); } if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) { return(null); } StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) { return(null); } var ed = (ExtensibleTextEditor)editor; string expression = null; int startOffset; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { startOffset = ed.SelectionRange.Offset; expression = ed.SelectedText; } else { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.ParsedDocument == null) { return(null); } var resolver = doc.GetContent <IDebuggerExpressionResolver> (); var data = editor.GetTextEditorData(); if (resolver != null) { expression = resolver.ResolveExpression(data, doc, offset, out startOffset); } else { int endOffset = data.FindCurrentWordEnd(offset); startOffset = data.FindCurrentWordStart(offset); expression = data.GetTextAt(startOffset, endOffset - startOffset); } } if (string.IsNullOrEmpty(expression)) { return(null); } ObjectValue val; if (!cachedValues.TryGetValue(expression, out val)) { val = frame.GetExpressionValue(expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) { return(null); } val.Name = expression; return(new TooltipItem(val, startOffset, expression.Length)); }
CaretPosition ITextCaret.MoveToPreferredCoordinates() { TextEditor.GetTextEditorData().FixVirtualIndentation(); return(((ITextCaret)this).Position); }
public override TooltipItem GetItem(TextEditor editor, int offset) { if (offset >= editor.Document.TextLength) { return(null); } if (!DebuggingService.IsDebugging || DebuggingService.IsRunning) { return(null); } StackFrame frame = DebuggingService.CurrentFrame; if (frame == null) { return(null); } var ed = (ExtensibleTextEditor)editor; int startOffset = 0, length = 0; DomRegion expressionRegion; string expression = null; ResolveResult res; if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) { expression = ed.SelectedText; startOffset = ed.SelectionRange.Offset; length = ed.SelectionRange.Length; } else if ((res = ed.GetLanguageItem(offset, out expressionRegion)) != null && !res.IsError && res.GetType() != typeof(ResolveResult)) { //Console.WriteLine ("res is a {0}", res.GetType ().Name); if (expressionRegion.IsEmpty) { return(null); } if (res is NamespaceResolveResult || res is ConversionResolveResult || res is ConstantResolveResult || res is ForEachResolveResult || res is TypeIsResolveResult || res is TypeOfResolveResult || res is ErrorResolveResult) { return(null); } if (res.IsCompileTimeConstant) { return(null); } var start = new DocumentLocation(expressionRegion.BeginLine, expressionRegion.BeginColumn); var end = new DocumentLocation(expressionRegion.EndLine, expressionRegion.EndColumn); startOffset = editor.Document.LocationToOffset(start); int endOffset = editor.Document.LocationToOffset(end); length = endOffset - startOffset; if (res is LocalResolveResult) { var lr = (LocalResolveResult)res; // In a setter, the 'value' variable will have a begin line/column of 0,0 which is an undefined offset if (lr.Variable.Region.BeginLine != 0 && lr.Variable.Region.BeginColumn != 0) { // Use the start and end offsets of the variable region so that we get the "@" in variable names like "@class" start = new DocumentLocation(lr.Variable.Region.BeginLine, lr.Variable.Region.BeginColumn); end = new DocumentLocation(lr.Variable.Region.EndLine, lr.Variable.Region.EndColumn); startOffset = editor.Document.LocationToOffset(start); endOffset = editor.Document.LocationToOffset(end); } expression = ed.GetTextBetween(startOffset, endOffset).Trim(); // Note: When the LocalResolveResult is a parameter, the Variable.Region includes the type if (lr.IsParameter) { int index = IndexOfLastWhiteSpace(expression); if (index != -1) { expression = expression.Substring(index + 1); } } length = expression.Length; } else if (res is InvocationResolveResult) { var ir = (InvocationResolveResult)res; if (ir.Member.Name != ".ctor") { return(null); } expression = ir.Member.DeclaringType.FullName; } else if (res is MemberResolveResult) { var mr = (MemberResolveResult)res; if (mr.TargetResult == null) { // User is hovering over a member definition... if (mr.Member is IProperty) { // Visual Studio will evaluate Properties if you hover over their definitions... var prop = (IProperty)mr.Member; if (prop.CanGet) { if (prop.IsStatic) { expression = prop.FullName; } else { expression = prop.Name; } } else { return(null); } } else if (mr.Member is IField) { var field = (IField)mr.Member; if (field.IsStatic) { expression = field.FullName; } else { expression = field.Name; } } else { return(null); } } // If the TargetResult is not null, then treat it like any other ResolveResult. } else if (res is NamedArgumentResolveResult) { // Fall through... } else if (res is ThisResolveResult) { // Fall through... } else if (res is TypeResolveResult) { // Fall through... } else { return(null); } if (expression == null) { expression = ed.GetTextBetween(start, end); } } else { var data = editor.GetTextEditorData(); startOffset = data.FindCurrentWordStart(offset); int endOffset = data.FindCurrentWordEnd(offset); expression = ed.GetTextBetween(ed.OffsetToLocation(startOffset), ed.OffsetToLocation(endOffset)); } if (string.IsNullOrEmpty(expression)) { return(null); } ObjectValue val; if (!cachedValues.TryGetValue(expression, out val)) { val = frame.GetExpressionValue(expression, true); cachedValues [expression] = val; } if (val == null || val.IsUnknown || val.IsNotSupported) { return(null); } val.Name = expression; return(new TooltipItem(val, startOffset, length)); }