本文整理汇总了Java中javax.lang.model.element.ElementKind.ANNOTATION_TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.ANNOTATION_TYPE属性的具体用法?Java ElementKind.ANNOTATION_TYPE怎么用?Java ElementKind.ANNOTATION_TYPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.lang.model.element.ElementKind
的用法示例。
在下文中一共展示了ElementKind.ANNOTATION_TYPE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: from
static AttributeTypeKind from(TypeMirror type) {
if (type.getKind() == TypeKind.DECLARED) {
TypeElement typeElement = toElement(type);
if (typeElement.getKind() == ElementKind.ENUM) {
return ENUM;
}
if (typeElement.getKind() == ElementKind.ANNOTATION_TYPE) {
return ANNOTATION;
}
Name qualifiedName = typeElement.getQualifiedName();
if (qualifiedName.contentEquals(Class.class.getName())) {
return TYPE;
}
if (qualifiedName.contentEquals(String.class.getName())) {
return STRING;
}
} else if (type.getKind().isPrimitive()) {
return PRIMITIVE;
}
throw new AssertionError();
}
示例2: isInaccessibleOutsideOuterClass
/**
* computes accessibility of members of nested classes
* @param e member
* @return {@code true} if the member cannot be accessed outside the outer class
* @see <a href="http://www.netbeans.org/issues/show_bug.cgi?id=169377">169377</a>
*/
private static boolean isInaccessibleOutsideOuterClass(Element e, ElementUtilities eu) {
Element enclosing = e.getEnclosingElement();
boolean isStatic = e.getModifiers().contains(Modifier.STATIC);
ElementKind kind = e.getKind();
if (isStatic || kind.isClass() || kind.isInterface() || kind.isField()) {
// static declaration of nested class, interface, enum, ann type, method, field
// or inner class
return isAnyEncloserPrivate(e);
} else if (enclosing != null && kind == ElementKind.METHOD) {
// final is enum, ann type and some classes
ElementKind enclosingKind = enclosing.getKind();
boolean isEnclosingFinal = enclosing.getModifiers().contains(Modifier.FINAL)
// ann type is not final even if it cannot be subclassed
|| enclosingKind == ElementKind.ANNOTATION_TYPE;
return isAnyEncloserPrivate(e) && !eu.overridesMethod((ExecutableElement) e) && !eu.implementsMethod((ExecutableElement)e) &&
(isEnclosingFinal || !isOverriddenInsideOutermostEnclosingClass((ExecutableElement)e, eu));
}
return false;
}
示例3: decodeKind
@NonNull
static ElementKind decodeKind (char kind) {
switch (kind) {
case EK_CLASS:
case EK_LOCAL_CLASS:
return ElementKind.CLASS;
case EK_INTERFACE:
case EK_LOCAL_INTERFACE:
return ElementKind.INTERFACE;
case EK_ENUM:
case EK_LOCAL_ENUM:
return ElementKind.ENUM;
case EK_ANNOTATION:
case EK_LOCAL_ANNOTATION:
return ElementKind.ANNOTATION_TYPE;
case EK_MODULE:
return ElementKind.MODULE;
default:
throw new IllegalArgumentException ();
}
}
示例4: javaDocFor
/**Get javadoc for given element.
* @deprecated The new DocTree API should be used to traverse Javadoc comments.
* Use {@link DocTrees#getDocCommentTree(javax.lang.model.element.Element)} instead.
*/
@Deprecated
public Doc javaDocFor(Element element) {
if (element != null) {
DocEnv env = DocEnv.instance(ctx);
switch (element.getKind()) {
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
return env.getClassDoc((ClassSymbol)element);
case ENUM_CONSTANT:
case FIELD:
return env.getFieldDoc((VarSymbol)element);
case METHOD:
if (((MethodSymbol)element).enclClass().getKind() == ElementKind.ANNOTATION_TYPE)
return env.getAnnotationTypeElementDoc((MethodSymbol)element);
return env.getMethodDoc((MethodSymbol)element);
case CONSTRUCTOR:
return env.getConstructorDoc((MethodSymbol)element);
case PACKAGE:
return env.getPackageDoc((PackageSymbol)element);
}
}
return null;
}
示例5: checkAbstractValueType
static boolean checkAbstractValueType(Element element, Collection<String> violations) {
boolean ofSupportedKind = false
|| element.getKind() == ElementKind.INTERFACE
|| element.getKind() == ElementKind.ANNOTATION_TYPE
|| element.getKind() == ElementKind.CLASS;
boolean staticOrTopLevel = false
|| element.getEnclosingElement().getKind() == ElementKind.PACKAGE
|| element.getModifiers().contains(Modifier.STATIC);
boolean nonFinal = !element.getModifiers().contains(Modifier.FINAL);
boolean publicOrPackageVisible =
!element.getModifiers().contains(Modifier.PRIVATE)
&& !element.getModifiers().contains(Modifier.PROTECTED);
if (!ofSupportedKind) {
violations.add("must be class or interface or annotation type");
}
if (!nonFinal) {
violations.add("must be non-final");
}
if (!publicOrPackageVisible) {
violations.add("should be public or package-visible");
}
if (!staticOrTopLevel) {
violations.add("should be top-level or static inner class");
}
return violations.isEmpty();
}
示例6: getKind
@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
long flags = flags();
if ((flags & ANNOTATION) != 0)
return ElementKind.ANNOTATION_TYPE;
else if ((flags & INTERFACE) != 0)
return ElementKind.INTERFACE;
else if ((flags & ENUM) != 0)
return ElementKind.ENUM;
else
return ElementKind.CLASS;
}
示例7: typeElementConvertor
@NonNull
public static Convertor<Document,ElementHandle<TypeElement>> typeElementConvertor() {
return new ElementHandleConvertor<> (
ElementKind.CLASS,
ElementKind.ENUM,
ElementKind.INTERFACE,
ElementKind.ANNOTATION_TYPE);
}
示例8: getElementKind
private static ElementKind getElementKind(@NonNull final ClassFile cf) {
if (cf.isEnum()) {
return ElementKind.ENUM;
} else if (cf.isAnnotation()) {
return ElementKind.ANNOTATION_TYPE;
} else if (cf.isModule()) {
return ElementKind.MODULE;
} else if ((cf.getAccess() & Access.INTERFACE) == Access.INTERFACE) {
return ElementKind.INTERFACE;
} else {
return ElementKind.CLASS;
}
}
示例9: doCreateFromTemplate
FileObject doCreateFromTemplate(CompilationUnitTree cut) throws IOException {
ElementKind kind;
if ("package-info.java".equals(cut.getSourceFile().getName())) {
kind = ElementKind.PACKAGE;
} else if (cut.getTypeDecls().isEmpty()) {
kind = null;
} else {
switch (cut.getTypeDecls().get(0).getKind()) {
case CLASS:
kind = ElementKind.CLASS;
break;
case INTERFACE:
kind = ElementKind.INTERFACE;
break;
case ANNOTATION_TYPE:
kind = ElementKind.ANNOTATION_TYPE;
break;
case ENUM:
kind = ElementKind.ENUM;
break;
default:
Logger.getLogger(WorkingCopy.class.getName()).log(Level.SEVERE, "Cannot resolve template for {0}", cut.getTypeDecls().get(0).getKind());
kind = null;
}
}
FileObject template = FileUtil.getConfigFile(template(kind));
return doCreateFromTemplate(template, cut.getSourceFile());
}
示例10: getGroupId
/**
* Returns the group number of the class member. Elements with the same
* number form a group. Groups with lower numbers should be positioned
* higher in the class member list.
* @param element the member element
* @return the group number
* @since 0.96
*/
public int getGroupId(Element element) {
for (Info info : infos) {
ElementKind kind = element.getKind();
if (kind == ElementKind.ANNOTATION_TYPE || kind == ElementKind.ENUM || kind == ElementKind.INSTANCE_INIT)
kind = ElementKind.CLASS;
if (info.check(kind, element.getModifiers()));
return info.groupId;
}
return infos.length;
}
示例11: getText
public String getText() {
if(target.getKind() == ElementKind.ANNOTATION_TYPE)
return NbBundle.getMessage(CreateMethodFix.class, "LBL_FIX_Create_Annotation_Element", methodDisplayName, inFQN );
if (returnType != null) {
return NbBundle.getMessage(CreateMethodFix.class, "LBL_FIX_Create_Method", methodDisplayName, inFQN );
} else {
return NbBundle.getMessage(CreateMethodFix.class, "LBL_FIX_Create_Constructor", methodDisplayName, inFQN );
}
}
示例12: isInAnnotationType
static boolean isInAnnotationType(CompilationInfo info, TreePath path) {
Element e = info.getTrees().getElement(path);
if (e != null) {
e = e.getEnclosingElement();
return e != null && e.getKind() == ElementKind.ANNOTATION_TYPE;
}
return false;
}
示例13: getClassType
private static ElementKind getClassType(Set<ElementKind> types) {
if (types.contains(ElementKind.CLASS))
return ElementKind.CLASS;
if (types.contains(ElementKind.ANNOTATION_TYPE))
return ElementKind.ANNOTATION_TYPE;
if (types.contains(ElementKind.INTERFACE))
return ElementKind.INTERFACE;
if (types.contains(ElementKind.ENUM))
return ElementKind.ENUM;
return null;
}
示例14: isAnnotationType
public boolean isAnnotationType() {
return element.getKind() == ElementKind.ANNOTATION_TYPE;
}
示例15: isImplementing
public boolean isImplementing() {
return element.getKind() == ElementKind.INTERFACE
|| element.getKind() == ElementKind.ANNOTATION_TYPE;
}