本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.ChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionStatementSyntax.ChildNodes方法的具体用法?C# ExpressionStatementSyntax.ChildNodes怎么用?C# ExpressionStatementSyntax.ChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax
的用法示例。
在下文中一共展示了ExpressionStatementSyntax.ChildNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TraverseExpressionStatementSyntax
//private Method TraverseStatementSyntax(StatementSyntax ss)
//{
// Method retMethod = new Method();
// //TODO
// //Get catches for decisions
// if (ss is DoStatementSyntax)
// {
// DoWhileLoop dwl = TraverseDoStatements(ss as DoStatementSyntax);
// dwl.IsNested = true;
// retMethod.Decisions.DoWhileLoops.Add(dwl);
// }
// else if (ss is ExpressionStatementSyntax)
// {
// Method tempMethod = TraverseExpressionStatementSyntax(ss as ExpressionStatementSyntax);
// retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
// retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
// }
// else if (ss is ForEachStatementSyntax)
// {
// ForEachStatement fes = TraverseForEachStatements(ss as ForEachStatementSyntax);
// fes.IsNested = true;
// retMethod.Decisions.ForEachStatements.Add(fes);
// }
// else if (ss is ForStatementSyntax)
// {
// ForStatement fs = TraverseForStatements(ss as ForStatementSyntax);
// fs.IsNested = true;
// retMethod.Decisions.ForStatements.Add(fs);
// }
// else if (ss is IfStatementSyntax)
// {
// IfStatement ifstm = TraverseIfStatements(ss as IfStatementSyntax);
// ifstm.IsNested = true;
// retMethod.Decisions.IfStatements.Add(ifstm);
// }
// else if (ss is LocalDeclarationStatementSyntax)
// {
// Model.Type tempType = new Model.Type();
// LocalDeclarationStatementSyntax ldss = ss as LocalDeclarationStatementSyntax;
// if (ldss.Declaration != null)
// {
// VariableDeclarationSyntax vds = ldss.Declaration;
// tempType.Name = vds.Type.ToString();
// tempType.IsKnownType = true;
// tempType.IsNotUserDefined = true;
// }
// Method tempMethod = TransverseAccessVars(ss as LocalDeclarationStatementSyntax);
// //NOT SURE if this will work but here goes
// tempMethod.AccessedVariables[0].Type = tempType;
// retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
// retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
// }
// else if (ss is SwitchStatementSyntax)
// {
// SwitchStatement switchStm = TraverseSwitchStatements(ss as SwitchStatementSyntax);
// switchStm.IsNested = true;
// retMethod.Decisions.SwitchStatements.Add(switchStm);
// }
// else if (ss is WhileStatementSyntax)
// {
// WhileLoop wl = TraverseWhileLoops(ss as WhileStatementSyntax);
// wl.IsNested = true;
// retMethod.Decisions.WhileLoops.Add(wl);
// }
// return retMethod;
//}
private Method TraverseExpressionStatementSyntax(ExpressionStatementSyntax ess)
{
Method retMethod = new Method();
if (ess.HasLeadingTrivia)
{
SetOuterComments(retMethod, ess.GetLeadingTrivia().ToFullString());
}
if (ess.HasTrailingTrivia)
{
SetInnerComments(retMethod, ess.GetTrailingTrivia().ToFullString());
}
var vars = from aVar in ess.ChildNodes().OfType<BinaryExpressionSyntax>() select aVar;
foreach (BinaryExpressionSyntax bes in vars)
{
Method tempMethod = TraverseBinaryExpression(bes);
retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
}
var invokedMethods = from aInvokedMethod in ess.ChildNodes().OfType<InvocationExpressionSyntax>() select aInvokedMethod;
foreach (InvocationExpressionSyntax ies in invokedMethods)
{
Method tempMethod = TraverseInvocationExpression(ies);
retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
}
var postfixUnaryExpressions = from aPostfixUnaryExpression in ess.ChildNodes().OfType<PostfixUnaryExpressionSyntax>() select aPostfixUnaryExpression;
foreach (PostfixUnaryExpressionSyntax pues in postfixUnaryExpressions)
{
Method tempMethod = TraversePostfixUnaryExpressions(pues);
retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
//.........这里部分代码省略.........