コード例 #1
0
        private static async Task <ImmutableArray <ReferencedSymbol> > FindCallReferencesAsync(
            Solution solution,
            SymbolAndProjectId symbolAndProjectId,
            IImmutableSet <Document> documents,
            CancellationToken cancellationToken = default)
        {
            var symbol = symbolAndProjectId.Symbol;

            if (symbol != null)
            {
                if (symbol.Kind == SymbolKind.Event ||
                    symbol.Kind == SymbolKind.Method ||
                    symbol.Kind == SymbolKind.Property)
                {
                    var collector = new StreamingProgressCollector();
                    await FindReferencesAsync(
                        symbolAndProjectId, solution, collector, documents,
                        FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false);

                    return(collector.GetReferencedSymbols());
                }
            }

            return(ImmutableArray <ReferencedSymbol> .Empty);
        }
コード例 #2
0
        internal static async Task <ImmutableArray <ReferencedSymbol> > FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            IFindReferencesProgress progress,
            IImmutableSet <Document> documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken
            )
        {
            progress ??= NoOpFindReferencesProgress.Instance;
            var streamingProgress = new StreamingProgressCollector(
                new StreamingFindReferencesProgressAdapter(progress)
                );

            await FindReferencesAsync(
                symbol,
                solution,
                streamingProgress,
                documents,
                options,
                cancellationToken
                )
            .ConfigureAwait(false);

            return(streamingProgress.GetReferencedSymbols());
        }
コード例 #3
0
        private static async Task <ImmutableArray <ReferencedSymbol> > FindCallReferencesAsync(
            Solution solution,
            ISymbol symbol,
            IImmutableSet <Document> documents,
            CancellationToken cancellationToken = default)
        {
            Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);

            if (symbol != null)
            {
                if (symbol.Kind == SymbolKind.Event ||
                    symbol.Kind == SymbolKind.Method ||
                    symbol.Kind == SymbolKind.Property)
                {
                    var collector = new StreamingProgressCollector();
                    await FindReferencesAsync(
                        symbol, solution, collector, documents,
                        FindReferencesSearchOptions.Default, cancellationToken).ConfigureAwait(false);

                    return(collector.GetReferencedSymbols());
                }
            }

            return(ImmutableArray <ReferencedSymbol> .Empty);
        }
コード例 #4
0
 /// <summary>
 /// Finds all references to a symbol throughout a solution
 /// </summary>
 /// <param name="symbol">The symbol to find references to.</param>
 /// <param name="solution">The solution to find references within.</param>
 /// <param name="cancellationToken">A cancellation token.</param>
 public static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync(
     ISymbol symbol,
     Solution solution,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     var progressCollector = new StreamingProgressCollector(StreamingFindReferencesProgress.Instance);
     await FindReferencesAsync(
         SymbolAndProjectId.Create(symbol, projectId: null),
         solution, progress: progressCollector,
         documents: null, cancellationToken: cancellationToken).ConfigureAwait(false);
     return progressCollector.GetReferencedSymbols();
 }
コード例 #5
0
        internal static async Task <IEnumerable <ReferencedSymbol> > FindReferencesAsync(
            SymbolAndProjectId symbolAndProjectId,
            Solution solution,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            var progressCollector = new StreamingProgressCollector(StreamingFindReferencesProgress.Instance);

            await FindReferencesAsync(
                symbolAndProjectId, solution, progressCollector,
                documents : null, options, cancellationToken).ConfigureAwait(false);

            return(progressCollector.GetReferencedSymbols());
        }
        /// <summary>
        /// Finds all references to a symbol throughout a solution
        /// </summary>
        /// <param name="symbol">The symbol to find references to.</param>
        /// <param name="solution">The solution to find references within.</param>
        /// <param name="cancellationToken">A cancellation token.</param>
        public static async Task <IEnumerable <ReferencedSymbol> > FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            CancellationToken cancellationToken = default)
        {
            var progressCollector = new StreamingProgressCollector(StreamingFindReferencesProgress.Instance);

            await FindReferencesAsync(
                SymbolAndProjectId.Create(symbol, projectId: null),
                solution, progress : progressCollector,
                documents : null, cancellationToken : cancellationToken).ConfigureAwait(false);

            return(progressCollector.GetReferencedSymbols());
        }
コード例 #7
0
 /// <summary>
 /// Finds all references to a symbol throughout a solution
 /// </summary>
 /// <param name="symbol">The symbol to find references to.</param>
 /// <param name="solution">The solution to find references within.</param>
 /// <param name="progress">An optional progress object that will receive progress
 /// information as the search is undertaken.</param>
 /// <param name="documents">An optional set of documents to be searched. If documents is null, then that means "all documents".</param>
 /// <param name="cancellationToken">An optional cancellation token.</param>
 public static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync(
     ISymbol symbol,
     Solution solution,
     IFindReferencesProgress progress,
     IImmutableSet<Document> documents,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     progress = progress ?? FindReferencesProgress.Instance;
     var streamingProgress = new StreamingProgressCollector(
         new StreamingFindReferencesProgressAdapter(progress));
     await FindReferencesAsync(
         SymbolAndProjectId.Create(symbol, projectId: null),
         solution, streamingProgress, documents, cancellationToken).ConfigureAwait(false);
     return streamingProgress.GetReferencedSymbols();
 }
