示例#1
0
        public bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken)
        {
            // Try to compute the referenced symbol and attempt to go to definition for the symbol.
            var symbolService = document.GetLanguageService <IGoToDefinitionSymbolService>();

            var(symbol, _) = symbolService.GetSymbolAndBoundSpanAsync(document, position, includeType: true, cancellationToken).WaitAndGetResult(cancellationToken);
            if (symbol is null)
            {
                return(false);
            }

            // if the symbol only has a single source location, and we're already on it,
            // try to see if there's a better symbol we could navigate to.
            var remapped = TryGoToAlternativeLocationIfAlreadyOnDefinition(document, position, symbol, cancellationToken);

            if (remapped)
            {
                return(true);
            }

            var isThirdPartyNavigationAllowed = IsThirdPartyNavigationAllowed(symbol, position, document, cancellationToken);

            return(GoToDefinitionHelpers.TryGoToDefinition(symbol,
                                                           document.Project,
                                                           _streamingPresenter.Value,
                                                           thirdPartyNavigationAllowed: isThirdPartyNavigationAllowed,
                                                           cancellationToken: cancellationToken));
        }
示例#2
0
        public bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken)
        {
            // First try to compute the referenced symbol and attempt to go to definition for the symbol.
            var symbol = FindSymbolAsync(document, position, cancellationToken).WaitAndGetResult(cancellationToken);

            if (symbol == null)
            {
                return(false);
            }

            var isThirdPartyNavigationAllowed = IsThirdPartyNavigationAllowed(symbol, position, document, cancellationToken);

            return(GoToDefinitionHelpers.TryGoToDefinition(symbol,
                                                           document.Project,
                                                           _streamingPresenters,
                                                           thirdPartyNavigationAllowed: isThirdPartyNavigationAllowed,
                                                           throwOnHiddenDefinition: true,
                                                           cancellationToken: cancellationToken));
        }
示例#3
0
        public bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken)
        {
            // Try to compute the referenced symbol and attempt to go to definition for the symbol.
            var symbolService = document.GetLanguageService <IGoToDefinitionSymbolService>();

            var(symbol, _) = symbolService.GetSymbolAndBoundSpanAsync(document, position, includeType: true, cancellationToken).WaitAndGetResult(cancellationToken);
            if (symbol is null)
            {
                return(false);
            }

            var isThirdPartyNavigationAllowed = IsThirdPartyNavigationAllowed(symbol, position, document, cancellationToken);

            return(GoToDefinitionHelpers.TryGoToDefinition(symbol,
                                                           document.Project,
                                                           _streamingPresenter.Value,
                                                           thirdPartyNavigationAllowed: isThirdPartyNavigationAllowed,
                                                           throwOnHiddenDefinition: true,
                                                           cancellationToken: cancellationToken));
        }