private async Task FindReferencesAsync( IStreamingFindUsagesPresenter presenter, SymbolListItem symbolListItem, Project project) { try { // Let the presented know we're starting a search. It will give us back // the context object that the FAR service will push results into. var context = presenter.StartSearch( EditorFeaturesResources.Find_References, supportsReferences: true); var cancellationToken = context.CancellationToken; // Kick off the work to do the actual finding on a BG thread. That way we don' // t block the calling (UI) thread too long if we happen to do our work on this // thread. await Task.Run(async() => { await FindReferencesAsync(_threadingContext, symbolListItem, project, context, cancellationToken).ConfigureAwait(false); }, cancellationToken).ConfigureAwait(false); // Note: we don't need to put this in a finally. The only time we might not hit // this is if cancellation or another error gets thrown. In the former case, // that means that a new search has started. We don't care about telling the // context it has completed. In the latter case something wrong has happened // and we don't want to run any more code in this particular context. await context.OnCompletedAsync().ConfigureAwait(false); } catch (OperationCanceledException) { } catch (Exception e) when(FatalError.ReportWithoutCrash(e)) { } }
private static async Task FindReferencesAsync(SymbolListItem symbolListItem, Project project, CodeAnalysis.FindUsages.FindUsagesContext context) { var compilation = await project.GetCompilationAsync(context.CancellationToken).ConfigureAwait(false); var symbol = symbolListItem.ResolveSymbol(compilation); if (symbol != null) { await AbstractFindUsagesService.FindSymbolReferencesAsync(context, symbol, project).ConfigureAwait(false); } }
public void UpdateItems() { // Updates items in listbox from symbol table Items.Clear(); foreach (ScriptingSymbol symb in _symbols) { if (symb.Enabled) { SymbolListItem item = new SymbolListItem(); item.Name = symb.Name; item.Ndx = getInfoByType(symb.Type).Ndx; Items.Add(item); } } bool flag = true; if (flag) { flag = true; } }
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 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)); }
private void InitControl(ISymbol pSym) { this.symbolItem1.Symbol = pSym; if (pSym is IMultiLayerMarkerSymbol) { this.symbolListBox1.Items.Clear(); this.m_oldSel = -1; for (int i = 0; i < ((IMultiLayerMarkerSymbol)pSym).LayerCount; i++) { SymbolListItem item = new SymbolListItem { m_pSymbol = (ISymbol)((IMultiLayerMarkerSymbol)pSym).get_Layer(i), m_bVisible = ((ILayerVisible)pSym).get_LayerVisible(i), m_bLockColor = ((ILayerColorLock)pSym).get_LayerColorLock(i) }; this.symbolListBox1.Items.Add(item); } if (this.symbolListBox1.Items.Count > 0) { this.symbolListBox1.SelectedIndex = this.m_OldSelItem; } } }
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.GetOrCreateCodeElement <EnvDTE.CodeElement>(syntaxNode); if (codeElement != null) { return(codeElement); } } } return(null); }
internal abstract object?GetBrowseObject(SymbolListItem symbolListItem);
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; Contract.ThrowIfNull(tree, "We have a location that was in source, but doesn't have a SourceTree."); var document = project.GetDocument(tree); Contract.ThrowIfNull(document, "We have a symbol coming from a tree, and that tree isn't in the Project it supposedly came from."); var vsFileCodeModel = this.GetFileCodeModel(document.Id); var fileCodeModel = ComAggregate.GetManagedObject <FileCodeModel>(vsFileCodeModel); if (fileCodeModel != null) { SyntaxNode?syntaxNode = tree.GetRoot().FindNode(sourceLocation.SourceSpan); while (syntaxNode != null) { if (!codeModelService.TryGetNodeKey(syntaxNode).IsEmpty) { break; } syntaxNode = syntaxNode.Parent; } if (syntaxNode != null) { var codeElement = fileCodeModel.GetOrCreateCodeElement <EnvDTE.CodeElement>(syntaxNode); if (codeElement != null) { return(codeElement); } } } return(null); }
public void Add(SymbolListItem item) { _itemList.Add(item); }