Ejemplo n.º 1
0
        public Task <(IList <SerializableImportCompletionItem>, StatisticCounter)> GetUnimportedExtensionMethodsAsync(
            DocumentId documentId,
            int position,
            string receiverTypeSymbolKeyData,
            string[] namespaceInScope,
            bool forceIndexCreation,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);
                    var document = solution.GetDocument(documentId) !;
                    var compilation = (await document.Project.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false));
                    var symbol = SymbolKey.ResolveString(receiverTypeSymbolKeyData, compilation, cancellationToken: cancellationToken).GetAnySymbol();

                    if (symbol is ITypeSymbol receiverTypeSymbol)
                    {
                        var syntaxFacts = document.GetRequiredLanguageService <ISyntaxFactsService>();
                        var namespaceInScopeSet = new HashSet <string>(namespaceInScope, syntaxFacts.StringComparer);

                        var(items, counter) = await ExtensionMethodImportCompletionHelper.GetUnimportedExtensionMethodsInCurrentProcessAsync(
                            document, position, receiverTypeSymbol, namespaceInScopeSet, forceIndexCreation, cancellationToken).ConfigureAwait(false);
                        return ((IList <SerializableImportCompletionItem>)items, counter);
                    }

                    return (Array.Empty <SerializableImportCompletionItem>(), new StatisticCounter());
                }
            }, cancellationToken));
        }
