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


C# IDocument.UpdateSyntaxRoot方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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


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