本文整理汇总了Java中javax.lang.model.element.NestingKind.ANONYMOUS属性的典型用法代码示例。如果您正苦于以下问题:Java NestingKind.ANONYMOUS属性的具体用法?Java NestingKind.ANONYMOUS怎么用?Java NestingKind.ANONYMOUS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.lang.model.element.NestingKind
的用法示例。
在下文中一共展示了NestingKind.ANONYMOUS属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
public static TargetDescription create(CompilationInfo info, TypeElement type, TreePath path, boolean allowForDuplicates, boolean iface) {
boolean canStatic = true;
if (iface) {
// interface cannot have static methods
canStatic = false;
} else {
if (type.getNestingKind() == NestingKind.ANONYMOUS ||
type.getNestingKind() == NestingKind.LOCAL ||
(type.getNestingKind() != NestingKind.TOP_LEVEL && !type.getModifiers().contains(Modifier.STATIC))) {
canStatic = false;
}
}
return new TargetDescription(Utilities.target2String(type),
ElementHandle.create(type),
TreePathHandle.create(path, info),
allowForDuplicates,
type.getSimpleName().length() == 0, iface, canStatic);
}
示例2: tooComplexClass
@Hint(
displayName = "#DN_ClassTooComplex",
description = "#DESC_ClassTooComplex",
category = "metrics",
options = { Hint.Options.HEAVY, Hint.Options.QUERY },
enabled = false
)
@UseOptions(OPTION_COMPLEXITY_LIMIT)
@TriggerTreeKind(Tree.Kind.CLASS)
public static ErrorDescription tooComplexClass(HintContext ctx) {
ClassTree clazz = (ClassTree)ctx.getPath().getLeaf();
TypeElement e = (TypeElement)ctx.getInfo().getTrees().getElement(ctx.getPath());
if (e.getNestingKind() == NestingKind.ANONYMOUS) {
return null;
}
CyclomaticComplexityVisitor v = new CyclomaticComplexityVisitor();
v.scan(ctx.getPath(), null);
int complexity = v.getComplexity();
int limit = ctx.getPreferences().getInt(OPTION_COMPLEXITY_LIMIT, DEFAULT_COMPLEXITY_LIMIT);
if (complexity > limit) {
return ErrorDescriptionFactory.forName(ctx,
ctx.getPath(),
TEXT_ClassTooComplex(clazz.getSimpleName().toString(), complexity));
} else {
return null;
}
}
示例3: getNestingKind
@DefinedBy(Api.LANGUAGE_MODEL)
public NestingKind getNestingKind() {
complete();
if (owner.kind == PCK)
return NestingKind.TOP_LEVEL;
else if (name.isEmpty())
return NestingKind.ANONYMOUS;
else if (owner.kind == MTH)
return NestingKind.LOCAL;
else
return NestingKind.MEMBER;
}
示例4: getNestingKind
@Override
public NestingKind getNestingKind() {
ReferenceBinding refBinding = (ReferenceBinding)_binding;
if (refBinding.isAnonymousType()) {
return NestingKind.ANONYMOUS;
} else if (refBinding.isLocalType()) {
return NestingKind.LOCAL;
} else if (refBinding.isMemberType()) {
return NestingKind.MEMBER;
}
return NestingKind.TOP_LEVEL;
}