本文整理汇总了C#中TypeDeclaration.GetParent方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclaration.GetParent方法的具体用法?C# TypeDeclaration.GetParent怎么用?C# TypeDeclaration.GetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeDeclaration
的用法示例。
在下文中一共展示了TypeDeclaration.GetParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTypeSignature
public static string CreateTypeSignature(TypeDeclaration type)
{
var @namespace = type.GetParent<NamespaceDeclaration>();
var builder = new StringBuilder();
builder.Append(@namespace.FullName.ToJavaNamespace());
builder.Append("/");
builder.Append(type.Name);
return builder.ToString();
}
示例2: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
if (!typeDeclaration.HasModifier(Modifiers.Public))
{
base.VisitTypeDeclaration(typeDeclaration);
return;
}
var parent = typeDeclaration.GetParent<TypeDeclaration>();
if (parent != null && typeDeclaration.HasModifier(Modifiers.Public))
{
this.Results.Issues.Add(new LintIssue(typeDeclaration)
{
Index = LintIssueIndex.PublicNestedClassDefined,
Parameters = new[]
{
typeDeclaration.Name
}
});
}
base.VisitTypeDeclaration(typeDeclaration);
}
示例3: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
if (this.CurrentType != null)
{
this.NestedTypes = this.NestedTypes ?? new List<Tuple<TypeDeclaration, ITypeInfo>>();
this.NestedTypes.Add(new Tuple<TypeDeclaration, ITypeInfo>(typeDeclaration, this.CurrentType));
return;
}
ValidateNamespace(typeDeclaration);
if (this.HasIgnore(typeDeclaration))
{
return;
}
var rr = this.Resolver.ResolveNode(typeDeclaration, null);
var fullName = rr.Type.ReflectionName;
var partialType = this.Types.FirstOrDefault(t => t.Key == fullName);
var add = true;
if (partialType == null)
{
ITypeInfo parentTypeInfo = null;
var parentTypeDeclaration = typeDeclaration.GetParent<TypeDeclaration>();
if (parentTypeDeclaration != null)
{
var rr1 = this.Resolver.ResolveNode(parentTypeDeclaration, null);
var parentName = rr1.Type.ReflectionName;
parentTypeInfo = this.Types.FirstOrDefault(t => t.Key == parentName);
}
this.CurrentType = new TypeInfo()
{
Key = rr.Type.ReflectionName,
TypeDeclaration = typeDeclaration,
ParentType = parentTypeInfo,
Name = typeDeclaration.Name,
ClassType = typeDeclaration.ClassType,
Namespace = this.Namespace,
Usings = new HashSet<string>(Usings),
IsEnum = typeDeclaration.ClassType == ClassType.Enum,
IsStatic = typeDeclaration.ClassType == ClassType.Enum || typeDeclaration.HasModifier(Modifiers.Static),
IsObjectLiteral = this.IsObjectLiteral(typeDeclaration),
Type = rr.Type
};
if (parentTypeInfo != null && Emitter.reservedStaticNames.Any(n => String.Equals(this.CurrentType.Name, n, StringComparison.InvariantCultureIgnoreCase)))
{
throw new EmitterException(typeDeclaration, "Nested class cannot have such name: " + this.CurrentType.Name + ". Please rename it.");
}
}
else
{
this.CurrentType = partialType;
add = false;
}
if (typeDeclaration.ClassType != ClassType.Interface)
{
typeDeclaration.AcceptChildren(this);
}
else
{
typeDeclaration.AcceptChildren(this);
}
if (add)
{
this.Types.Add(this.CurrentType);
}
this.CurrentType = null;
while (this.NestedTypes != null && this.NestedTypes.Count > 0)
{
var types = this.NestedTypes;
this.NestedTypes = null;
foreach (var nestedType in types)
{
this.VisitTypeDeclaration(nestedType.Item1);
}
}
}