Ejemplo n.º 2
0
        public Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndProjectIdArg, DocumentId[] documentArgs, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                    var symbolAndProjectId = await symbolAndProjectIdArg.TryRehydrateAsync(
                        solution, cancellationToken).ConfigureAwait(false);

                    var progressCallback = new FindReferencesProgressCallback(this);

                    if (!symbolAndProjectId.HasValue)
                    {
                        await progressCallback.OnStartedAsync().ConfigureAwait(false);
                        await progressCallback.OnCompletedAsync().ConfigureAwait(false);
                        return;
                    }

                    // NOTE: In projection scenarios, we might get a set of documents to search
                    // that are not all the same language and might not exist in the OOP process
                    // (like the JS parts of a .cshtml file). Filter them out here.  This will
                    // need to be revisited if we someday support FAR between these languages.
                    var documents = documentArgs?.Select(solution.GetDocument)
                                    .WhereNotNull()
                                    .ToImmutableHashSet();

                    await SymbolFinder.FindReferencesInCurrentProcessAsync(
                        symbolAndProjectId.Value, solution,
                        progressCallback, documents, cancellationToken).ConfigureAwait(false);
                }
            }, cancellationToken));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is top level entry point for diagnostic calculation from client (VS).
        ///
        /// This will be called by ServiceHub/JsonRpc framework
        /// </summary>
        public Task CalculateDiagnosticsAsync(DiagnosticArguments arguments, string streamName, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                // if this analysis is explicitly asked by user, boost priority of this request
                using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken))
                    using (arguments.ForcedAnalysis ? UserOperationBooster.Boost() : default)
                    {
                        try
                        {
                            // entry point for diagnostic service
                            var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                            var optionSet = await RoslynServices.AssetService.GetAssetAsync <OptionSet>(arguments.OptionSetChecksum, cancellationToken).ConfigureAwait(false);
                            var projectId = arguments.ProjectId;
                            var analyzers = RoslynServices.AssetService.GetGlobalAssetsOfType <AnalyzerReference>(cancellationToken);

                            var result = await(new DiagnosticComputer(solution.GetProject(projectId))).GetDiagnosticsAsync(
                                analyzers, optionSet, arguments.AnalyzerIds, arguments.ReportSuppressedDiagnostics, arguments.LogAnalyzerExecutionTime, cancellationToken).ConfigureAwait(false);

                            await SerializeDiagnosticResultAsync(streamName, result, cancellationToken).ConfigureAwait(false);
                        }
                        catch (IOException)
                        {
                            // direct stream to send over result has closed before we
                            // had chance to check cancellation
                        }
                    }
            }, cancellationToken));
        }
        public Task <SerializableConflictResolution> RenameSymbolAsync(
            PinnedSolutionInfo solutionInfo,
            SerializableSymbolAndProjectId symbolAndProjectId,
            string newName,
            SerializableRenameOptionSet options,
            SerializableSymbolAndProjectId[] nonConflictSymbolIds,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync <SerializableConflictResolution>(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var symbol = await symbolAndProjectId.TryRehydrateAsync(
                        solution, cancellationToken).ConfigureAwait(false);

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

                    var nonConflictSymbols = await GetNonConflictSymbolsAsync(solution, nonConflictSymbolIds, cancellationToken).ConfigureAwait(false);

                    var result = await Renamer.RenameSymbolAsync(
                        solution, symbol, newName, options.Rehydrate(),
                        nonConflictSymbols, cancellationToken).ConfigureAwait(false);
                    return await result.DehydrateAsync(cancellationToken).ConfigureAwait(false);
                }
            }, cancellationToken));
        }
        private Task <ImmutableArray <SerializableSymbolAndProjectId> > FindAndCacheTypesAsync(
            PinnedSolutionInfo solutionInfo,
            SerializableSymbolAndProjectId typeAndProjectId,
            ProjectId[] projectIds,
            Func <INamedTypeSymbol, Solution, ImmutableHashSet <Project>, Task <ImmutableArray <INamedTypeSymbol> > > func,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var symbol = await typeAndProjectId.TryRehydrateAsync(
                        solution, cancellationToken).ConfigureAwait(false);

                    if (!(symbol is INamedTypeSymbol namedType))
                    {
                        return ImmutableArray <SerializableSymbolAndProjectId> .Empty;
                    }

                    var projects = projectIds?.Select(id => solution.GetProject(id)).ToImmutableHashSet();
                    var types = await func(namedType, solution, projects).ConfigureAwait(false);

                    return types.SelectAsArray(
                        (Func <INamedTypeSymbol, SerializableSymbolAndProjectId>)(t => SerializableSymbolAndProjectId.Dehydrate(solution, t, cancellationToken)));
                }
            }, cancellationToken));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Calculate dignostics. this works differently than other ones such as todo comments or designer attribute scanner
        /// since in proc and out of proc runs quite differently due to concurrency and due to possible amount of data
        /// that needs to pass through between processes
        /// </summary>
        public Task CalculateDiagnosticsAsync(PinnedSolutionInfo solutionInfo, DiagnosticArguments arguments, string pipeName, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken))
                    using (arguments.IsHighPriority ? UserOperationBooster.Boost() : default)
                    {
                        var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                        var documentId = arguments.DocumentId;
                        var projectId = arguments.ProjectId;
                        var project = solution.GetProject(projectId);
                        var documentSpan = arguments.DocumentSpan;
                        var documentAnalysisKind = arguments.DocumentAnalysisKind;
                        var diagnosticComputer = new DiagnosticComputer(documentId, project, documentSpan, documentAnalysisKind, _analyzerInfoCache);

                        var result = await diagnosticComputer.GetDiagnosticsAsync(
                            arguments.AnalyzerIds,
                            reportSuppressedDiagnostics: arguments.ReportSuppressedDiagnostics,
                            logPerformanceInfo: arguments.LogPerformanceInfo,
                            getTelemetryInfo: arguments.GetTelemetryInfo,
                            cancellationToken).ConfigureAwait(false);

                        await RemoteEndPoint.WriteDataToNamedPipeAsync(pipeName, (result, documentAnalysisKind), (writer, data, cancellationToken) =>
                        {
                            var(diagnostics, telemetry) = DiagnosticResultSerializer.WriteDiagnosticAnalysisResults(writer, data.documentAnalysisKind, data.result, cancellationToken);

                            // save log for debugging
                            Log(TraceEventType.Information, $"diagnostics: {diagnostics}, telemetry: {telemetry}");

                            return Task.CompletedTask;
                        }, cancellationToken).ConfigureAwait(false);
                    }
            }, cancellationToken));
        }
        public Task <SerializableRenameLocations> FindRenameLocationsAsync(
            PinnedSolutionInfo solutionInfo,
            SerializableSymbolAndProjectId symbolAndProjectId,
            SerializableRenameOptionSet options,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync <SerializableRenameLocations>(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var symbol = await symbolAndProjectId.TryRehydrateAsync(
                        solution, cancellationToken).ConfigureAwait(false);

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

                    var result = await RenameLocations.FindLocationsAsync(
                        symbol, solution, options.Rehydrate(), cancellationToken).ConfigureAwait(false);
                    return result.Dehydrate(solution, cancellationToken);
                }
            }, cancellationToken));
        }
        public Task <SerializableConvertTupleToStructResult> ConvertToStructAsync(
            PinnedSolutionInfo solutionInfo,
            DocumentId documentId,
            TextSpan span,
            Scope scope,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync <SerializableConvertTupleToStructResult>(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var document = solution.GetDocument(documentId);

                    var service = document.GetLanguageService <IConvertTupleToStructCodeRefactoringProvider>();
                    var updatedSolution = await service.ConvertToStructAsync(document, span, scope, cancellationToken).ConfigureAwait(false);

                    var cleanedSolution = await CleanupAsync(solution, updatedSolution, cancellationToken).ConfigureAwait(false);

                    var documentTextChanges = await RemoteUtilities.GetDocumentTextChangesAsync(
                        solution, cleanedSolution, cancellationToken).ConfigureAwait(false);
                    var renamedToken = await GetRenamedTokenAsync(
                        solution, cleanedSolution, cancellationToken).ConfigureAwait(false);

                    return new SerializableConvertTupleToStructResult
                    {
                        DocumentTextChanges = documentTextChanges,
                        RenamedToken = renamedToken,
                    };
                }
            }, cancellationToken));
        }
        public Task FindImplementationsAsync(
            PinnedSolutionInfo solutionInfo,
            SerializableSymbolAndProjectId symbolAndProjectIdArg,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var project = solution.GetProject(symbolAndProjectIdArg.ProjectId);

                    var symbol = await symbolAndProjectIdArg.TryRehydrateAsync(
                        solution, cancellationToken).ConfigureAwait(false);
                    if (symbol == null)
                    {
                        return;
                    }

                    var context = new RemoteFindUsageContext(solution, EndPoint, cancellationToken);
                    await AbstractFindUsagesService.FindImplementationsAsync(
                        symbol, project, context).ConfigureAwait(false);
                }
            }, cancellationToken));
        }
