本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.GetLeadingTrivia方法的典型用法代码示例。如果您正苦于以下问题:C# ClassDeclarationSyntax.GetLeadingTrivia方法的具体用法?C# ClassDeclarationSyntax.GetLeadingTrivia怎么用?C# ClassDeclarationSyntax.GetLeadingTrivia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax
的用法示例。
在下文中一共展示了ClassDeclarationSyntax.GetLeadingTrivia方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TraverseClass
public Class TraverseClass(ClassDeclarationSyntax cds)
{
Class retClass = new Class();
//public List<Delegate> Delegates { get; set; }
//public List<Method> FunctionDefs { get; set; }
//public Inheritance Inheritance { get; set; }
//public List<Module> Modules { get; set; }
//public List<Preprocessor> Preprocessors { get; set; }
//public List<Property> Properties { get; set; }
//public List<Union> Unions { get; set; }
retClass.Name = cds.Identifier.ValueText;
if (cds.HasLeadingTrivia)
{
SetOuterComments(retClass, cds.GetLeadingTrivia().ToFullString());
}
if (cds.HasTrailingTrivia)
{
SetInnerComments(retClass, cds.GetTrailingTrivia().ToFullString());
}
foreach (SyntaxToken st in cds.Modifiers)
{
string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
Encapsulation encap;
Qualifiers qual;
if (System.Enum.TryParse<Encapsulation>( modifier, out encap))
{
retClass.Encapsulation.Add(encap);
}
else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
{
retClass.Qualifiers.Add(qual);
}
}
var enums = from aEnu in cds.ChildNodes().OfType<EnumDeclarationSyntax>() select aEnu;
foreach (EnumDeclarationSyntax eds in enums)
{
retClass.Enums.Add(TraverseEnums(eds));
}
var structs = from aStruct in cds.ChildNodes().OfType<StructDeclarationSyntax>() select aStruct;
foreach (StructDeclarationSyntax sds in structs)
{
retClass.Structs.Add(TransverseStructs(sds));
}
var methods = from aMethod in cds.ChildNodes().OfType<MethodDeclarationSyntax>() select aMethod;
foreach (MethodDeclarationSyntax mds in methods)
{
retClass.Methods.Add(TransverseMethods(mds));
}
var Fields = from aField in cds.ChildNodes().OfType<FieldDeclarationSyntax>() select aField;
foreach (FieldDeclarationSyntax fds in Fields)
{
retClass.Fields.Add(TransverseVariables(fds));
}
//var properties = from aProperty in cds.ChildNodes().OfType<PropertyDeclarationSyntax>() select aProperty;
//foreach (PropertyDeclarationSyntax pds in properties)
//{
// //traverse attributes
//}
var constructors = from aConstructor in cds.ChildNodes().OfType<ConstructorDeclarationSyntax>() select aConstructor;
foreach (ConstructorDeclarationSyntax cods in constructors)
{
retClass.Constructors.Add(TransverseConstructors(cods));
}
var destructors = from aDestructor in cds.ChildNodes().OfType<DestructorDeclarationSyntax>() select aDestructor;
foreach (DestructorDeclarationSyntax dds in destructors)
{
retClass.Destructors.Add(TransverseDestructors(dds));
}
var classes = from aClass in cds.ChildNodes().OfType<ClassDeclarationSyntax>() select aClass;
foreach (ClassDeclarationSyntax cds2 in classes)
{
retClass.Classes.Add(TraverseClass(cds2));
}
return retClass;
}