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));
        }
        public Task <(IList <SerializableImportCompletionItem>, StatisticCounter)> GetUnimportedExtensionMethodsAsync(
            PinnedSolutionInfo solutionInfo,
            DocumentId documentId,
            int position,
            string receiverTypeSymbolKeyData,
            string[] namespaceInScope,
            bool forceIndexCreation,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, 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));
        }
Example #3
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));
        }
        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));
        }
Example #5
0
        public ValueTask <SerializableClassifiedSpans> GetSemanticClassificationsAsync(
            PinnedSolutionInfo solutionInfo,
            DocumentId documentId,
            TextSpan span,
            ClassificationOptions options,
            StorageDatabase database,
            bool isFullyLoaded,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async cancellationToken =>
            {
                var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                var document = solution.GetDocument(documentId) ?? await solution.GetSourceGeneratedDocumentAsync(documentId, cancellationToken).ConfigureAwait(false);
                Contract.ThrowIfNull(document);

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

                if (isFullyLoaded)
                {
                    // Once fully loaded, there's no need for us to keep around any of the data we cached in-memory
                    // during the time the solution was loading.
                    lock (_cachedData)
                        _cachedData.Clear();

                    // Enqueue this document into our work queue to fully classify and cache.
                    _workQueue.AddWork((document, options, database));
                }

                return SerializableClassifiedSpans.Dehydrate(temp.ToImmutable());
            }, cancellationToken));
        }
Example #6
0
        public Task <ReferenceCount> GetReferenceCountAsync(PinnedSolutionInfo solutionInfo, DocumentId documentId, TextSpan textSpan, int maxResultCount, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_GetReferenceCountAsync, documentId.ProjectId.DebugName, cancellationToken))
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                    var document = solution.GetDocument(documentId);
                    if (document == null)
                    {
                        return null;
                    }

                    var syntaxNode = (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false)).FindNode(textSpan);

                    return await CodeLensReferencesServiceFactory.Instance.GetReferenceCountAsync(
                        solution,
                        documentId,
                        syntaxNode,
                        maxResultCount,
                        cancellationToken).ConfigureAwait(false);
                }
            }, 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 <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));
        }
        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 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));
        }
        /// <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() =>
            {
                // 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)
                    {
                        var solutionService = CreateSolutionService(solutionInfo);
                        var solution = await solutionService.GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                        var projectId = arguments.ProjectId;

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

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

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

                            return Task.CompletedTask;
                        }, cancellationToken).ConfigureAwait(false);
                    }
            }, cancellationToken));
        }
Example #12
0
        protected Task <Solution> GetSolutionAsync(PinnedSolutionInfo solutionInfo, CancellationToken cancellationToken)
        {
            var workspace     = GetWorkspace();
            var assetProvider = workspace.CreateAssetProvider(solutionInfo, WorkspaceManager.SolutionAssetCache, WorkspaceManager.GetAssetSource());

            return(workspace.GetSolutionAsync(assetProvider, solutionInfo.SolutionChecksum, solutionInfo.FromPrimaryBranch, solutionInfo.WorkspaceVersion, cancellationToken));
        }
        public ValueTask <Solution> GetSolutionAsync(ServiceBrokerClient client, PinnedSolutionInfo solutionInfo, CancellationToken cancellationToken)
        {
            var assetSource   = new SolutionAssetSource(client);
            var workspace     = GetWorkspace();
            var assetProvider = workspace.CreateAssetProvider(solutionInfo, SolutionAssetCache, assetSource);

            return(workspace.GetSolutionAsync(assetProvider, solutionInfo.SolutionChecksum, solutionInfo.FromPrimaryBranch, solutionInfo.WorkspaceVersion, solutionInfo.ProjectId, cancellationToken));
        }
Example #14
0
 private PinnedRemotableDataScope(
     AssetStorages storages,
     AssetStorages.Storage storage,
     PinnedSolutionInfo solutionInfo)
 {
     _storages    = storages;
     _storage     = storage;
     SolutionInfo = solutionInfo;
 }
