bool GoTo(IDocumentTab tab, MethodDef method, uint?ilOffset, object @ref) { if (method == null || ilOffset == null) { return(false); } var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) { return(false); } var methodDebugService = documentViewer.GetMethodDebugService(); var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset.Value); if (methodStatement == null) { return(false); } var textSpan = methodStatement.Value.Statement.TextSpan; var loc = FindLocation(documentViewer.Content.ReferenceCollection.FindFrom(textSpan.Start), documentViewer.TextView.TextSnapshot, methodStatement.Value.Statement.TextSpan.End, @ref); if (loc == null) { loc = textSpan.Start; } documentViewer.MoveCaretToPosition(loc.Value); return(true); }
bool MustRefresh(IDocumentTab tab, IEnumerable <IDsDocument> documents) { var modules = new HashSet <IDsDocument>(documents); if (InModifiedModuleHelper.IsInModifiedModule(modules, tab.Content.Nodes)) { return(true); } var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer != null && InModifiedModuleHelper.IsInModifiedModule(DocumentTreeView.DocumentService, modules, documentViewer.Content.ReferenceCollection.Select(a => a.Data.Reference))) { return(true); } return(false); }
bool GoTo(IDocumentTab tab, MethodDef method, uint ilOffset) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null || method == null) { return(false); } var methodDebugService = documentViewer.GetMethodDebugService(); var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset); if (methodStatement == null) { return(false); } documentViewer.MoveCaretToPosition(methodStatement.Value.Statement.TextSpan.Start); return(true); }
public override TextViewBookmarkLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) { return(null); } // A bookmark should be set on the current line if possible, and the current position // isn't necessarily at the start of the line. int startPos = position.Position.GetContainingLine().Start.Position; foreach (var data in documentViewer.ReferenceCollection.FindFrom(startPos)) { if (!data.Data.IsDefinition) { continue; } var def = data.Data.Reference as IMemberDef; if (def == null) { continue; } var span = data.Span; var snapshot = textView.TextSnapshot; if (span.End > snapshot.Length) { return(null); } var moduleId = moduleIdProvider.Create(def.Module); var location = dotNetBookmarkLocationFactory.Value.CreateTokenLocation(moduleId, def.MDToken.Raw); return(new TextViewBookmarkLocationResult(location, new SnapshotSpan(snapshot, span))); } return(null); }
public override TextViewBookmarkLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) { return(null); } var methodDebugService = documentViewer.GetMethodDebugService(); if (methodDebugService == null) { return(null); } // A bookmark should be set on the current line if possible, and the current position // isn't necessarily at the start of the line. var startPos = position.Position.GetContainingLine().Start; var methodStatements = methodDebugService.FindByTextPosition(startPos, FindByTextPositionOptions.None); if (methodStatements.Count == 0) { return(null); } var textSpan = methodStatements[0].Statement.TextSpan; var snapshot = textView.TextSnapshot; if (textSpan.End > snapshot.Length) { return(null); } var span = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length))); var statement = methodStatements[0]; var moduleId = moduleIdProvider.Create(statement.Method.Module); var location = dotNetBookmarkLocationFactory.Value.CreateMethodBodyLocation(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start); return(new TextViewBookmarkLocationResult(location, span)); }
public override DbgTextViewBreakpointLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) { return(null); } var methodDebugService = documentViewer.GetMethodDebugService(); if (methodDebugService == null) { return(null); } var methodStatements = methodDebugService.FindByTextPosition(position.Position, FindByTextPositionOptions.None); if (methodStatements.Count == 0) { return(null); } var textSpan = methodStatements[0].Statement.TextSpan; var snapshot = textView.TextSnapshot; if (textSpan.End > snapshot.Length) { return(null); } var span = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length))); var locations = new DbgCodeLocation[methodStatements.Count]; for (int i = 0; i < methodStatements.Count; i++) { var statement = methodStatements[i]; var moduleId = moduleIdProvider.Create(statement.Method.Module); locations[i] = dbgDotNetCodeLocationFactory.Value.Create(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start); } return(new DbgTextViewBreakpointLocationResult(locations, span)); }
bool GoTo(IDocumentTab tab, MethodDef method, uint? ilOffset, object @ref) { if (method == null || ilOffset == null) return false; var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) return false; var methodDebugService = documentViewer.GetMethodDebugService(); var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset.Value); if (methodStatement == null) return false; var textSpan = methodStatement.Value.Statement.TextSpan; var loc = FindLocation(documentViewer.Content.ReferenceCollection.FindFrom(textSpan.Start), documentViewer.TextView.TextSnapshot, methodStatement.Value.Statement.TextSpan.End, @ref); if (loc == null) loc = textSpan.Start; documentViewer.MoveCaretToPosition(loc.Value); return true; }
bool GoTo(IDocumentTab tab, MethodDef method, uint ilOffset) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null || method == null) return false; var methodDebugService = documentViewer.GetMethodDebugService(); var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset); if (methodStatement == null) return false; documentViewer.MoveCaretToPosition(methodStatement.Value.Statement.TextSpan.Start); return true; }