public async Task FindReferencesAsync(
            Document document, int position, FindUsagesContext context)
        {
            // NOTE: All ConFigureAwaits in this method need to pass 'true' so that
            // we return to the caller's context.  that's so the call to
            // CallThirdPartyExtensionsAsync will happen on the UI thread.  We need
            // this to maintain the threading guarantee we had around that method
            // from pre-Roslyn days.
            var findReferencesProgress = await FindReferencesWorkerAsync(
                document, position, context).ConfigureAwait(true);

            if (findReferencesProgress == null)
            {
                return;
            }

            // After the FAR engine is done call into any third party extensions to see
            // if they want to add results.
            await findReferencesProgress.CallThirdPartyExtensionsAsync().ConfigureAwait(true);
        }
        private async Task <ProgressAdapter> FindReferencesWorkerAsync(
            Document document, int position, FindUsagesContext context)
        {
            var cancellationToken = context.CancellationToken;

            cancellationToken.ThrowIfCancellationRequested();

            // Find the symbol we want to search and the solution we want to search in.
            var symbolAndProject = await GetRelevantSymbolAndProjectAtPositionAsync(
                document, position, cancellationToken).ConfigureAwait(false);

            if (symbolAndProject == null)
            {
                return(null);
            }

            var symbol  = symbolAndProject.Item1;
            var project = symbolAndProject.Item2;

            var displayName = GetDisplayName(symbol);

            context.SetSearchLabel(displayName);

            var progressAdapter = new ProgressAdapter(project.Solution, context);

            // Now call into the underlying FAR engine to find reference.  The FAR
            // engine will push results into the 'progress' instance passed into it.
            // We'll take those results, massage them, and forward them along to the
            // FindReferencesContext instance we were given.
            await SymbolFinder.FindReferencesAsync(
                SymbolAndProjectId.Create(symbol, project.Id),
                project.Solution,
                progressAdapter,
                documents : null,
                cancellationToken : cancellationToken).ConfigureAwait(false);

            return(progressAdapter);
        }
Пример #3
0
 public MockStreamingFindUsagesPresenter(FindUsagesContext context)
 => _context = context;
 public ProgressAdapter(Solution solution, FindUsagesContext context)
 {
     _solution          = solution;
     _context           = context;
     _definitionFactory = s => s.ToDefinitionItem(solution);
 }
Пример #5
0
 public VSTypeScriptFindUsagesContext(FindUsagesContext underlyingObject)
 => UnderlyingObject = underlyingObject;