Example #15
0
        public ValueTask <ImmutableArray <ReferenceInfo> > GetUnusedReferencesAsync(PinnedSolutionInfo solutionInfo, string projectFilePath, string projectAssetsFilePath, ImmutableArray <ReferenceInfo> projectReferences, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async cancellationToken =>
            {
                var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                var references = await ProjectAssetsFileReader.ReadReferencesAsync(projectReferences, projectAssetsFilePath).ConfigureAwait(false);

                return await UnusedReferencesRemover.GetUnusedReferencesAsync(solution, projectFilePath, references, cancellationToken).ConfigureAwait(false);
            }, cancellationToken));
        }
 public Task SynchronizePrimaryWorkspaceAsync(PinnedSolutionInfo solutionInfo, Checksum checksum, int workspaceVersion, CancellationToken cancellationToken)
 {
     return(RunServiceAsync(async() =>
     {
         using (RoslynLogger.LogBlock(FunctionId.RemoteHostService_SynchronizePrimaryWorkspaceAsync, Checksum.GetChecksumLogInfo, checksum, cancellationToken))
         {
             var solutionService = CreateSolutionService(solutionInfo);
             await solutionService.UpdatePrimaryWorkspaceAsync(checksum, workspaceVersion, cancellationToken).ConfigureAwait(false);
         }
     }, cancellationToken));
 }
 public Task <ImmutableArray <SerializableSymbolAndProjectId> > FindAndCacheImplementingTypesAsync(
     PinnedSolutionInfo solutionInfo,
     SerializableSymbolAndProjectId typeAndProjectId,
     ProjectId[] projectIds,
     bool transitive,
     CancellationToken cancellationToken)
 {
     return(FindAndCacheTypesAsync(
                solutionInfo, typeAndProjectId, projectIds,
                (nt, s, ps) => DependentTypeFinder.FindAndCacheImplementingTypesAsync(nt, s, ps, transitive, cancellationToken),
                cancellationToken));
 }
        public ValueTask <ImmutableArray <ReferenceInfo> > GetUnusedReferencesAsync(PinnedSolutionInfo solutionInfo, string projectFilePath, string projectAssetsFilePath, ImmutableArray <ReferenceInfo> projectReferences, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(solutionInfo, async solution =>
            {
                // Read specified references with dependency information from the project assets file.
                var references = await ProjectAssetsFileReader.ReadReferencesAsync(projectReferences, projectAssetsFilePath).ConfigureAwait(false);

                // Determine unused references
                var unusedReferences = await UnusedReferencesRemover.GetUnusedReferencesAsync(solution, projectFilePath, references, cancellationToken).ConfigureAwait(false);

                // Remove dependency information before returning.
                return unusedReferences.SelectAsArray(reference => reference.WithDependencies(null));
            }, cancellationToken));
        }
Example #19
0
        public override void Initialize(PinnedSolutionInfo solutionInfo)
        {
            base.Initialize(solutionInfo);

            lock (_gate)
            {
                if (CancellationToken.IsCancellationRequested)
                {
                    return;
                }

                _source = new JsonRpcAssetSource(this, solutionInfo.ScopeId);
            }
        }
Example #20
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));
        }
Example #21
0
        public AssetProvider CreateAssetProvider(
            PinnedSolutionInfo solutionInfo,
            SolutionAssetCache assetCache,
            IAssetSource assetSource
            )
        {
            var serializerService = Services.GetRequiredService <ISerializerService>();

            return(new AssetProvider(
                       solutionInfo.ScopeId,
                       assetCache,
                       assetSource,
                       serializerService
                       ));
        }
        /// <summary>
        /// Adds given snapshot into the storage. This snapshot will be available within the returned <see cref="Scope"/>.
        /// </summary>
        internal async ValueTask <Scope> StoreAssetsAsync(Solution solution, CancellationToken cancellationToken)
        {
            var solutionState    = solution.State;
            var solutionChecksum = await solutionState.GetChecksumAsync(cancellationToken).ConfigureAwait(false);

            var id           = Interlocked.Increment(ref s_scopeId);
            var solutionInfo = new PinnedSolutionInfo(
                id,
                fromPrimaryBranch: solutionState.BranchId == solutionState.Workspace.PrimaryBranchId,
                solutionState.WorkspaceVersion,
                solutionChecksum);

            Contract.ThrowIfFalse(_solutionStates.TryAdd(id, solutionState));

            return(new Scope(this, solutionInfo));
        }
