private bool TryGetNavigationAPIRequiredArguments( ISymbol symbol, Solution solution, out IVsHierarchy hierarchy, out uint itemID, out IVsSymbolicNavigationNotify navigationNotify, out string rqname) { AssertIsForeground(); hierarchy = null; navigationNotify = null; rqname = null; itemID = (uint)VSConstants.VSITEMID.Nil; if (!symbol.Locations.Any()) { return(false); } var sourceLocations = symbol.Locations.Where(loc => loc.IsInSource); if (!sourceLocations.Any()) { return(false); } var documents = sourceLocations.Select(loc => solution.GetDocument(loc.SourceTree)).WhereNotNull(); if (!documents.Any()) { return(false); } // We can only pass one itemid to IVsSymbolicNavigationNotify, so prefer itemids from // documents we consider to be "generated" to give external language services the best // chance of participating. var generatedCodeRecognitionService = solution.Workspace.Services.GetService <IGeneratedCodeRecognitionService>(); var generatedDocuments = documents.Where(d => generatedCodeRecognitionService.IsGeneratedCode(d)); var documentToUse = generatedDocuments.FirstOrDefault() ?? documents.First(); if (!TryGetVsHierarchyAndItemId(documentToUse, out hierarchy, out itemID)) { return(false); } navigationNotify = hierarchy as IVsSymbolicNavigationNotify; if (navigationNotify == null) { return(false); } rqname = LanguageServices.RQName.From(symbol); return(rqname != null); }
private bool TryGetNavigationAPIRequiredArguments( DefinitionItem definitionItem, string rqName, Solution solution, CancellationToken cancellationToken, out IVsHierarchy hierarchy, out uint itemID, out IVsSymbolicNavigationNotify navigationNotify) { AssertIsForeground(); hierarchy = null; navigationNotify = null; itemID = (uint)VSConstants.VSITEMID.Nil; if (rqName == null) { return(false); } var sourceLocations = definitionItem.SourceSpans; if (!sourceLocations.Any()) { return(false); } var documents = sourceLocations.SelectAsArray(loc => loc.Document); // We can only pass one itemid to IVsSymbolicNavigationNotify, so prefer itemids from // documents we consider to be "generated" to give external language services the best // chance of participating. var generatedDocuments = documents.WhereAsArray(d => d.IsGeneratedCode(cancellationToken)); var documentToUse = generatedDocuments.FirstOrDefault() ?? documents.First(); if (!TryGetVsHierarchyAndItemId(documentToUse, out hierarchy, out itemID)) { return(false); } navigationNotify = hierarchy as IVsSymbolicNavigationNotify; if (navigationNotify == null) { return(false); } return(true); }
private bool TryGetNavigationAPIRequiredArguments(ISymbol symbol, Solution solution, out IVsHierarchy hierarchy, out IVsSymbolicNavigationNotify navigationNotify, out string rqname) { hierarchy = null; navigationNotify = null; rqname = null; if (!symbol.Locations.Any() || !symbol.Locations[0].IsInSource) { return(false); } var document = solution.GetDocument(symbol.Locations[0].SourceTree); if (document == null) { return(false); } hierarchy = GetVsHierarchy(document.Project); navigationNotify = hierarchy as IVsSymbolicNavigationNotify; if (navigationNotify == null) { return(false); } return(RQNameService.TryBuild(symbol, out rqname)); }
private bool TryGetNavigationAPIRequiredArguments( ISymbol symbol, Solution solution, out IVsHierarchy hierarchy, out uint itemID, out IVsSymbolicNavigationNotify navigationNotify, out string rqname) { AssertIsForeground(); hierarchy = null; navigationNotify = null; rqname = null; itemID = (uint)VSConstants.VSITEMID.Nil; if (!symbol.Locations.Any()) { return false; } var sourceLocations = symbol.Locations.Where(loc => loc.IsInSource); if (!sourceLocations.Any()) { return false; } var documents = sourceLocations.Select(loc => solution.GetDocument(loc.SourceTree)).WhereNotNull(); if (!documents.Any()) { return false; } // We can only pass one itemid to IVsSymbolicNavigationNotify, so prefer itemids from // documents we consider to be "generated" to give external language services the best // chance of participating. var generatedCodeRecognitionService = solution.Workspace.Services.GetService<IGeneratedCodeRecognitionService>(); var generatedDocuments = documents.Where(d => generatedCodeRecognitionService.IsGeneratedCode(d)); var documentToUse = generatedDocuments.FirstOrDefault() ?? documents.First(); if (!TryGetVsHierarchyAndItemId(documentToUse, out hierarchy, out itemID)) { return false; } navigationNotify = hierarchy as IVsSymbolicNavigationNotify; if (navigationNotify == null) { return false; } rqname = LanguageServices.RQName.From(symbol); return rqname != null; }