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


C# InvocationExpressionSyntax.DescendantNodes方法代码示例

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


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

示例1: CheckForCondition

 private static void CheckForCondition(SyntaxNodeAnalysisContext context, InvocationExpressionSyntax invocationNode, 
   SyntaxNode expressionStatementParent, DiagnosticDescriptor descriptor)
 {
   if ((!expressionStatementParent?.DescendantNodesAndTokens()?.Any(_ => _.IsKind(SyntaxKind.EqualsToken)) ?? false) &&
     !(invocationNode.DescendantNodes()?.Any(_ => new ContainsInvocationExpressionWalker(_).HasIssue) ?? false))
   {
     context.ReportDiagnostic(Diagnostic.Create(descriptor, invocationNode.GetLocation()));
   }
 }
开发者ID:StrickDev,项目名称:csla,代码行数:9,代码来源:FindSaveAssignmentIssueAnalyzer.cs

示例2: CheckForCondition

 private static void CheckForCondition(SyntaxNodeAnalysisContext context, InvocationExpressionSyntax invocationNode, 
   SyntaxNode expressionStatementParent, DiagnosticDescriptor descriptor)
 {
   // Make sure the invocation's containing type is not the same as the class that contains it
   if ((invocationNode.DescendantNodesAndTokens().Any(_ => _.IsKind(SyntaxKind.DotToken)) &&
     !invocationNode.DescendantNodesAndTokens().Any(_ => _.IsKind(SyntaxKind.ThisExpression) || _.IsKind(SyntaxKind.BaseExpression))) &&
     (!expressionStatementParent?.DescendantNodesAndTokens()?.Any(_ => _.IsKind(SyntaxKind.EqualsToken)) ?? false) &&
     !(invocationNode.DescendantNodes()?.Any(_ => new ContainsInvocationExpressionWalker(_).HasIssue) ?? false) &&
     !FindSaveAssignmentIssueAnalyzer.IsReturnValue(invocationNode))
   {
     context.ReportDiagnostic(Diagnostic.Create(descriptor, invocationNode.GetLocation()));
   }
 }
开发者ID:RodrigoGT,项目名称:csla,代码行数:13,代码来源:FindSaveAssignmentIssueAnalyzer.cs

示例3: ValidateInvocation

        static bool ValidateInvocation(InvocationExpressionSyntax expr)
        {
            // Okay => x = M(), var x = M(), return M(), from x in M(), (bool) ? M() : M()
            if (expr.Parent.IsKind(SyntaxKind.SimpleAssignmentExpression)) return true;
            if (expr.Parent.IsKind(SyntaxKind.EqualsValueClause) && expr.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator)) return true;
            if (expr.Parent.IsKind(SyntaxKind.ReturnStatement)) return true;
            if (expr.Parent.IsKind(SyntaxKind.FromClause)) return true;
            if (expr.Parent.IsKind(SyntaxKind.ConditionalExpression)) return true;

            // Okay => M().M()
            if (expr.DescendantNodes().OfType<InvocationExpressionSyntax>().Any()) return true;

            return false;
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:14,代码来源:HandleObservableAnalyzer.cs

示例4: ValidateInvocation

        static bool ValidateInvocation(InvocationExpressionSyntax expr)
        {
            bool allAncestorsIsParenthes = true;
            foreach (var x in expr.Ancestors())
            {
                // scope is in lambda, method
                if (x.IsKind(SyntaxKind.SimpleLambdaExpression) || x.IsKind(SyntaxKind.ParenthesizedLambdaExpression) || x.IsKind(SyntaxKind.ArrowExpressionClause))
                {
                    // () => M()
                    if (allAncestorsIsParenthes) return true;
                    break;
                }
                if (x.IsKind(SyntaxKind.MethodDeclaration)) break;
                if (x.IsKind(SyntaxKind.PropertyDeclaration)) break;
                if (x.IsKind(SyntaxKind.ConstructorDeclaration)) break;

                // x = M()
                if (x.IsKind(SyntaxKind.SimpleAssignmentExpression)) return true;
                // var x = M()
                if (x.IsKind(SyntaxKind.VariableDeclarator)) return true;
                // return M()
                if (x.IsKind(SyntaxKind.ReturnStatement)) return true;
                // from x in M()
                if (x.IsKind(SyntaxKind.FromClause)) return true;
                // (bool) ? M() : M()
                if (x.IsKind(SyntaxKind.ConditionalExpression)) return true;
                // M(M())
                if (x.IsKind(SyntaxKind.InvocationExpression)) return true;
                // new C(M())
                if (x.IsKind(SyntaxKind.ObjectCreationExpression)) return true;

                // (((((M()))))
                if (!x.IsKind(SyntaxKind.ParenthesizedExpression))
                {
                    allAncestorsIsParenthes = false;
                }
            }

            // Okay => M().M()
            if (expr.DescendantNodes().OfType<InvocationExpressionSyntax>().Any()) return true;

            return false;
        }
开发者ID:ChicK00o,项目名称:UniRx,代码行数:43,代码来源:HandleObservableAnalyzer.cs

示例5: GetMethodName

        private SyntaxNode GetMethodName(InvocationExpressionSyntax invocation)
        {
            // The left parentheses is the rightmost position for the method name.
            int rightMost = invocation.ArgumentList.OpenParenToken.Span.Start;

            // Order the decendents by its span
            var orderedDecendents = invocation.DescendantNodes().OrderBy(n => n.Span.Length);

            // The decendent whose length is the most and end is before ( should be method name node.
            return orderedDecendents.Last(n => n.Span.End <= rightMost);
        }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:11,代码来源:MethodInvocationAnalyzer.cs


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