本文整理汇总了C#中DoStatementSyntax.GetLeadingTrivia方法的典型用法代码示例。如果您正苦于以下问题:C# DoStatementSyntax.GetLeadingTrivia方法的具体用法?C# DoStatementSyntax.GetLeadingTrivia怎么用?C# DoStatementSyntax.GetLeadingTrivia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoStatementSyntax
的用法示例。
在下文中一共展示了DoStatementSyntax.GetLeadingTrivia方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TraverseDoStatements
private Decisions TraverseDoStatements(DoStatementSyntax dss, ref int exitPoints, bool nested = false)
{
Decisions retDecision = new Decisions();
DoWhileLoop retDo = new DoWhileLoop();
if (dss.HasLeadingTrivia)
{
SetOuterComments(retDo, dss.GetLeadingTrivia().ToFullString());
}
if (dss.HasTrailingTrivia)
{
SetInnerComments(retDo, dss.GetTrailingTrivia().ToFullString());
}
ExpressionSyntax es = dss.Condition;
var binaryExpressions = from aBinaryExpression in dss.Condition.DescendantNodesAndSelf().OfType<BinaryExpressionSyntax>() select aBinaryExpression;
retDo.ConditionCount = binaryExpressions.Count();
foreach (BinaryExpressionSyntax bes in binaryExpressions)
{
Method tempMethod = TraverseBinaryExpression(bes);
retDo.AccessedVars.AddRange(tempMethod.AccessedVariables);
retDo.InvokedMethods.AddRange(tempMethod.InvokedMethods);
}
var catches = from aCatch in dss.ChildNodes().OfType<CatchClauseSyntax>() select aCatch;
foreach (CatchClauseSyntax ccs in catches)
{
Decisions tempCatch = TraverseCatchClauses(ccs, ref exitPoints, true);
retDo.Nested.AddRange(tempCatch.Catches);
}
var statements = from aStatement in dss.Statement.ChildNodes().OfType<StatementSyntax>() select aStatement;
List<BaseDecisions> retBd = new List<BaseDecisions>();
List<InvokedMethod> retIm = new List<InvokedMethod>();
#region Nested and Invoked Methods and accessed vars
foreach (StatementSyntax ss in statements)
{
//if (ss is BreakStatementSyntax)
//{
//}
//else if (ss is CheckedStatementSyntax)
//{
//}
//else if (ss is ContinueStatementSyntax)
//{
//}
if (ss is DoStatementSyntax)
{
Decisions dwl = TraverseDoStatements(ss as DoStatementSyntax, ref exitPoints, true);
retDo.Nested.AddRange(dwl.DoWhileLoops);
//dwl.IsNested = true;
//retDo.Nested.Add(dwl);
}
//else if (ss is EmptyStatementSyntax)
//{
//}
else if (ss is ExpressionStatementSyntax)
{
Method tempMethod = TraverseExpressionStatementSyntax(ss as ExpressionStatementSyntax);
retDo.AccessedVars.AddRange(tempMethod.AccessedVariables);
retDo.InvokedMethods.AddRange(tempMethod.InvokedMethods);
}
//else if (ss is FixedStatementSyntax)
//{
//}
else if (ss is ForEachStatementSyntax)
{
Decisions fes = TraverseForEachStatements(ss as ForEachStatementSyntax, ref exitPoints, true);
retDo.Nested.AddRange(fes.ForEachStatements);
//fes.IsNested = true;
//retDo.Nested.Add(fes);
}
else if (ss is ForStatementSyntax)
{
Decisions fs = TraverseForStatements(ss as ForStatementSyntax, ref exitPoints, true);
retDo.Nested.AddRange(fs.ForStatements);
//fs.IsNested = true;
//retDo.Nested.Add(fs);
}
//else if (ss is GotoStatementSyntax)
//{
//}
else if (ss is IfStatementSyntax)
{
Decisions ifstm = TraverseIfStatements(ss as IfStatementSyntax, ref exitPoints, true);
retDo.Nested.AddRange(ifstm.IfStatements);
//ifstm.IsNested = true;
//retDo.Nested.Add(ifstm);
}
//else if (ss is LabeledStatementSyntax)
//{
// BaseDecisions bd = new BaseDecisions();
// bd.IsNested = true;
// bd.Nested.Add(TraverseLabelStatements(ss as LabeledStatementSyntax));
// retIf.Nested.Add(bd);
//}
else if (ss is LocalDeclarationStatementSyntax)
{
Method tempMethod = TransverseAccessVars(ss as LocalDeclarationStatementSyntax);
retDo.AccessedVars.AddRange(tempMethod.AccessedVariables);
//.........这里部分代码省略.........