本文整理汇总了Java中javax.lang.model.element.ElementKind.ENUM属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.ENUM属性的具体用法?Java ElementKind.ENUM怎么用?Java ElementKind.ENUM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.lang.model.element.ElementKind
的用法示例。
在下文中一共展示了ElementKind.ENUM属性的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: getEnumElements
public Collection<TypeElement> getEnumElements() {
if (isEnumType()) {
return Collections.singletonList(containedTypeElement);
}
if (!isContainerType()) {
List<TypeElement> elements = Lists.newArrayListWithCapacity(2);
if (hasEnumContainedElementType()) {
elements.add(containedTypeElement);
}
if (isMapType() && containedSecondaryTypeElement.getKind() == ElementKind.ENUM) {
elements.add(containedSecondaryTypeElement);
}
return elements;
}
return Collections.emptyList();
}
示例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: ElementGrip
private ElementGrip(TreePathHandle delegateElementHandle, Element elm, CompilationInfo info) {
this.delegateElementHandle = delegateElementHandle;
this.handle = elm == null ? null : ElementHandle.create(elm);
if (elm != null) {
if (elm.getKind() == ElementKind.CLASS && elm.getSimpleName().length() == 0) {
this.toString = ((TypeElement) elm).asType().toString();
this.icon = ElementIcons.getElementIcon(elm.getKind(), elm.getModifiers());
} else if(elm.getKind() == ElementKind.ENUM
&& elm.getSimpleName().length() == 0
&& elm.getEnclosingElement() != null) {
final Element enclosingElement = elm.getEnclosingElement();
this.toString = enclosingElement.getSimpleName().toString();
this.icon = ElementIcons.getElementIcon(enclosingElement.getKind(), enclosingElement.getModifiers());
} else {
// workaround for issue 171692
this.toString = elm.getKind() != ElementKind.CONSTRUCTOR
? elm.getSimpleName().toString()
: elm.getEnclosingElement().getSimpleName().toString();
this.icon = ElementIcons.getElementIcon(elm.getKind(), elm.getModifiers());
// this.toString = ElementHeaders.getHeader(treePath, info, ElementHeaders.NAME);
}
}
this.fileObject = info.getFileObject();
}
示例5: createItem
private CompletionItem createItem(ElementHandle<TypeElement> handle, int priority) {
TypeElement el = handle.resolve(ctx.getCompilationInfo());
if (el == null) {
// element does not exist etc
return null;
}
if (el.getKind() != ElementKind.CLASS && el.getKind() != ElementKind.ENUM) {
// do not honour interfaces
return null;
}
if (!el.getModifiers().contains(Modifier.PUBLIC)) {
return null;
}
CompletionItem item = null;
Collection<? extends ClassItemFactory> converters = MimeLookup.getLookup(JavaFXEditorUtils.FXML_MIME_TYPE).lookupAll(ClassItemFactory.class);
for (ClassItemFactory converter : converters) {
item = converter.convert(el, ctx, priority);
if (item != null) {
break;
}
}
return item;
}
示例6: createCompleter
@Override
public Completer createCompleter(CompletionContext ctx) {
FxProperty p = ctx.getEnclosingProperty();
if (p == null || p.getType() == null) {
return null;
}
TypeMirror m = p.getType().resolve(ctx.getCompilationInfo());
if (m.getKind() == TypeKind.BOOLEAN) {
return new EnumValueCompleter(ctx);
}
if (m.getKind() != TypeKind.DECLARED) {
return null;
}
DeclaredType t = (DeclaredType)m;
TypeElement tel = (TypeElement)t.asElement();
if (tel.getQualifiedName().contentEquals("java.lang.Boolean")) {
return new EnumValueCompleter(ctx);
}
if (tel.getKind() == ElementKind.ENUM) {
return new EnumValueCompleter(ctx, tel);
} else {
return null;
}
}
示例7: visitMemberSelect
@Override
public State visitMemberSelect(MemberSelectTree node, Void p) {
State expr = scan(node.getExpression(), p);
boolean wasNPE = false;
if (expr == State.NULL || expr == State.NULL_HYPOTHETICAL || expr == State.POSSIBLE_NULL || expr == State.POSSIBLE_NULL_REPORT) {
wasNPE = true;
}
Element site = info.getTrees().getElement(new TreePath(getCurrentPath(), node.getExpression()));
if (isVariableElement(site) && wasNPE && (variable2State.get((VariableElement) site) == null || !variable2State.get((VariableElement) site).isNotNull())) {
variable2State.put((VariableElement) site, NOT_NULL_BE_NPE);
}
// special case: if the memberSelect selects enum field = constant, it is never null.
if (site != null && site.getKind() == ElementKind.ENUM) {
Element enumConst = info.getTrees().getElement(getCurrentPath());
if (enumConst != null && enumConst.getKind() == ElementKind.ENUM_CONSTANT) {
return State.NOT_NULL;
}
}
return getStateFromAnnotations(info, info.getTrees().getElement(getCurrentPath()));
}
示例8: validate
/**
* Some validations, not exhaustive.
*/
@Value.Check
protected void validate() {
if (include().isPresent() && !isTopLevel()) {
report()
.annotationNamed(IncludeMirror.simpleName())
.error("@%s could not be used on nested types.", IncludeMirror.simpleName());
}
if (builderInclude().isPresent() && !isTopLevel()) {
report()
.annotationNamed(FIncludeMirror.simpleName())
.error("@%s could not be used on nested types.", FIncludeMirror.simpleName());
}
if (isEnclosing() && !isTopLevel()) {
report()
.annotationNamed(EnclosingMirror.simpleName())
.error("@%s should only be used on a top-level types.", EnclosingMirror.simpleName());
}
if (isImmutable() && element().getKind() == ElementKind.ENUM) {
report()
.annotationNamed(ImmutableMirror.simpleName())
.error("@%s is not supported on enums", ImmutableMirror.simpleName());
}
if (isModifiable() && (isEnclosed() || isEnclosing())) {
report()
.annotationNamed(ModifiableMirror.simpleName())
.error("@%s could not be used with or within @%s",
ModifiableMirror.simpleName(),
EnclosingMirror.simpleName());
}
}
示例9: isImmutableType
private static boolean isImmutableType(CompilationInfo info, TypeMirror m, Preferences p) {
if (m == null) {
return false;
}
if (m.getKind().isPrimitive() || !isValidType(m)) {
return true;
}
if (Utilities.isPrimitiveWrapperType(m)) {
return true;
}
if (m.getKind() != TypeKind.DECLARED) {
return false;
}
Element e = ((DeclaredType)m).asElement();
if (e == null) {
return false;
}
if (e.getKind() == ElementKind.ENUM) {
return true;
}
if (e.getKind() != ElementKind.CLASS) {
return false;
}
String qn = ((TypeElement)e).getQualifiedName().toString();
if (IMMUTABLE_JDK_CLASSES.contains(qn)) {
return true;
}
List<String> classes = getImmutableTypes(p);
return classes.contains(qn);
}
示例10: 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;
}
示例11: 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;
}
}
示例12: 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;
}
示例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: executeRound
@Override
protected boolean executeRound(Element el, int round) throws Exception {
if (el.getKind() != ElementKind.ENUM) {
return false;
}
ClassTree ct = (ClassTree)path.getLeaf();
for (ListIterator<? extends Tree> it = ct.getMembers().listIterator(ct.getMembers().size()); it.hasPrevious(); ) {
Tree t = it.previous();
if (t.getKind() != Tree.Kind.VARIABLE) {
continue;
}
TreePath p = new TreePath(path, t);
Element e = copy.getTrees().getElement(p);
if (e == null || e.getKind() != ElementKind.ENUM_CONSTANT) {
continue;
}
switch (round) {
case 0:
if (!generateClassBody(p)) {
return false;
}
break;
case 1:
if (!generateImplementation(el, p)) {
return false;
}
break;
default:
throw new IllegalStateException();
}
}
return true;
}
示例15: hasEnumFirstTypeParameter
public boolean hasEnumFirstTypeParameter() {
return typeKind().isEnumKeyed()
&& containedTypeElement.getKind() == ElementKind.ENUM;
}