当前位置: 首页>>代码示例>>C#>>正文


C# IDocument.GetSyntaxRoot方法代码示例

本文整理汇总了C#中IDocument.GetSyntaxRoot方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.GetSyntaxRoot方法的具体用法?C# IDocument.GetSyntaxRoot怎么用?C# IDocument.GetSyntaxRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDocument的用法示例。


在下文中一共展示了IDocument.GetSyntaxRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMethodBlock

 private SyntaxNode GetMethodBlock(IDocument document, string name)
 {
     var methods = ASTUtil.GetMethodsDeclarations((SyntaxNode) document.GetSyntaxRoot());
     var method = (MethodDeclarationSyntax)methods.First(m => ((MethodDeclarationSyntax) m).
         Identifier.ValueText.Equals(name));
     return method.Body;
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:7,代码来源:BlockAnalyzerTests.cs

示例2: Annotate

 public static IDocument Annotate(IDocument document, TextSpan span, out IEnumerable<SyntaxAnnotation> annotations)
 {
     var oldRoot = (CompilationUnitSyntax)document.GetSyntaxRoot();
     var propertyAnnotater = new PropertyAnnotater(document, span);
     var newRoot = (CompilationUnitSyntax)propertyAnnotater.Visit(oldRoot);
     annotations = propertyAnnotater.annotations;
     return document.UpdateSyntaxRoot(newRoot);
 }
开发者ID:2j2e,项目名称:presentations,代码行数:8,代码来源:PropertyAnnotater.cs

示例3: TypeHierarchyAnalyzerTests

 public TypeHierarchyAnalyzerTests()
 {
     var source = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "/TypeHierarchyFakeSource.cs");
     var converter = new String2IDocumentConverter();
     document = (IDocument)converter.Convert(source, null, null, null);
     analyzer = AnalyzerFactory.GetTypeHierarchyAnalyzer();
     analyzer.SetSemanticModel(document.GetSemanticModel());
     root = (SyntaxNode) document.GetSyntaxRoot();
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:9,代码来源:TypeHierarchyAnalyzerTests.cs

示例4: MethodInvocationAnalyzerTests

 public MethodInvocationAnalyzerTests()
 {
     this.analyzer = AnalyzerFactory.GetMethodInvocationAnalyzer();
     var converter = new String2IDocumentConverter();
     this.document = (IDocument) converter.Convert(FileUtil.ReadAllText(
         TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureAfter.txt"), null, null, null);
     this.invocations = ((SyntaxNode)document.GetSyntaxRoot()).
         DescendantNodes().Where(i => i.Kind == SyntaxKind.InvocationExpression);
     this.logger = NLoggerUtil.GetNLogger(typeof(MethodInvocationAnalyzerTests));
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:10,代码来源:MethodInvocationAnalyzerTests.cs

示例5: TransformSyntaxRoot

        private static CommonSyntaxNode TransformSyntaxRoot(IDocument document)
        {
            var originalRoot = document.GetSyntaxRoot();
            switch (document.LanguageServices.Language)
            {
                case LanguageNames.CSharp:
                    return TransformRootCSharp((Roslyn.Compilers.CSharp.SyntaxNode)originalRoot);
                case LanguageNames.VisualBasic:
                    return TransformRootVisualBasic((Roslyn.Compilers.VisualBasic.SyntaxNode)originalRoot);
            }

            return originalRoot;
        }
开发者ID:piotrosz,项目名称:RoslynChart,代码行数:13,代码来源:Program.cs

示例6: IsDocumentRight

                /* Is the document where the inline methodAfter refactoring happened? */
                private bool IsDocumentRight(IDocument document)
                {
                    // Get the qualified name of the type that encloses the methodAfter.
                    var analyzer = AnalyzerFactory.GetQualifiedNameAnalyzer();
                    analyzer.SetSyntaxNode(methodAfter);
                    var containingMethodName = analyzer.GetOutsideTypeQualifiedName();

                    // Get the qualified names of types that are contained in the document.
                    analyzer.SetSyntaxNode((SyntaxNode)document.GetSyntaxRoot());
                    var documentContainedNames = analyzer.GetInsideQualifiedNames();

                    // If the type names in the document contains the name we want.
                    return documentContainedNames.Contains(containingMethodName);
                }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:15,代码来源:ChangedVariablesChecker.cs

示例7: ComputerAllCodeIssues

 private IEnumerable<CodeIssue> ComputerAllCodeIssues(ICodeIssueComputer computer, IDocument document)
 {
     var root = (SyntaxNode)document.GetSyntaxRoot();
     return root.DescendantNodes().SelectMany(n => computer.ComputeCodeIssues(document, n));
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:5,代码来源:InlineMethodRefactoringTests.cs

示例8: MapToAnotherDocument

 public SyntaxNode MapToAnotherDocument(IDocument target)
 {
     // Do not need to parse into the node that does not include the node.
     return (SyntaxNode)target.GetSyntaxRoot().DescendantNodes(n => n.Span.Contains(node.Span)).
         First(n => n.Span.Equals(node.Span));
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:6,代码来源:SyntaxNodeAnalyzer.cs

示例9: GetPossibleSyntaxNodes

 public override IEnumerable<SyntaxNode> GetPossibleSyntaxNodes(IDocument document)
 {
     return ((SyntaxNode) document.GetSyntaxRoot()).DescendantNodes().Where(n => n
         is StatementSyntax);
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:5,代码来源:ChangedVariablesChecker.cs

示例10: SetDocument

 public void SetDocument(IDocument document)
 {
     this.document = document;
     this.root = (SyntaxNode)document.GetSyntaxRoot();
 }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:5,代码来源:DocumentAnalyzer.cs

示例11: GetPossibleSyntaxNodes

 public override IEnumerable<SyntaxNode> GetPossibleSyntaxNodes(IDocument document)
 {
     return ((SyntaxNode) document.GetSyntaxRoot()).DescendantNodes(n => n.Kind != SyntaxKind.
         MethodDeclaration).OfType<MethodDeclarationSyntax>().Select(m => m.ReturnType);
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:5,代码来源:ReturnTypeChecker.cs

示例12: SetDocument

 public void SetDocument(IDocument document)
 {
     root = (SyntaxNode) document.GetSyntaxRoot();
     model = document.GetSemanticModel();
     this.document = document;
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:6,代码来源:MethodInvocationsRetriever.cs

示例13: updateMethodInvocations

                    /// <summary>
                    /// Update all the method invocations in the solution. 
                    /// </summary>
                    /// <param name="document"></param>
                    /// <returns></returns>
                    private IDocument updateMethodInvocations(IDocument document)
                    {
                        // Get the retriever for method invocations.
                        var retriever = RetrieverFactory.GetMethodInvocationRetriever();
                        retriever.SetMethodDeclaration(declaration);

                        // Get all the invocations in the document for the given method
                        // declaration.
                        retriever.SetDocument(document);
                        var invocations = retriever.GetInvocations();

                        // If there are invocations in the document.
                        if (invocations.Any())
                        {
                            // Update root
                            var root = (SyntaxNode) document.GetSyntaxRoot();
                            var updatedRoot = new InvocationsAddArgumentsRewriter(invocations,
                                typeNameTuple.Item2).Visit(root);

                            // Update solution by update the document.
                            document = document.UpdateSyntaxRoot(updatedRoot);
                        }
                        return document;
                    }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:29,代码来源:ParametersChecker.cs

示例14: updateMethodDeclaration

                    private IDocument updateMethodDeclaration(IDocument document)
                    {
                        // Get the simplified name of the method
                        var methodName = ((MethodDeclarationSyntax) declaration).Identifier.ValueText;
                        var documentAnalyzer = AnalyzerFactory.GetDocumentAnalyzer();
                        documentAnalyzer.SetDocument(document);

                        // Get the root of the current document.
                        var root = ((SyntaxNode) document.GetSyntaxRoot());

                        // Find the method
                        SyntaxNode method = root.DescendantNodes().Where(
                            // Find all the method declarations.
                            n => n.Kind == SyntaxKind.MethodDeclaration).
                            // Convert all of them to the RefactoringType MethodDeclarationSyntax.
                            Select(n => (MethodDeclarationSyntax) n).
                            // Get the one whose name is same with the given method declaration.
                            First(m => m.Identifier.ValueText.Equals(methodName));

                        // If we can find this method.
                        if (method != null)
                        {
                            // Get the updated method declaration.
                            var methodAnalyzer = AnalyzerFactory.GetMethodDeclarationAnalyzer();
                            methodAnalyzer.SetMethodDeclaration(method);
                            var updatedMethod = methodAnalyzer.AddParameters(new[] {typeNameTuple});

                            // Update the root, document and finally return the code action.
                            var updatedRoot = new MethodDeclarationRewriter(method, updatedMethod).
                                Visit(root);
                            return document.UpdateSyntaxRoot(updatedRoot);
                        }
                        return document;
                    }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:34,代码来源:ParametersChecker.cs

示例15: SetDocument

 public void SetDocument(IDocument document)
 {
     model = document.GetSemanticModel();
     root = (SyntaxNode) document.GetSyntaxRoot();
 }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:5,代码来源:TypablesRetriever.cs


注:本文中的IDocument.GetSyntaxRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。