bool UpdateMarkers() { try { var dom = SyntaxTree; if (dom == null) { return(false); } ResolutionContext ctxt; var rr = DResolverWrapper.ResolveHoveredCode(out ctxt, Document); if (rr == null || rr.Length < 1) { return(false); } var parseCache = Document.HasProject ? (Document.Project as AbstractDProject).ParseCache : DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView(); var mr = rr[0] as DSymbol; if (mr == null) { return(false); } var referencedNode = mr.Definition; // Slightly hacky: To keep highlighting the id of e.g. a NewExpression, take the ctor's parent node (i.e. the class node) if (referencedNode is DMethod && ((DMethod)referencedNode).SpecialType == DMethod.MethodType.Constructor) { mr = mr.Base as DSymbol; referencedNode = mr.Definition; } try { var references = D_Parser.Refactoring.ReferencesFinder.Scan(dom, referencedNode, ctxt).ToList(); if (references.Count > 0) { ShowReferences(references); } } catch (Exception ex) { LoggingService.LogWarning("Error during usage highlighting analysis", ex); } } catch (Exception ex) { LoggingService.LogDebug("Error while highlighting symbol usages", ex); } return(false); }
/// <summary> /// Reads the current caret context, and opens the adequate reference site in the default browser /// </summary> public static string GetReferenceUrl() { var caret = Ide.IdeApp.Workbench.ActiveDocument.Editor.Caret.Location; ResolutionContext ctxt = null; var rr = DResolverWrapper.ResolveHoveredCode(out ctxt, Ide.IdeApp.Workbench.ActiveDocument); return(GetReferenceUrl(rr != null ? rr [0] : null, ctxt, new CodeLocation(caret.Column, caret.Line))); }
protected override bool TryResolve(out Tuple <ResolutionContext, DSymbol> resolveResult) { ResolutionContext lastCtxt; IEditorData ed; var rr = DResolverWrapper.ResolveHoveredCode(out lastCtxt, out ed, Document); if (rr == null || rr.Length < 1 || !(rr[0] is DSymbol)) { resolveResult = null; return(false); } resolveResult = new Tuple <ResolutionContext, DSymbol>(lastCtxt, rr[0] as DSymbol); return(true); }
void FindReferences_Upd(CommandInfo ci) { lastResults = DResolverWrapper.ResolveHoveredCode(out lastContext); if (lastResults == null || lastResults.Length == 0) { ci.Bypass = true; return; } ci.Bypass = true; foreach (var r in lastResults) { if ((firstResultNode = DResolver.GetResultMember(r)) != null) { ci.Bypass = false; return; } } }
bool UpdateMarkers() { try { var dom = SyntaxTree; if (dom == null) { return(false); } ResolverContextStack ctxt; var rr = DResolverWrapper.ResolveHoveredCode(out ctxt, Document); if (rr == null || rr.Length < 1) { return(false); } var parseCache = Document.HasProject ? (Document.Project as DProject).ParseCache : ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache); var mr = rr[0] as DSymbol; if (mr == null) { return(false); } var referencedNode = mr.Definition; // Slightly hacky: To keep highlighting the id of e.g. a NewExpression, take the ctor's parent node (i.e. the class node) if (referencedNode is DMethod && ((DMethod)referencedNode).SpecialType == DMethod.MethodType.Constructor) { mr = mr.Base as DSymbol; referencedNode = mr.Definition; } try { var references = D_Parser.Refactoring.ReferencesFinder.Scan(dom, referencedNode, ctxt).ToList(); // Highlight the node's definition location - only if the node is located in the current document if (referencedNode.NodeRoot is IAbstractSyntaxTree && (referencedNode.NodeRoot as IAbstractSyntaxTree).FileName == dom.FileName) { references.Add(new IdentifierDeclaration(referencedNode.Name) { Location = referencedNode.NameLocation, EndLocation = new CodeLocation(referencedNode.NameLocation.Column + referencedNode.Name.Length, referencedNode.NameLocation.Line) }); } if (references.Count > 0) { ShowReferences(references); } } catch (Exception ex) { LoggingService.LogWarning("Error during usage highlighting analysis", ex); } } catch (Exception ex) { LoggingService.LogDebug("Error while highlighting symbol usages", ex); } return(false); }