Ejemplo n.º 10
0
        public async Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndProjectIdArg, DocumentId[] documentArgs)
        {
            using (UserOperationBooster.Boost())
            {
                var solution = await GetSolutionAsync().ConfigureAwait(false);

                var symbolAndProjectId = await symbolAndProjectIdArg.TryRehydrateAsync(
                    solution, CancellationToken).ConfigureAwait(false);

                var progressCallback = new FindReferencesProgressCallback(this);

                if (!symbolAndProjectId.HasValue)
                {
                    await progressCallback.OnStartedAsync().ConfigureAwait(false);

                    await progressCallback.OnCompletedAsync().ConfigureAwait(false);

                    return;
                }

                var documents = documentArgs?.Select(solution.GetDocument)
                                .ToImmutableHashSet();

                await SymbolFinder.FindReferencesInCurrentProcessAsync(
                    symbolAndProjectId.Value, solution,
                    progressCallback, documents, CancellationToken).ConfigureAwait(false);
            }
        }
Ejemplo n.º 11
0
        public Task <SerializableConflictResolution?> ResolveConflictsAsync(
            PinnedSolutionInfo solutionInfo,
            SerializableRenameLocations renameLocationSet,
            string replacementText,
            SerializableSymbolAndProjectId[] nonConflictSymbolIds,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync <SerializableConflictResolution?>(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var nonConflictSymbols = await GetNonConflictSymbolsAsync(solution, nonConflictSymbolIds, cancellationToken).ConfigureAwait(false);

                    var rehydratedSet = await RenameLocations.TryRehydrateAsync(solution, renameLocationSet, cancellationToken).ConfigureAwait(false);
                    if (rehydratedSet == null)
                    {
                        return null;
                    }

                    var result = await ConflictResolver.ResolveConflictsAsync(
                        rehydratedSet,
                        replacementText,
                        nonConflictSymbols,
                        cancellationToken).ConfigureAwait(false);
                    return await result.DehydrateAsync(cancellationToken).ConfigureAwait(false);
                }
            }, cancellationToken));
        }
        /// <summary>
        /// Calculate dignostics. this works differently than other ones such as todo comments or designer attribute scanner
        /// since in proc and out of proc runs quite differently due to concurrency and due to possible amount of data
        /// that needs to pass through between processes
        /// </summary>
        public Task CalculateDiagnosticsAsync(DiagnosticArguments arguments, string pipeName, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                // if this analysis is explicitly asked by user, boost priority of this request
                using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_CalculateDiagnosticsAsync, arguments.ProjectId.DebugName, cancellationToken))
                    using (arguments.ForcedAnalysis ? UserOperationBooster.Boost() : default)
                    {
                        // entry point for diagnostic service
                        var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                        var projectId = arguments.ProjectId;
                        var analyzers = RoslynServices.AssetService.GetGlobalAssetsOfType <AnalyzerReference>(cancellationToken);

                        var result = await new DiagnosticComputer(solution.GetProject(projectId)).GetDiagnosticsAsync(
                            analyzers, arguments.AnalyzerIds, arguments.ReportSuppressedDiagnostics, arguments.LogAnalyzerExecutionTime, cancellationToken).ConfigureAwait(false);

                        await RemoteEndPoint.WriteDataToNamedPipeAsync(pipeName, result, (writer, data, cancellationToken) =>
                        {
                            var(diagnostics, telemetry, exceptions) = DiagnosticResultSerializer.WriteDiagnosticAnalysisResults(writer, data, cancellationToken);

                            // save log for debugging
                            Log(TraceEventType.Information, $"diagnostics: {diagnostics}, telemetry: {telemetry}, exceptions: {exceptions}");

                            return Task.CompletedTask;
                        }, cancellationToken).ConfigureAwait(false);
                    }
            }, cancellationToken));
        }
        public async Task FindLiteralReferencesAsync(object value, TypeCode typeCode, CancellationToken cancellationToken)
        {
            using (UserOperationBooster.Boost())
            {
                var convertedType = System.Convert.ChangeType(value, typeCode);
                var solution      = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                var progressCallback = new FindLiteralReferencesProgressCallback(this);
                await SymbolFinder.FindLiteralReferencesInCurrentProcessAsync(
                    convertedType, solution, progressCallback, cancellationToken).ConfigureAwait(false);
            }
        }
