當前位置: 首頁>>代碼示例>>Java>>正文


Java ElementKind.ENUM屬性代碼示例

本文整理匯總了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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:Mirrors.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:ValueAttribute.java

示例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 ();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:DocumentUtil.java

示例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();
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ElementGrip.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ClassCompleter.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:EnumValueCompleter.java

示例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()));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:NPECheck.java

示例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());
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:33,代碼來源:Proto.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:ConstantNameHint.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:Symbol.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:BinaryAnalyser.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CodeStyle.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:CreateElement.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:ImplementAllAbstractMethods.java

示例15: hasEnumFirstTypeParameter

public boolean hasEnumFirstTypeParameter() {
  return typeKind().isEnumKeyed()
      && containedTypeElement.getKind() == ElementKind.ENUM;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:ValueAttribute.java


注:本文中的javax.lang.model.element.ElementKind.ENUM屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。