本文整理汇总了C#中ICSharpCode.NRefactory.Ast.TypeDeclaration.AcceptChildren方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclaration.AcceptChildren方法的具体用法?C# TypeDeclaration.AcceptChildren怎么用?C# TypeDeclaration.AcceptChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.NRefactory.Ast.TypeDeclaration
的用法示例。
在下文中一共展示了TypeDeclaration.AcceptChildren方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTypeDeclaration
public override object VisitTypeDeclaration (TypeDeclaration node, object data)
{
if (CurrentType != null) {
Console.WriteLine ("Nested types are not supported");
//throw CreateException (node, "Nested types are not supported");
}
if (IsHiddenClass (node))
return null;
if ((node.Modifier & Modifiers.Partial) > 0) {
Console.WriteLine ("Partial classes are not supported: " + node);
//throw CreateException (node, "Partial classes are not supported");
}
CurrentType = new JsTypeInfo { Name = GenericsHelper.GetScriptName (node), ClassType = node.Type, Namespace = Namespace, Usings = new HashSet<string> (Usings) };
Usings = new HashSet<string> ();
CurrentType.IsStatic = node.Type == ClassType.Enum || HasModifier (node.Modifier, Modifiers.Static);
if (node.Type != ClassType.Interface)
node.AcceptChildren (this, null);
if (CachedCctor != null) {
if (!ProcessCctor ())
throw CreateException (node, "Static constructor may only contain primitive or array static field initializations");
CachedCctor = null;
}
CollectedTypes.Add (CurrentType);
CurrentType = null;
return null;
}
示例2: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
Contract.Requires(typeDeclaration != null);
// Is this a class?
if (IsClass(typeDeclaration))
{
// Process for multiple partial of class in the same file
if (!IsExist(DictClass, typeDeclaration.Name))
{
var objClass = new ClassStructure
{
Name = typeDeclaration.Name,
Methods = new List<MethodStructure>()
};
DictClass.Add(objClass.Name, objClass);
}
}
// Visit children (E.g. MethodDeclarion objects)
typeDeclaration.AcceptChildren(this, data);
return null;
}
示例3: TrackedVisitTypeDeclaration
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
this.codeBuilder.AppendLineIfPreviousLineIsCode();
this.AppendIndented(string.Concat("class ", typeDeclaration.Name));
this.AppendBaseTypes(typeDeclaration.BaseTypes);
this.AppendLine();
this.IncreaseIndent();
this.AppendDocstring(this.xmlDocComments);
if (typeDeclaration.Children.Count <= 0)
{
this.AppendIndentedPassStatement();
}
else
{
this.constructorInfo = PythonConstructorInfo.GetConstructorInfo(typeDeclaration);
if (this.constructorInfo != null)
{
if (this.constructorInfo.Constructor == null)
{
this.CreateConstructor(this.constructorInfo);
}
}
typeDeclaration.AcceptChildren(this, data);
}
this.DecreaseIndent();
return null;
}
示例4: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
TypeDeclaration oldTypeDeclaration = currentTypeDeclaration;
this.currentTypeDeclaration = typeDeclaration;
CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(typeDeclaration.Name);
codeTypeDeclaration.TypeAttributes = ConvTypeAttributes(typeDeclaration.Modifier);
codeTypeDeclaration.IsClass = typeDeclaration.Type == ClassType.Class;
codeTypeDeclaration.IsEnum = typeDeclaration.Type == ClassType.Enum;
codeTypeDeclaration.IsInterface = typeDeclaration.Type == ClassType.Interface;
codeTypeDeclaration.IsStruct = typeDeclaration.Type == ClassType.Struct;
codeTypeDeclaration.IsPartial = (typeDeclaration.Modifier & Modifiers.Partial) != 0;
if (typeDeclaration.BaseTypes != null) {
foreach (TypeReference typeRef in typeDeclaration.BaseTypes) {
codeTypeDeclaration.BaseTypes.Add(ConvType(typeRef));
}
}
typeDeclarations.Push(codeTypeDeclaration);
typeDeclaration.AcceptChildren(this, data);
typeDeclarations.Pop();
if (typeDeclarations.Count > 0) {
typeDeclarations.Peek().Members.Add(codeTypeDeclaration);
} else {
namespaceDeclarations.Peek().Types.Add(codeTypeDeclaration);
}
currentTypeDeclaration = oldTypeDeclaration;
return null;
}
示例5: TrackedVisitTypeDeclaration
/// <summary>
/// Visits a class.
/// </summary>
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
codeBuilder.AppendLineIfPreviousLineIsCode();
AppendIndented("class " + typeDeclaration.Name);
AppendBaseTypes(typeDeclaration.BaseTypes);
AppendLine();
IncreaseIndent();
AppendDocstring(xmlDocComments);
if (typeDeclaration.Children.Count > 0) {
// Look for fields or a constructor for the type.
constructorInfo = PythonConstructorInfo.GetConstructorInfo(typeDeclaration);
if (constructorInfo != null) {
if (constructorInfo.Constructor != null) {
// Generate constructor later when VisitConstructorDeclaration method is called.
// This allows the constructor comments to be converted in the right place.
} else {
CreateConstructor(constructorInfo);
}
}
// Visit the rest of the class.
typeDeclaration.AcceptChildren(this, data);
} else {
AppendIndentedPassStatement();
}
DecreaseIndent();
return null;
}
示例6: VisitTypeDeclaration
public object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (typeDeclaration.Templates.Count > 0) {
AddError(typeDeclaration, "Generic type definitions are not supported.");
}
B.TypeDefinition oldType = currentType;
B.TypeDefinition typeDef;
switch (typeDeclaration.Type) {
case ClassType.Class:
typeDef = new B.ClassDefinition(GetLexicalInfo(typeDeclaration));
break;
case ClassType.Interface:
typeDef = new B.InterfaceDefinition(GetLexicalInfo(typeDeclaration));
break;
case ClassType.Enum:
typeDef = new B.EnumDefinition(GetLexicalInfo(typeDeclaration));
break;
case ClassType.Struct:
typeDef = new B.StructDefinition(GetLexicalInfo(typeDeclaration));
break;
case ClassType.Module:
typeDef = new B.ClassDefinition(GetLexicalInfo(typeDeclaration));
typeDeclaration.Modifier |= Modifiers.Static;
break;
default:
AddError(typeDeclaration, "Unknown class type.");
return null;
}
if (currentType != null)
typeDef.Modifiers = ConvertModifier(typeDeclaration, B.TypeMemberModifiers.Private);
else
typeDef.Modifiers = ConvertModifier(typeDeclaration, B.TypeMemberModifiers.Internal);
typeDef.Name = typeDeclaration.Name;
typeDef.EndSourceLocation = GetLocation(typeDeclaration.EndLocation);
ConvertAttributes(typeDeclaration.Attributes, typeDef.Attributes);
ConvertTypeReferences(typeDeclaration.BaseTypes, typeDef.BaseTypes);
if (currentType != null)
currentType.Members.Add(typeDef);
else
module.Members.Add(typeDef);
currentType = typeDef;
typeDeclaration.AcceptChildren(this, data);
currentType = oldType;
return typeDef;
}
示例7: VisitTypeDeclaration
public virtual object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
Debug.Assert((typeDeclaration != null));
Debug.Assert((typeDeclaration.Attributes != null));
Debug.Assert((typeDeclaration.BaseTypes != null));
Debug.Assert((typeDeclaration.Templates != null));
foreach (AttributeSection o in typeDeclaration.Attributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (TypeReference o in typeDeclaration.BaseTypes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (TemplateDefinition o in typeDeclaration.Templates) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
return typeDeclaration.AcceptChildren(this, data);
}
示例8: VisitTypeDeclaration
public virtual bool VisitTypeDeclaration(TypeDeclaration typeDeclaration, object d)
{
if ((typeDeclaration == null)) {
return SetFailure();
}
if ((d == null)) {
return SetFailure();
}
if ((typeDeclaration.Attributes == null)) {
return SetFailure();
}
if ((typeDeclaration.BaseTypes == null)) {
return SetFailure();
}
if ((typeDeclaration.Templates == null)) {
return SetFailure();
}
if(typeDeclaration.GetType() != d.GetType()) {return SetFailure();}
var data = (TypeDeclaration)d;
if (!IsMatch(typeDeclaration, data)) {
return SetFailure();
}
if (typeDeclaration.Attributes.Count == data.Attributes.Count) {
for (int i=0; i<typeDeclaration.Attributes.Count;i++) {
AttributeSection o = typeDeclaration.Attributes[i];
if(o == null){return SetFailure();}
if((bool)o.AcceptVisitor(this, data.Attributes[i]) == false) return SetFailure();
} } else { return SetFailure(); }
if (typeDeclaration.BaseTypes.Count == data.BaseTypes.Count) {
for (int i=0; i<typeDeclaration.BaseTypes.Count;i++) {
TypeReference o = typeDeclaration.BaseTypes[i];
if(o == null){return SetFailure();}
if((bool)o.AcceptVisitor(this, data.BaseTypes[i]) == false) return SetFailure();
} } else { return SetFailure(); }
if (typeDeclaration.Templates.Count == data.Templates.Count) {
for (int i=0; i<typeDeclaration.Templates.Count;i++) {
TemplateDefinition o = typeDeclaration.Templates[i];
if(o == null){return SetFailure();}
if((bool)o.AcceptVisitor(this, data.Templates[i]) == false) return SetFailure();
} } else { return SetFailure(); }
return typeDeclaration.AcceptChildren(this, d);
}
示例9: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
Contract.Requires(typeDeclaration != null);
// Is this a class but not a test fixture?
if (IsClass(typeDeclaration) && !HasTestFixtureAttribute(typeDeclaration))
{
var parent = new JsClass()
{
Name = typeDeclaration.Name,
Properties = new List<JsProperty>()
};
if (typeDeclaration.Attributes.Count > 0)
{
foreach (var attribute in typeDeclaration.Attributes)
{
var jsAttributes = new List<JsAttribute>();
var a = attribute.Attributes[0];
jsAttributes.Add(new JsAttribute()
{
Name = a.Name
});
parent.Attributes = jsAttributes;
}
}
if (Model == null) Model = new JsFile();
if (Model.Files == null) Model.Files = new List<JsClass>();
Model.Files.Add(parent);
CurrentParent = parent;
}
// Visit children (E.g. MethodDeclarion objects)
typeDeclaration.AcceptChildren(this, data);
return null;
}