internal IVsNavInfo GetNavInfo(SymbolListItem symbolListItem, bool useExpandedHierarchy) { var project = GetProject(symbolListItem); if (project == null) { return null; } var compilation = symbolListItem.GetCompilation(this.Workspace); if (compilation == null) { return null; } var symbol = symbolListItem.ResolveSymbol(compilation); if (symbol == null) { return null; } if (symbolListItem is MemberListItem) { return GetMemberNavInfo(symbol, project, compilation, useExpandedHierarchy); } else if (symbolListItem is TypeListItem) { return GetTypeNavInfo((INamedTypeSymbol)symbol, project, compilation, useExpandedHierarchy); } else if (symbolListItem is NamespaceListItem) { return GetNamespaceNavInfo((INamespaceSymbol)symbol, project, compilation, useExpandedHierarchy); } return GetProjectNavInfo(project); }
internal override object GetBrowseObject(SymbolListItem symbolListItem) { var compilation = symbolListItem.GetCompilation(this); if (compilation == null) { return null; } var symbol = symbolListItem.ResolveSymbol(compilation); var sourceLocation = symbol.Locations.Where(l => l.IsInSource).FirstOrDefault(); if (sourceLocation == null) { return null; } var projectId = symbolListItem.ProjectId; if (projectId == null) { return null; } var project = this.CurrentSolution.GetProject(projectId); if (project == null) { return null; } var codeModelService = project.LanguageServices.GetService<ICodeModelService>(); if (codeModelService == null) { return null; } var tree = sourceLocation.SourceTree; var document = project.GetDocument(tree); var vsFileCodeModel = this.GetFileCodeModel(document.Id); var fileCodeModel = ComAggregate.GetManagedObject<FileCodeModel>(vsFileCodeModel); if (fileCodeModel != null) { var syntaxNode = tree.GetRoot().FindNode(sourceLocation.SourceSpan); while (syntaxNode != null) { if (!codeModelService.TryGetNodeKey(syntaxNode).IsEmpty) { break; } syntaxNode = syntaxNode.Parent; } if (syntaxNode != null) { var codeElement = fileCodeModel.CreateCodeElement<EnvDTE.CodeElement>(syntaxNode); if (codeElement != null) { return codeElement; } } } return null; }
internal IVsNavInfo GetNavInfo(SymbolListItem symbolListItem, bool useExpandedHierarchy) { var project = GetProject(symbolListItem); if (project == null) { return null; } var compilation = symbolListItem.GetCompilation(this.Workspace); if (compilation == null) { return null; } var symbol = symbolListItem.ResolveSymbol(compilation); if (symbol == null) { return null; } if (symbolListItem is MemberListItem) { return this.LibraryService.NavInfoFactory.CreateForMember(symbol, project, compilation, useExpandedHierarchy); } else if (symbolListItem is TypeListItem) { return this.LibraryService.NavInfoFactory.CreateForType((INamedTypeSymbol)symbol, project, compilation, useExpandedHierarchy); } else if (symbolListItem is NamespaceListItem) { return this.LibraryService.NavInfoFactory.CreateForNamespace((INamespaceSymbol)symbol, project, compilation, useExpandedHierarchy); } return this.LibraryService.NavInfoFactory.CreateForProject(project); }
internal abstract object GetBrowseObject(SymbolListItem symbolListItem);