private static void NavigateToQuickInfoTarget(string navigationTarget, Document document, IStreamingFindUsagesPresenter streamingPresenter) { var navigateToLinkService = document.Project.Solution.Workspace.Services.GetRequiredService <INavigateToLinkService>(); if (Uri.TryCreate(navigationTarget, UriKind.Absolute, out var absoluteUri)) { navigateToLinkService.TryNavigateToLinkAsync(absoluteUri, CancellationToken.None); return; } SymbolKeyResolution resolvedSymbolKey; try { resolvedSymbolKey = SymbolKey.ResolveString(navigationTarget, document.Project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None), cancellationToken: CancellationToken.None); } catch { // Ignore symbol resolution failures. It likely is just a badly formed URI. return; } if (resolvedSymbolKey.GetAnySymbol() is { } symbol) { GoToDefinitionHelpers.TryGoToDefinition(symbol, document.Project, streamingPresenter, CancellationToken.None); return; } }
private static void NavigateToQuickInfoTarget( string navigationTarget, Workspace workspace, DocumentId documentId, IThreadingContext threadingContext, IStreamingFindUsagesPresenter streamingPresenter) { var solution = workspace.CurrentSolution; SymbolKeyResolution resolvedSymbolKey; try { var project = solution.GetRequiredProject(documentId.ProjectId); resolvedSymbolKey = SymbolKey.ResolveString(navigationTarget, project.GetRequiredCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None), cancellationToken: CancellationToken.None); } catch { // Ignore symbol resolution failures. It likely is just a badly formed URI. return; } if (resolvedSymbolKey.GetAnySymbol() is { } symbol) { GoToDefinitionHelpers.TryGoToDefinition(symbol, solution, threadingContext, streamingPresenter, CancellationToken.None); return; } }
public override bool TryGoToDefinition( ISymbol symbol, Project project, CancellationToken cancellationToken ) { if ( !TryResolveSymbol( symbol, project, cancellationToken, out var searchSymbol, out var searchProject ) ) { return(false); } return(GoToDefinitionHelpers.TryGoToDefinition( searchSymbol, searchProject.Solution, _threadingContext, _streamingPresenter.Value, cancellationToken )); }
public void Navigate(INavigableRelationship relationship) => _waitIndicator.Wait( title: EditorFeaturesResources.Go_to_Definition, message: EditorFeaturesResources.Navigating_to_definition, allowCancel: true, showProgress: false, action: context => GoToDefinitionHelpers.TryGoToDefinition( _definitions, _document.Project.Solution, _definitions[0].NameDisplayParts.GetFullText(), _threadingContext, _presenter));
public void Navigate(INavigableRelationship relationship) => _uiThreadOperationExecutor.Execute( title: EditorFeaturesResources.Go_to_Definition, defaultDescription: EditorFeaturesResources.Navigating_to_definition, allowCancellation: true, showProgress: false, action: context => GoToDefinitionHelpers.TryGoToDefinition( _definitions, _document.Project.Solution, _definitions[0].NameDisplayParts.GetFullText(), _threadingContext, _presenter, context.UserCancellationToken));
public override bool TryGoToDefinition(ISymbol symbol, Project project, CancellationToken cancellationToken) { if (!_navigableItemsPresenters.Any()) { return(false); } ISymbol searchSymbol; Project searchProject; if (!TryResolveSymbol(symbol, project, cancellationToken, out searchSymbol, out searchProject)) { return(false); } return(GoToDefinitionHelpers.TryGoToDefinition( searchSymbol, searchProject, _externalDefinitionProviders, _navigableItemsPresenters, cancellationToken: cancellationToken)); }
public override bool TryGoToDefinition(ISymbol symbol, Project project, CancellationToken cancellationToken) { if (!_navigableItemsPresenters.Any()) { return(false); } ISymbol searchSymbol; Project searchProject; if (!TryResolveSymbol(symbol, project, cancellationToken, out searchSymbol, out searchProject)) { return(false); } return(GoToDefinitionHelpers.TryGoToDefinition( searchSymbol, searchProject, _navigableItemsPresenters, containingTypeSymbol: null, throwOnHiddenDefinition: false, cancellationToken: cancellationToken)); }
public override bool TryGoToDefinition( ISymbol symbol, Project project, CancellationToken cancellationToken) { if (!_navigableItemsPresenters.Any() && !_streamingPresenters.Any()) { return(false); } if (!TryResolveSymbol(symbol, project, cancellationToken, out var searchSymbol, out var searchProject)) { return(false); } return(GoToDefinitionHelpers.TryGoToDefinition( searchSymbol, searchProject, _navigableItemsPresenters, _streamingPresenters, cancellationToken)); }
private bool TryGoToImplementations( ISymbol symbol, Project project, ImmutableArray <ISymbol> implementations, CancellationToken cancellationToken, out string message) { if (implementations.Length == 0) { message = EditorFeaturesResources.The_symbol_has_no_implementations; return(false); } else if (implementations.Length == 1) { GoToDefinitionHelpers.TryGoToDefinition( implementations.Single(), project, _navigableItemPresenters, SpecializedCollections.EmptyEnumerable <Lazy <IStreamingFindUsagesPresenter> >(), cancellationToken); message = null; return(true); } else { return(TryPresentInNavigableItemsPresenter(symbol, project, implementations, out message)); } }
private static void NavigateToQuickInfoTarget( string navigationTarget, Document document, IThreadingContext threadingContext, IStreamingFindUsagesPresenter streamingPresenter) { SymbolKeyResolution resolvedSymbolKey; try { resolvedSymbolKey = SymbolKey.ResolveString(navigationTarget, document.Project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None), cancellationToken: CancellationToken.None); } catch { // Ignore symbol resolution failures. It likely is just a badly formed URI. return; } if (resolvedSymbolKey.GetAnySymbol() is { } symbol) { GoToDefinitionHelpers.TryGoToDefinition(symbol, document.Project.Solution, threadingContext, streamingPresenter, CancellationToken.None); return; } }