本文整理汇总了C#中StatementSyntax.?.DescendantNodesAndSelf方法的典型用法代码示例。如果您正苦于以下问题:C# StatementSyntax.?.DescendantNodesAndSelf方法的具体用法?C# StatementSyntax.?.DescendantNodesAndSelf怎么用?C# StatementSyntax.?.DescendantNodesAndSelf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementSyntax
的用法示例。
在下文中一共展示了StatementSyntax.?.DescendantNodesAndSelf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeStatement
/// <summary>
/// Analyzes the data-flow information in the statement.
/// </summary>
/// <param name="statement">StatementSyntax</param>
/// <param name="node">IDataFlowNode</param>
private void AnalyzeStatement(StatementSyntax statement, IDataFlowNode node)
{
var localDecl = statement?.DescendantNodesAndSelf().
OfType<LocalDeclarationStatementSyntax>().FirstOrDefault();
var expr = statement?.DescendantNodesAndSelf().
OfType<ExpressionStatementSyntax>().FirstOrDefault();
var ret = statement?.DescendantNodesAndSelf().
OfType<ReturnStatementSyntax>().FirstOrDefault();
if (localDecl != null)
{
var varDecl = (statement as LocalDeclarationStatementSyntax).Declaration;
this.AnalyzeVariableDeclaration(varDecl, node);
}
else if (expr != null)
{
if (expr.Expression is AssignmentExpressionSyntax)
{
var assignment = expr.Expression as AssignmentExpressionSyntax;
this.AnalyzeAssignmentExpression(assignment, node);
}
else if (expr.Expression is IdentifierNameSyntax ||
expr.Expression is MemberAccessExpressionSyntax)
{
this.AnalyzeBinaryExpression(expr.Expression, node);
}
else if (expr.Expression is InvocationExpressionSyntax ||
expr.Expression is ObjectCreationExpressionSyntax)
{
this.AnalyzeMethodCall(expr.Expression, node);
}
}
else if (ret != null)
{
this.AnalyzeReturnStatement(ret, node);
}
}