internal static async Task <ImmutableArray <ISymbol> > FindSourceDeclarationsWithCustomQueryAsync(
            Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (query.Name != null && string.IsNullOrWhiteSpace(query.Name))
            {
                return(ImmutableArray <ISymbol> .Empty);
            }

            using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Predicate_FindSourceDeclarationsAsync, cancellationToken))
            {
                if (await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false))
                {
                    var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);

                    var unfiltered = compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken)
                                     .ToImmutableArray();

                    return(DeclarationFinder.FilterByCriteria(unfiltered, filter));
                }
            }

            return(ImmutableArray <ISymbol> .Empty);
        }
예제 #2
0
        public async Task <ImmutableArray <ISymbol> > FindAsync(
            SearchQuery query, AsyncLazy <IAssemblySymbol> lazyAssembly,
            SymbolFilter filter, CancellationToken cancellationToken)
        {
            // All entrypoints to this function are Find functions that are only searching
            // for specific strings (i.e. they never do a custom search).
            Contract.ThrowIfTrue(query.Kind == SearchKind.Custom, "Custom queries are not supported in this API");

            var symbols = await FindCoreAsync(query, lazyAssembly, cancellationToken).ConfigureAwait(false);

            return(DeclarationFinder.FilterByCriteria(symbols, filter));
        }
예제 #3
0
        public async Task <ImmutableArray <SymbolAndProjectId> > FindAsync(
            SearchQuery query, AsyncLazy <IAssemblySymbol> lazyAssembly, ProjectId assemblyProjectId,
            SymbolFilter filter, CancellationToken cancellationToken)
        {
            // All entrypoints to this function are Find functions that are only searching
            // for specific strings (i.e. they never do a custom search).
            Debug.Assert(query.Kind != SearchKind.Custom);

            var symbols = await FindAsyncWorker(query, lazyAssembly, cancellationToken).ConfigureAwait(false);

            return(DeclarationFinder.FilterByCriteria(
                       symbols.SelectAsArray(s => new SymbolAndProjectId(s, assemblyProjectId)),
                       filter));
        }