Example #23
0
        public Task <IList <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 (IList <SerializableSymbolAndProjectId>)result.SelectAsArray(SerializableSymbolAndProjectId.Dehydrate);
                }
            }, cancellationToken));
        }
Example #24
0
        public Task SynchronizeGlobalAssetsAsync(PinnedSolutionInfo solutionInfo, Checksum[] checksums, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (RoslynLogger.LogBlock(FunctionId.RemoteHostService_SynchronizeGlobalAssetsAsync, Checksum.GetChecksumsLogInfo, checksums, cancellationToken))
                {
                    var assetProvider = SolutionService.CreateAssetProvider(solutionInfo, AssetStorage);
                    var assets = await assetProvider.GetAssetsAsync <object>(checksums, cancellationToken).ConfigureAwait(false);

                    foreach (var(checksum, value) in assets)
                    {
                        AssetStorage.TryAddGlobalAsset(checksum, value);
                    }
                }
            }, cancellationToken));
        }
        public Task <IList <SerializableNavigateToSearchResult> > SearchDocumentAsync(
            PinnedSolutionInfo solutionInfo, DocumentId documentId, string searchPattern, string[] kinds, CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

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

                    return Convert(result);
                }
            }, cancellationToken));
        }
Example #26
0
        public static PinnedRemotableDataScope Create(
            AssetStorages storages,
            AssetStorages.Storage storage,
            Checksum solutionChecksum)
        {
            Contract.ThrowIfNull(solutionChecksum);

            var solutionInfo = new PinnedSolutionInfo(
                Interlocked.Increment(ref s_scopeId),
                storage.SolutionState.BranchId == storage.SolutionState.Workspace.PrimaryBranchId,
                storage.SolutionState.WorkspaceVersion,
                solutionChecksum);

            storages.RegisterSnapshot(solutionInfo.ScopeId, storage);

            return(new PinnedRemotableDataScope(storages, storage, solutionInfo));
        }
Example #27
0
        public Task <ImmutableArray <SerializableSymbolAndProjectId> > FindProjectSourceDeclarationsWithPatternAsync(
            PinnedSolutionInfo solutionInfo, ProjectId projectId, string pattern, 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.FindSourceDeclarationsWithPatternInCurrentProcessAsync(
                        project, pattern, criteria, cancellationToken).ConfigureAwait(false);

                    return Convert(result, solution, cancellationToken);
                }
            }, cancellationToken));
        }
        /// <summary>
        /// This is top level entry point for TodoComments service from client (VS).
        ///
        /// This will be called by ServiceHub/JsonRpc framework
        /// </summary>
        public async Task <IList <TodoComment> > GetTodoCommentsAsync(PinnedSolutionInfo solutionInfo, DocumentId documentId, ImmutableArray <TodoCommentDescriptor> tokens, CancellationToken cancellationToken)
        {
            using (RoslynLogger.LogBlock(FunctionId.CodeAnalysisService_GetTodoCommentsAsync, documentId.ProjectId.DebugName, cancellationToken))
            {
                var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

                var document = solution.GetDocument(documentId);

                var service = document.GetLanguageService <ITodoCommentService>();
                if (service != null)
                {
                    // todo comment service supported
                    return(await service.GetTodoCommentsAsync(document, tokens, cancellationToken).ConfigureAwait(false));
                }

                return(SpecializedCollections.EmptyList <TodoComment>());
            }
        }
Example #29
0
        public Task <ImmutableArray <SerializableSymbolAndProjectId> > FindSolutionSourceDeclarationsWithNormalQueryAsync(
            PinnedSolutionInfo solutionInfo,
            string name,
            bool ignoreCase,
            SymbolFilter criteria,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);
                    var result = await DeclarationFinder.FindSourceDeclarationsWithNormalQueryInCurrentProcessAsync(
                        solution, name, ignoreCase, criteria, cancellationToken).ConfigureAwait(false);

                    return Convert(result, solution, cancellationToken);
                }
            }, cancellationToken));
        }
Example #30
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));
        }