本文整理匯總了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;
}