コード例 #1
0
        public async Task <IEnumerable <ReferenceMethodDescriptor> > FindReferenceMethodsAsync(CodeLensArguments arguments)
        {
            try
            {
                var documentId = arguments.GetDocumentId();
                var textSpan   = arguments.GetTextSpan();

                using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_FindReferenceMethodsAsync, documentId.ProjectId.DebugName, CancellationToken))
                {
                    var solution = await GetSolutionAsync().ConfigureAwait(false);

                    var syntaxNode = (await solution.GetDocument(documentId).GetSyntaxRootAsync().ConfigureAwait(false)).FindNode(textSpan);

                    return(await CodeLensReferencesServiceFactory.Instance.FindReferenceMethodsAsync(solution, documentId,
                                                                                                     syntaxNode, CancellationToken).ConfigureAwait(false));
                }
            }
            catch (IOException)
            {
                // stream to send over result has closed before we
                // had chance to check cancellation
            }
            catch (OperationCanceledException)
            {
                // rpc connection has closed.
                // this can happen if client side cancelled the
                // operation
            }

            return(null);
        }
コード例 #2
0
        public async Task <string> GetFullyQualifiedName(CodeLensArguments arguments, byte[] solutionChecksum)
        {
            try
            {
                var documentId = arguments.GetDocumentId();
                var textSpan   = arguments.GetTextSpan();

                using (Internal.Log.Logger.LogBlock(FunctionId.CodeAnalysisService_GetFullyQualifiedName, documentId.ProjectId.DebugName, CancellationToken))
                {
                    var solution = await RoslynServices.SolutionService.GetSolutionAsync(new Checksum(solutionChecksum), CancellationToken).ConfigureAwait(false);

                    var syntaxNode = (await solution.GetDocument(documentId).GetSyntaxRootAsync().ConfigureAwait(false)).FindNode(textSpan);

                    return(await CodeLensReferencesServiceFactory.Instance.GetFullyQualifiedName(solution, documentId,
                                                                                                 syntaxNode, CancellationToken).ConfigureAwait(false));
                }
            }
            catch (IOException)
            {
                // stream to send over result has closed before we
                // had chance to check cancellation
            }
            catch (OperationCanceledException)
            {
                // rpc connection has closed.
                // this can happen if client side cancelled the
                // operation
            }

            return(null);
        }