本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax.GetTrailingTrivia方法的典型用法代码示例。如果您正苦于以下问题:C# LocalDeclarationStatementSyntax.GetTrailingTrivia方法的具体用法?C# LocalDeclarationStatementSyntax.GetTrailingTrivia怎么用?C# LocalDeclarationStatementSyntax.GetTrailingTrivia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax
的用法示例。
在下文中一共展示了LocalDeclarationStatementSyntax.GetTrailingTrivia方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransverseAccessVars
private Method TransverseAccessVars(LocalDeclarationStatementSyntax ldss)
{
Method retMethod = new Method();
if (ldss.HasLeadingTrivia)
{
SetOuterComments(retMethod, ldss.GetLeadingTrivia().ToFullString());
}
if (ldss.HasTrailingTrivia)
{
SetInnerComments(retMethod, ldss.GetTrailingTrivia().ToFullString());
}
List<Encapsulation> accessability = new List<Encapsulation>();
List<Qualifiers> qualifiers = new List<Qualifiers>();
foreach (SyntaxToken st in ldss.Modifiers)
{
string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
Encapsulation encap;
Qualifiers qual;
if (System.Enum.TryParse<Encapsulation>(modifier, out encap))
{
accessability.Add(encap);
}
else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
{
qualifiers.Add(qual);
}
}
retMethod.Qualifiers.AddRange(qualifiers);
retMethod.Encapsulation.AddRange(accessability);
VariableDeclarationSyntax varDecl = ldss.Declaration;
Model.Type tempType = new Model.Type();
if(varDecl.Type is PredefinedTypeSyntax)
{
tempType.Name = varDecl.Type.ToString();
tempType.IsKnownType = true;
tempType.IsNotUserDefined = true;
}
var vars = from aVar in varDecl.ChildNodes().OfType<VariableDeclaratorSyntax>() select aVar;
foreach (VariableDeclaratorSyntax vds in vars)
{
//Variables retVar = new Variables();
Method tempMethod = TraverseVarDeclarators(vds);
foreach (Variables vrs in tempMethod.AccessedVariables)
{
vrs.Type = tempType;
}
retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
if (vds.Initializer != null)
{
var castStatements = from aCastStatement in vds.Initializer.Value.ChildNodes().OfType<CastExpressionSyntax>() select aCastStatement;
foreach (CastExpressionSyntax ces in castStatements)
{
Method retCast = TraverseCastExpressions(ces);
retMethod.AccessedVariables.AddRange(retCast.AccessedVariables);
retMethod.InvokedMethods.AddRange(retCast.InvokedMethods);
}
}
}
return retMethod;
}