Ejemplo n.º 14
0
 public Task <SymbolInformation[]?> WorkspaceSymbolAsync(WorkspaceSymbolParams args, CancellationToken cancellationToken)
 {
     return(RunServiceAsync(async() =>
     {
         using (UserOperationBooster.Boost())
         {
             // for now, we use whatever solution we have currently. in future, we will add an ability to sync VS's current solution
             // on demand from OOP side
             // https://github.com/dotnet/roslyn/issues/37424
             return await SearchAsync(GetWorkspace().CurrentSolution, args, cancellationToken).ConfigureAwait(false);
         }
     }, cancellationToken));
 }
        public async Task <IList <SerializableSymbolAndProjectId> > FindSolutionSourceDeclarationsWithNormalQueryAsync(
            string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken)
        {
            using (UserOperationBooster.Boost())
            {
                var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                var result = await DeclarationFinder.FindSourceDeclarationsWithNormalQueryInCurrentProcessAsync(
                    solution, name, ignoreCase, criteria, cancellationToken).ConfigureAwait(false);

                return(result.SelectAsArray(SerializableSymbolAndProjectId.Dehydrate));
            }
        }
Ejemplo n.º 16
0
 public Task <VSBeginSymbolParams> BeginWorkspaceSymbolAsync(string query, int searchId, CancellationToken cancellationToken)
 {
     return(RunServiceAsync(async() =>
     {
         using (UserOperationBooster.Boost())
         {
             // for now, we use whatever solution we have currently. in future, we will add an ability to sync VS's current solution
             // on demand from OOP side
             // https://github.com/dotnet/roslyn/issues/37424
             await SearchAsync(SolutionService.PrimaryWorkspace.CurrentSolution, query, searchId, cancellationToken).ConfigureAwait(false);
             return new VSBeginSymbolParams();
         }
     }, cancellationToken));
 }
Ejemplo n.º 17
0
        public async Task <ImmutableArray <SerializableNavigateToSearchResult> > SearchProjectAsync(
            ProjectId projectId, string searchPattern, CancellationToken cancellationToken)
        {
            using (UserOperationBooster.Boost())
            {
                var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                var project = solution.GetProject(projectId);
                var result  = await AbstractNavigateToSearchService.SearchProjectInCurrentProcessAsync(
                    project, searchPattern, cancellationToken).ConfigureAwait(false);

                return(Convert(result));
            }
        }
        public async Task <IList <SerializableSymbolAndProjectId> > FindProjectSourceDeclarationsWithPatternAsync(
            ProjectId projectId, string pattern, SymbolFilter criteria, CancellationToken cancellationToken)
        {
            using (UserOperationBooster.Boost())
            {
                var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                var project = solution.GetProject(projectId);

                var result = await DeclarationFinder.FindSourceDeclarationsWithPatternInCurrentProcessAsync(
                    project, pattern, criteria, cancellationToken).ConfigureAwait(false);

                return(result.SelectAsArray(SerializableSymbolAndProjectId.Dehydrate));
            }
        }
