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


C# SyntaxNode.DescendantNodesAndSelf方法代码示例

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


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

示例1: ProcessNode

        private List<Diagnostic> ProcessNode(Document document, SemanticModel model, SyntaxNode node, List<Diagnostic> result, CancellationToken cancellationToken)
        {
            Diagnostic diagnostic;
            Func<SyntaxNode, bool> descendIntoChildren = n =>
            {
                if (!IsRegularCandidate(n) ||
                    !TrySimplifyTypeNameExpression(document, model, n, out diagnostic, cancellationToken))
                {
                    return true;
                }

                result = result ?? new List<Diagnostic>();
                result.Add(diagnostic);
                return false;
            };

            // find regular node first - search from top to down. once found one, don't get into its children
            foreach (var candidate in node.DescendantNodesAndSelf(descendIntoChildren))
            {
                cancellationToken.ThrowIfCancellationRequested();
            }

            // now search structure trivia
            foreach (var candidate in node.DescendantNodesAndSelf(descendIntoChildren: n => !IsCrefCandidate(n), descendIntoTrivia: true))
            {
                cancellationToken.ThrowIfCancellationRequested();

                if (IsCrefCandidate(candidate) &&
                    TrySimplifyTypeNameExpression(document, model, candidate, out diagnostic, cancellationToken))
                {
                    result = result ?? new List<Diagnostic>();
                    result.Add(diagnostic);
                }
            }

            return result;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:37,代码来源:SimplifyTypeNamesDiagnosticProvider.cs

示例2: GetAllStatements

 private static IEnumerable<StatementSyntax> GetAllStatements(SyntaxNode node)
 {
     return node.DescendantNodesAndSelf().OfType<StatementSyntax>();
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:GetSemanticInfoBrokenCodeTests.cs

示例3: GetAllExpressions

 private static IEnumerable<ExpressionSyntax> GetAllExpressions(SyntaxNode node)
 {
     return node.DescendantNodesAndSelf(descendIntoTrivia: true).OfType<ExpressionSyntax>();
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:GetSemanticInfoBrokenCodeTests.cs

示例4: GetAwaitExpressions

 public static ImmutableArray<SyntaxNode> GetAwaitExpressions(SyntaxNode body)
 {
     // skip lambda bodies:
     return ImmutableArray.CreateRange(body.DescendantNodesAndSelf(LambdaUtilities.IsNotLambda).Where(n => n.IsKind(SyntaxKind.AwaitExpression)));
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:5,代码来源:SyntaxUtilities.cs


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