public LSPNavigateToCallback(
     RequestContext context,
     BufferedProgress <SymbolInformation> progress)
 {
     _context  = context;
     _progress = progress;
 }
Exemple #2
0
        public override async Task <SymbolInformation[]?> HandleRequestAsync(
            WorkspaceSymbolParams request,
            RequestContext context,
            CancellationToken cancellationToken
            )
        {
            Contract.ThrowIfNull(context.Solution);

            var solution = context.Solution;

            using var progress = BufferedProgress.Create(request.PartialResultToken);
            var searcher = NavigateToSearcher.Create(
                solution,
                _asyncListener,
                new LSPNavigateToCallback(progress),
                request.Query,
                searchCurrentDocument: false,
                s_supportedKinds,
                _threadingContext.DisposalToken
                );

            await searcher.SearchAsync(cancellationToken).ConfigureAwait(false);

            return(progress.GetValues());
        }
            // local functions
            static async Task <SymbolInformation[]?> SearchProjectAsync(Project project, WorkspaceSymbolParams request, CancellationToken cancellationToken)
            {
                using var progress = BufferedProgress.Create(request.PartialResultToken);

                var searchService = project.LanguageServices.GetService <INavigateToSearchService>();

                if (searchService != null)
                {
                    // TODO - Update Kinds Provided to return all necessary symbols.
                    // https://github.com/dotnet/roslyn/projects/45#card-20033822
                    var items = await searchService.SearchProjectAsync(
                        project,
                        ImmutableArray <Document> .Empty,
                        request.Query,
                        searchService.KindsProvided,
                        cancellationToken).ConfigureAwait(false);

                    await Task.WhenAll(items.Select(item => ReportSymbolInformation(progress, item, cancellationToken))).ConfigureAwait(false);
                }

                return(progress.GetValues());
 public LSPNavigateToCallback(BufferedProgress <SymbolInformation> progress)
 {
     _progress = progress;
 }