Ejemplo n.º 19
0
        public Task FindLiteralReferencesAsync(PinnedSolutionInfo solutionInfo, object value, TypeCode typeCode, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var convertedType = System.Convert.ChangeType(value, typeCode);
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var progressCallback = new FindLiteralReferencesProgressCallback(EndPoint, cancellationToken);
                    await SymbolFinder.FindLiteralReferencesInCurrentProcessAsync(
                        convertedType, solution, progressCallback, cancellationToken).ConfigureAwait(false);
                }
            }, cancellationToken));
        }
        public Task <IList <SerializableSymbolAndProjectId> > FindSolutionSourceDeclarationsWithPatternAsync(
            string pattern, SymbolFilter criteria, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async token =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(token).ConfigureAwait(false);

                    var result = await DeclarationFinder.FindSourceDeclarationsWithPatternInCurrentProcessAsync(
                        solution, pattern, criteria, token).ConfigureAwait(false);

                    return (IList <SerializableSymbolAndProjectId>)result.SelectAsArray(SerializableSymbolAndProjectId.Dehydrate);
                }
            }, cancellationToken));
        }
Ejemplo n.º 21
0
        public Task <ImmutableArray <SerializableSymbolAndProjectId> > FindSolutionSourceDeclarationsWithPatternAsync(
            PinnedSolutionInfo solutionInfo, string pattern, SymbolFilter criteria, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var result = await DeclarationFinder.FindSourceDeclarationsWithPatternInCurrentProcessAsync(
                        solution, pattern, criteria, cancellationToken).ConfigureAwait(false);

                    return Convert(result, solution, cancellationToken);
                }
            }, cancellationToken));
        }
        public Task <IList <SerializableSymbolAndProjectId> > FindProjectSourceDeclarationsWithNormalQueryAsync(
            ProjectId projectId, string name, bool ignoreCase, SymbolFilter criteria, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async token =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(token).ConfigureAwait(false);
                    var project = solution.GetProject(projectId);

                    var result = await DeclarationFinder.FindSourceDeclarationsWithNormalQueryInCurrentProcessAsync(
                        project, name, ignoreCase, criteria, token).ConfigureAwait(false);

                    return (IList <SerializableSymbolAndProjectId>)result.SelectAsArray(SerializableSymbolAndProjectId.Dehydrate);
                }
            }, cancellationToken));
        }
Ejemplo n.º 23
0
        public Task <IList <SerializableNavigateToSearchResult> > SearchDocumentAsync(
            DocumentId documentId, string searchPattern, string[] kinds, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                    var project = solution.GetDocument(documentId);
                    var result = await AbstractNavigateToSearchService.SearchDocumentInCurrentProcessAsync(
                        project, searchPattern, kinds.ToImmutableHashSet(), cancellationToken).ConfigureAwait(false);

                    return Convert(result);
                }
            }, cancellationToken));
        }
        public async Task <IList <SerializableSymbolAndProjectId> > FindAllDeclarationsWithNormalQueryAsync(
            ProjectId projectId, string name, SearchKind searchKind, SymbolFilter criteria, CancellationToken cancellationToken)
        {
            using (UserOperationBooster.Boost())
            {
                var solution = await GetSolutionAsync(cancellationToken).ConfigureAwait(false);

                var project = solution.GetProject(projectId);

                using (var query = SearchQuery.Create(name, searchKind))
                {
                    var result = await DeclarationFinder.FindAllDeclarationsWithNormalQueryInCurrentProcessAsync(
                        project, query, criteria, cancellationToken).ConfigureAwait(false);

                    return(result.SelectAsArray(SerializableSymbolAndProjectId.Dehydrate));
                }
            }
        }