コード例 #8
0
        internal static async Task <IEnumerable <ReferencedSymbol> > FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);

            var progressCollector = new StreamingProgressCollector();

            await FindReferencesAsync(
                symbol, solution, progressCollector,
                documents : null, options, cancellationToken).ConfigureAwait(false);

            return(progressCollector.GetReferencedSymbols());
        }
        /// <summary>
        /// Finds all references to a symbol throughout a solution
        /// </summary>
        /// <param name="symbol">The symbol to find references to.</param>
        /// <param name="solution">The solution to find references within.</param>
        /// <param name="progress">An optional progress object that will receive progress
        /// information as the search is undertaken.</param>
        /// <param name="documents">An optional set of documents to be searched. If documents is null, then that means "all documents".</param>
        /// <param name="cancellationToken">An optional cancellation token.</param>
        public static async Task <IEnumerable <ReferencedSymbol> > FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            IFindReferencesProgress progress,
            IImmutableSet <Document> documents,
            CancellationToken cancellationToken = default)
        {
            progress = progress ?? FindReferencesProgress.Instance;
            var streamingProgress = new StreamingProgressCollector(
                new StreamingFindReferencesProgressAdapter(progress));

            await FindReferencesAsync(
                SymbolAndProjectId.Create(symbol, projectId: null),
                solution, streamingProgress, documents, cancellationToken).ConfigureAwait(false);

            return(streamingProgress.GetReferencedSymbols());
        }
コード例 #10
0
        private static async Task <IEnumerable <ReferencedSymbol> > FindReferencesAsync(
            ISymbol symbol,
            Solution solution,
            IFindReferencesProgress progress,
            IImmutableSet <Document> documents,
            FindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);

            progress ??= NoOpFindReferencesProgress.Instance;
            var streamingProgress = new StreamingProgressCollector(
                new StreamingFindReferencesProgressAdapter(progress));

            await FindReferencesAsync(
                symbol, solution, streamingProgress, documents,
                options, cancellationToken).ConfigureAwait(false);

            return(streamingProgress.GetReferencedSymbols());
        }
コード例 #11
0
        internal static async Task <ImmutableArray <ReferencedSymbol> > FindRenamableReferencesAsync(
            ImmutableArray <ISymbol> symbols,
            Solution solution,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.FindReference_Rename, cancellationToken))
            {
                var streamingProgress = new StreamingProgressCollector();

                var engine = new FindReferencesSearchEngine(
                    solution,
                    documents: null,
                    ReferenceFinders.DefaultRenameReferenceFinders,
                    streamingProgress,
                    FindReferencesSearchOptions.Default);

                await engine.FindReferencesAsync(symbols, cancellationToken).ConfigureAwait(false);

                return(streamingProgress.GetReferencedSymbols());
            }
        }
コード例 #12
0
        private static async Task <ImmutableArray <ReferencedSymbol> > FindCallReferencesAsync(
            Solution solution,
            ISymbol symbol,
            IImmutableSet <Document>?documents,
            CancellationToken cancellationToken = default)
        {
            if (symbol.Kind is SymbolKind.Event or
                SymbolKind.Method or
                SymbolKind.Property or
                SymbolKind.Field)
            {
                var collector = new StreamingProgressCollector();
                var options   = FindReferencesSearchOptions.GetFeatureOptionsForStartingSymbol(symbol);
                await FindReferencesAsync(
                    symbol, solution, collector, documents,
                    options, cancellationToken).ConfigureAwait(false);

                return(collector.GetReferencedSymbols());
            }

            return(ImmutableArray <ReferencedSymbol> .Empty);
        }
コード例 #13
0
        private async Task<ImmutableArray<DocumentHighlights>> GetTagsForReferencedSymbolAsync(
            SymbolAndProjectId symbolAndProjectId,
            IImmutableSet<Document> documentsToSearch,
            Solution solution,
            CancellationToken cancellationToken)
        {
            var symbol = symbolAndProjectId.Symbol;
            Contract.ThrowIfNull(symbol);
            if (ShouldConsiderSymbol(symbol))
            {
                var progress = new StreamingProgressCollector(
                    StreamingFindReferencesProgress.Instance);
                await SymbolFinder.FindReferencesAsync(
                    symbolAndProjectId, solution, progress,
                    documentsToSearch, cancellationToken).ConfigureAwait(false);

                return await FilterAndCreateSpansAsync(
                    progress.GetReferencedSymbols(), solution, documentsToSearch, 
                    symbol, cancellationToken).ConfigureAwait(false);
            }

            return ImmutableArray<DocumentHighlights>.Empty;
        }
コード例 #14
0
        internal static async Task <ImmutableArray <ReferencedSymbol> > FindRenamableReferencesAsync(
            SymbolAndProjectId symbolAndProjectId,
            Solution solution,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.FindReference_Rename, cancellationToken))
            {
                var streamingProgress = new StreamingProgressCollector(
                    StreamingFindReferencesProgress.Instance);

                IImmutableSet <Document> documents = null;
                var engine = new FindReferencesSearchEngine(
                    solution,
                    documents,
                    ReferenceFinders.DefaultRenameReferenceFinders,
                    streamingProgress,
                    cancellationToken);

                await engine.FindReferencesAsync(symbolAndProjectId).ConfigureAwait(false);

                return(streamingProgress.GetReferencedSymbols());
            }
        }
コード例 #15
0
        internal static async Task<ImmutableArray<ReferencedSymbol>> FindRenamableReferencesAsync(
            SymbolAndProjectId symbolAndProjectId,
            Solution solution,
            CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.FindReference_Rename, cancellationToken))
            {
                var streamingProgress = new StreamingProgressCollector(
                    StreamingFindReferencesProgress.Instance);

                IImmutableSet<Document> documents = null;
                var engine = new FindReferencesSearchEngine(
                    solution,
                    documents,
                    ReferenceFinders.DefaultRenameReferenceFinders,
                    streamingProgress,
                    cancellationToken);

                await engine.FindReferencesAsync(symbolAndProjectId).ConfigureAwait(false);
                return streamingProgress.GetReferencedSymbols();
            }
        }