コード例 #1
0
            public async Task OnReferenceFoundAsync(
                SerializableSymbolAndProjectId definition, SerializableReferenceLocation reference)
            {
                var symbolAndProjectId = await definition.RehydrateAsync(
                    _solution, _cancellationToken).ConfigureAwait(false);
                var referenceLocation = await reference.RehydrateAsync(
                    _solution, _cancellationToken).ConfigureAwait(false);

                await _progress.OnReferenceFoundAsync(symbolAndProjectId, referenceLocation).ConfigureAwait(false);
            }
コード例 #2
0
            public async Task OnDefinitionFoundAsync(SerializableSymbolAndProjectId definition)
            {
                var symbolAndProjectId = await definition.RehydrateAsync(
                    _solution, _cancellationToken).ConfigureAwait(false);

                lock (_gate)
                {
                    _definitionMap[definition] = symbolAndProjectId;
                }

                await _progress.OnDefinitionFoundAsync(symbolAndProjectId).ConfigureAwait(false);
            }
コード例 #3
0
        public async Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndProjectIdArg, DocumentId[] documentArgs)
        {
            var solution = await GetSolutionAsync().ConfigureAwait(false);

            var symbolAndProjectId = await symbolAndProjectIdArg.RehydrateAsync(
                solution, CancellationToken).ConfigureAwait(false);
            var documents = documentArgs?.Select(solution.GetDocument)
                                         .ToImmutableHashSet();

            var progressCallback = new ProgressCallback(this);
            await SymbolFinder.FindReferencesInCurrentProcessAsync(
                symbolAndProjectId, solution, progressCallback, documents, CancellationToken).ConfigureAwait(false);
        }
コード例 #4
0
ファイル: RemoteArguments.cs プロジェクト: wenming2014/roslyn
 public static SerializableReferenceLocation Dehydrate(
     ReferenceLocation referenceLocation)
 {
     return(new SerializableReferenceLocation
     {
         Document = referenceLocation.Document.Id,
         Alias = SerializableSymbolAndProjectId.Dehydrate(referenceLocation.Alias, referenceLocation.Document),
         Location = referenceLocation.Location.SourceSpan,
         IsImplicit = referenceLocation.IsImplicit,
         SymbolUsageInfo = SerializableSymbolUsageInfo.Dehydrate(referenceLocation.SymbolUsageInfo),
         AdditionalProperties = referenceLocation.AdditionalProperties,
         CandidateReason = referenceLocation.CandidateReason
     });
 }
コード例 #5
0
ファイル: RemoteArguments.cs プロジェクト: zouql/roslyn
        public static bool TryCreate(
            ISymbol symbol, Solution solution, CancellationToken cancellationToken,
            out SerializableSymbolAndProjectId result)
        {
            var project = solution.GetOriginatingProject(symbol);

            if (project == null)
            {
                result = null;
                return(false);
            }

            return(TryCreate(symbol, project, cancellationToken, out result));
        }
コード例 #6
0
        public async Task FindReferencesAsync(SerializableSymbolAndProjectId symbolAndProjectIdArg, DocumentId[] documentArgs)
        {
            var solution = await GetSolutionAsync().ConfigureAwait(false);

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

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

            var progressCallback = new ProgressCallback(this);
            await SymbolFinder.FindReferencesInCurrentProcessAsync(
                symbolAndProjectId, solution, progressCallback, documents, CancellationToken).ConfigureAwait(false);
        }
コード例 #7
0
        public async Task FindReferencesAsync(
            SerializableSymbolAndProjectId symbolAndProjectIdArg, SerializableDocumentId[] documentArgs, 
            byte[] solutionChecksum)
        {
            var solution = await RoslynServices.SolutionService.GetSolutionAsync(
                new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);

            var symbolAndProjectId = await symbolAndProjectIdArg.RehydrateAsync(
                solution, CancellationToken).ConfigureAwait(false);
            var documents = documentArgs?.Select(a => a.Rehydrate())
                                         .Select(solution.GetDocument)
                                         .ToImmutableHashSet();

            var progressCallback = new ProgressCallback(this);
            await SymbolFinder.FindReferencesInCurrentProcessAsync(
                symbolAndProjectId, solution, progressCallback, documents, CancellationToken).ConfigureAwait(false);
        }
コード例 #8
0
        public static bool TryCreate(
            ISymbol symbol, Project project, CancellationToken cancellationToken,
            out SerializableSymbolAndProjectId result)
        {
            if (!SymbolKey.CanCreate(symbol, cancellationToken))
            {
                result = null;
                return(false);
            }

            result = new SerializableSymbolAndProjectId
            {
                SymbolKeyData = SymbolKey.CreateString(symbol, cancellationToken),
                ProjectId     = project.Id,
            };
            return(true);
        }
コード例 #9
0
        public async Task FindReferencesAsync(
            SerializableSymbolAndProjectId symbolAndProjectIdArg, SerializableDocumentId[] documentArgs,
            byte[] solutionChecksum)
        {
            var solution = await RoslynServices.SolutionService.GetSolutionAsync(
                new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);

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

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

            var progressCallback = new ProgressCallback(this);
            await SymbolFinder.FindReferencesInCurrentProcessAsync(
                symbolAndProjectId, solution, progressCallback, documents, CancellationToken).ConfigureAwait(false);
        }
コード例 #10
0
        public Task FindReferencesAsync(
            PinnedSolutionInfo solutionInfo,
            SerializableSymbolAndProjectId symbolAndProjectIdArg,
            DocumentId[] documentArgs,
            SerializableFindReferencesSearchOptions options,
            CancellationToken cancellationToken)
        {
            return(RunServiceAsync(async() =>
            {
                using (UserOperationBooster.Boost())
                {
                    var solution = await GetSolutionAsync(solutionInfo, cancellationToken).ConfigureAwait(false);

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

                    var progressCallback = new FindReferencesProgressCallback(EndPoint, cancellationToken);

                    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, options.Rehydrate(), cancellationToken).ConfigureAwait(false);
                }
            }, cancellationToken));
        }
コード例 #11
0
 public Task OnDefinitionFoundAsync(SymbolAndProjectId definition)
 => _service.Rpc.InvokeAsync(nameof(OnDefinitionFoundAsync),
                             SerializableSymbolAndProjectId.Dehydrate(definition));
コード例 #12
0
 public Task OnDefinitionFoundAsync(SymbolAndProjectId definition)
 => _service.InvokeAsync(nameof(OnDefinitionFoundAsync), new object[] { SerializableSymbolAndProjectId.Dehydrate(definition) }, _cancellationToken);
コード例 #13
0
 public Task OnDefinitionFoundAsync(SymbolAndProjectId definition)
 => _endPoint.InvokeAsync(nameof(SymbolFinder.FindReferencesServerCallback.OnDefinitionFoundAsync), new object[] { SerializableSymbolAndProjectId.Dehydrate(definition) }, _cancellationToken);
コード例 #14
0
        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));
        }