Ejemplo n.º 25
0
        public Task <SerializableClassifiedSpans> GetSemanticClassificationsAsync(
            PinnedSolutionInfo solutionInfo, DocumentId documentId,
            TextSpan span, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var document = solution.GetDocument(documentId);

                    using var _ = ArrayBuilder <ClassifiedSpan> .GetInstance(out var temp);
                    await AbstractClassificationService.AddSemanticClassificationsInCurrentProcessAsync(
                        document, span, temp, cancellationToken).ConfigureAwait(false);

                    return SerializableClassifiedSpans.Dehydrate(temp.ToImmutable());
                }
            }, cancellationToken));
        }
        public Task <IList <SerializableNavigateToSearchResult> > SearchProjectAsync(
            PinnedSolutionInfo solutionInfo, ProjectId projectId, DocumentId[] priorityDocumentIds, string searchPattern, string[] kinds, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var project = solution.GetProject(projectId);
                    var priorityDocuments = priorityDocumentIds.Select(d => solution.GetDocument(d))
                                            .ToImmutableArray();

                    var result = await AbstractNavigateToSearchService.SearchProjectInCurrentProcessAsync(
                        project, priorityDocuments, searchPattern, kinds.ToImmutableHashSet(), cancellationToken).ConfigureAwait(false);

                    return Convert(result);
                }
            }, cancellationToken));
        }
Ejemplo n.º 27
0
        public async Task <ImmutableArray <AddImportFixData> > GetFixesAsync(
            DocumentId documentId, TextSpan span, string diagnosticId,
            bool searchReferenceAssemblies, ImmutableArray <PackageSource> packageSources)
        {
            using (UserOperationBooster.Boost())
            {
                var solution = await GetSolutionAsync().ConfigureAwait(false);

                var document = solution.GetDocument(documentId);

                var service = document.GetLanguageService <IAddImportFeatureService>();

                var symbolSearchService = new SymbolSearchService(this);

                var result = await service.GetFixesAsync(
                    document, span, diagnosticId, symbolSearchService, searchReferenceAssemblies,
                    packageSources, CancellationToken).ConfigureAwait(false);

                return(result);
            }
        }
Ejemplo n.º 28
0
        public Task <ImmutableArray <SerializableSymbolAndProjectId> > FindProjectSourceDeclarationsWithNormalQueryAsync(
            PinnedSolutionInfo solutionInfo,
            ProjectId projectId,
            string name,
            bool ignoreCase,
            SymbolFilter criteria,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var project = solution.GetProject(projectId);

                    var result = await DeclarationFinder.FindSourceDeclarationsWithNormalQueryInCurrentProcessAsync(
                        project, name, ignoreCase, criteria, cancellationToken).ConfigureAwait(false);

                    return Convert(result, solution, cancellationToken);
                }
            }, cancellationToken));
        }
Ejemplo n.º 29
0
        public Task <IList <AddImportFixData> > GetFixesAsync(
            DocumentId documentId, TextSpan span, string diagnosticId, bool placeSystemNamespaceFirst,
            bool searchReferenceAssemblies, IList <PackageSource> packageSources, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async token =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(token).ConfigureAwait(false);
                    var document = solution.GetDocument(documentId);

                    var service = document.GetLanguageService <IAddImportFeatureService>();

                    var symbolSearchService = new SymbolSearchService(this);

                    var result = await service.GetFixesAsync(
                        document, span, diagnosticId, placeSystemNamespaceFirst,
                        symbolSearchService, searchReferenceAssemblies,
                        packageSources.ToImmutableArray(), token).ConfigureAwait(false);

                    return (IList <AddImportFixData>)result;
                }
            }, cancellationToken));
        }
Ejemplo n.º 30
0
        public Task <(DocumentId, TextChange[])[]> EncapsulateFieldsAsync(
            PinnedSolutionInfo solutionInfo,
            DocumentId documentId,
            ImmutableArray <string> fieldSymbolKeys,
            bool updateReferences,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var document = solution.GetRequiredDocument(documentId);

                    using var _ = ArrayBuilder <IFieldSymbol> .GetInstance(out var fields);
                    var compilation = await document.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);

                    foreach (var key in fieldSymbolKeys)
                    {
                        var resolved = SymbolKey.ResolveString(key, compilation, cancellationToken: cancellationToken).GetAnySymbol() as IFieldSymbol;
                        if (resolved == null)
                        {
                            return Array.Empty <(DocumentId, TextChange[])>();
                        }