コード例 #1
0
        public async Task <FileResponse> VisitAsync(Document document)
        {
            this.DocumentInfo = CodeGraphHelper.CreateFileResponse(document);
            this.DocumentInfo.declarationAnnotation = new List <DeclarationAnnotation>();
            this.DocumentInfo.referenceAnnotation   = new List <ReferenceAnnotation>();
            this.model = await document.GetSemanticModelAsync();

            var root = await document.GetSyntaxRootAsync();

            this.Visit(root);

            return(this.DocumentInfo);
        }
コード例 #2
0
        public static async Task <IEnumerable <FileResponse> > GetDocumentEntitiesAsync(IProjectCodeProvider projectProvider, OrleansClient.Analysis.DocumentInfo documentInfo)
        {
            var result = CodeGraphHelper.CreateFileResponse(documentInfo.Document);

            result.declarationAnnotation = new List <DeclarationAnnotation>();
            result.referenceAnnotation   = new List <ReferenceAnnotation>();

            foreach (var entry in documentInfo.DeclaredMethods)
            {
                var methodDescriptor = entry.Key;
                var methodInfo       = entry.Value;
                var methodEntity     = await projectProvider.GetMethodEntityAsync(methodDescriptor);

                var annotations = await methodEntity.GetAnnotationsAsync();

                // Add method declaration
                var methodDeclaration = GetMethodDeclarationInfo(methodInfo.DeclarationSyntaxNode, methodInfo.MethodSymbol);
                result.declarationAnnotation.Add(methodDeclaration);

                //var span = GetSpan(methodInfo.DeclarationSyntaxNode);
                //var baseRange = GetRange(span);
                // Annotations are relative to method declaration. Here we make it absolute
                var baseRange = methodDeclaration.range;
                foreach (var anotation in annotations)
                {
                    anotation.range = GetAbsoluteRange(anotation.range, baseRange);
                }

                var declarations = annotations.OfType <DeclarationAnnotation>();

                var references = annotations.OfType <ReferenceAnnotation>();



                result.declarationAnnotation.AddRange(declarations);
                result.referenceAnnotation.AddRange(references);
            }

            return(new List <FileResponse>()
            {
                result
            });
        }