public void AddToLine(Mono.TextEditor.Document doc) { if (Line != null) { DocumentLocation dl = doc.OffsetToLocation(marker.StartCol); marker.StartCol = dl.Column; dl = doc.OffsetToLocation(marker.EndCol); marker.EndCol = dl.Column; doc.AddMarker (Line, marker); } }
public TooltipItem GetItem (Mono.TextEditor.TextEditor editor, int offset) { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.ParsedDocument == null) return null; var unit = doc.ParsedDocument.GetAst<CompilationUnit> (); if (unit == null) return null; var file = doc.ParsedDocument.ParsedFile as CSharpParsedFile; if (file == null) return null; ResolveResult result; AstNode node; var loc = editor.OffsetToLocation (offset); if (!doc.TryResolveAt (loc, out result, out node)) return null; var resolver = new CSharpAstResolver (doc.Compilation, unit, file); resolver.ApplyNavigator (new NodeListResolveVisitorNavigator (node), CancellationToken.None); int startOffset = offset; int endOffset = offset; return new TooltipItem (new ToolTipData (unit, result, node, resolver), startOffset, endOffset - startOffset); }
public string GetExpression (Mono.TextEditor.TextEditorData data, int offset) { if (offset < 0) return ""; var doc = IdeApp.Workbench.ActiveDocument; if (doc == null) return ""; var loc = RefactoringService.GetCorrectResolveLocation (doc, data.OffsetToLocation (offset)); var unit = doc.ParsedDocument.GetAst<CompilationUnit> (); var parsedFile = doc.ParsedDocument.ParsedFile as CSharpParsedFile; var node = unit.GetNodeAt<Expression> (loc.Line, loc.Column); if (unit == null || parsedFile == null || node == null) return ""; return data.GetTextBetween (node.StartLocation, node.EndLocation); }
IEnumerable<MemberReference> SearchMember (INode member, ProjectDom dom, FilePath fileName, Mono.TextEditor.TextEditorData editor, Mono.TextEditor.Document buildDocument, List<LocalDocumentInfo.OffsetInfo> offsetInfos, ParsedDocument parsedDocument) { var resolver = new NRefactoryResolver (dom, parsedDocument.CompilationUnit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName); FindMemberAstVisitor visitor = new FindMemberAstVisitor (buildDocument, member); visitor.IncludeXmlDocumentation = IncludeDocumentation; visitor.RunVisitor (resolver); foreach (var result in visitor.FoundReferences) { var offsetInfo = offsetInfos.FirstOrDefault (info => info.ToOffset <= result.Position && result.Position < info.ToOffset + info.Length); if (offsetInfo == null) continue; var offset = offsetInfo.FromOffset + result.Position - offsetInfo.ToOffset; var loc = editor.OffsetToLocation (offset); yield return new MemberReference (null, fileName, offset, loc.Line, loc.Column, result.Name, null); } }
public override TooltipItem GetItem (Mono.TextEditor.TextEditor editor, int offset) { var doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.ParsedDocument == null) return null; var unit = doc.ParsedDocument.GetAst<SyntaxTree> (); if (unit == null) return null; var file = doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile; if (file == null) return null; ResolveResult result; AstNode node; var loc = editor.OffsetToLocation (offset); if (!doc.TryResolveAt (loc, out result, out node)) { if (node is CSharpTokenNode) { int startOffset2 = editor.LocationToOffset (node.StartLocation); int endOffset2 = editor.LocationToOffset (node.EndLocation); return new TooltipItem (new ToolTipData (unit, result, node, null), startOffset2, endOffset2 - startOffset2); } return null; } if (node == lastNode) return lastResult; var resolver = new CSharpAstResolver (doc.Compilation, unit, file); resolver.ApplyNavigator (new NodeListResolveVisitorNavigator (node), CancellationToken.None); var hoverNode = node.GetNodeAt (loc) ?? node; int startOffset = editor.LocationToOffset (hoverNode.StartLocation); int endOffset = editor.LocationToOffset (hoverNode.EndLocation); return lastResult = new TooltipItem (new ToolTipData (unit, result, node, resolver), startOffset, endOffset - startOffset); }