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


Java ElementKind.MODULE屬性代碼示例

本文整理匯總了Java中javax.lang.model.element.ElementKind.MODULE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ElementKind.MODULE屬性的具體用法?Java ElementKind.MODULE怎麽用?Java ElementKind.MODULE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.MODULE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getContainingClassOrPackageHeader

private StringBuilder getContainingClassOrPackageHeader(Element el, Elements elements, ElementUtilities eu) {
    StringBuilder sb = new StringBuilder();
    if (el.getKind() != ElementKind.PACKAGE && el.getKind() != ElementKind.MODULE) {
        TypeElement cls = eu.enclosingTypeElement(el);
        if (cls != null) {
            switch(cls.getEnclosingElement().getKind()) {
                case ANNOTATION_TYPE:
                case CLASS:
                case ENUM:
                case INTERFACE:
                case PACKAGE:
                    sb.append("<font size='+0'><b>"); //NOI18N
                    createLink(sb, cls, makeNameLineBreakable(cls.getQualifiedName().toString()));
                    sb.append("</b></font>"); //NOI18N)
            }
        } else {
            PackageElement pkg = elements.getPackageOf(el);
            if (pkg != null) {
                sb.append("<font size='+0'><b>"); //NOI18N
                createLink(sb, pkg, makeNameLineBreakable(pkg.getQualifiedName().toString()));
                sb.append("</b></font>"); //NOI18N)
            }
        }
    }
    return sb;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ElementJavadoc.java

示例2: 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

示例3: isErroneous

/**
 * Checks whether 'e' contains error or is missing. If the passed element is null
 * it's assumed the element could not be resolved and this method returns true. Otherwise,
 * the element's type kind is checked against error constants and finally the erroneous
 * state of the element is checked. 
 * 
 * @param e Element to check or {@code null}
 * @return true, if the element is missing (is {@code null}) or contains errors.
 */
public boolean isErroneous(@NullAllowed Element e) {
    if (e == null) {
        return true;
    }
    if (e.getKind() == ElementKind.MODULE && ((Symbol)e).kind == Kinds.Kind.ERR) {
        return true;
    }
    final TypeMirror type = e.asType();
    if (type == null) {
        return false;
    }
    if (type.getKind() == TypeKind.ERROR || type.getKind() == TypeKind.OTHER) {
        return true;
    }
    if (type instanceof Type) {
        if (((Type)type).isErroneous()) {
            return true;
        }
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:ElementUtilities.java

示例4: findNode

@CheckForNull
@Override
public Node findNode(@NonNull final Point loc) {
    final TreePath path = tree.getPathForLocation( loc.x, loc.y );
    if( null == path ) {
        return null;
    }
    final Node node = Visualizer.findNode( path.getLastPathComponent());
    if (!(node instanceof ElementNode)) {
        return null;
    }
    final ElementNode enode = (ElementNode) node;
    final ElementNode.Description desc = enode.getDescritption();
    //Other and module do not have javadoc
    return desc.kind != ElementKind.OTHER
        && desc.kind != ElementKind.MODULE ?
            node :
            null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ClassMemberPanelUI.java

示例5: setCurrent

/** Set the current declaration and its doc comment. */
void setCurrent(TreePath path, DocCommentTree comment) {
    currPath = path;
    currDocComment = comment;
    currElement = trees.getElement(currPath);
    currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);

    AccessKind ak = AccessKind.PUBLIC;
    for (TreePath p = path; p != null; p = p.getParentPath()) {
        Element e = trees.getElement(p);
        if (e != null && e.getKind() != ElementKind.PACKAGE && e.getKind() != ElementKind.MODULE) {
            ak = min(ak, AccessKind.of(e.getModifiers()));
        }
    }
    currAccess = ak;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Env.java

示例6: convert

@Override
public FileObject convert (final Document doc) {
    final String binaryName = getBinaryName(doc, kindHolder);            
    return binaryName == null ?
            null :
            kindHolder[0] == ElementKind.MODULE ?
                resolveFile(FileObjects.MODULE_INFO) :
                convertType(binaryName);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:DocumentUtil.java

示例7: 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

示例8: getBinaryName

/**
 * Returns a binary name of the {@link TypeElement} represented by this
 * {@link ElementHandle}. When the {@link ElementHandle} doesn't represent
 * a {@link TypeElement} it throws a {@link IllegalStateException}
 * @return the qualified name
 * @throws an {@link IllegalStateException} when this {@link ElementHandle} 
 * isn't created for the {@link TypeElement}.
 */
public @NonNull String getBinaryName () throws IllegalStateException {
    if ((this.kind.isClass() && !isArray(signatures[0])) ||
            this.kind.isInterface() ||
            this.kind == ElementKind.MODULE ||
            this.kind == ElementKind.OTHER) {
        return this.signatures[0];
    }
    else {
        throw new IllegalStateException ();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ElementHandle.java

示例9: getQualifiedName

/**
 * Returns a qualified name of the {@link TypeElement} represented by this
 * {@link ElementHandle}. When the {@link ElementHandle} doesn't represent
 * a {@link TypeElement} it throws a {@link IllegalStateException}
 * @return the qualified name
 * @throws an {@link IllegalStateException} when this {@link ElementHandle} 
 * isn't creatred for the {@link TypeElement}.
 */
public @NonNull String getQualifiedName () throws IllegalStateException {
    if ((this.kind.isClass() && !isArray(signatures[0])) ||
            this.kind.isInterface() ||
            this.kind == ElementKind.MODULE ||
            this.kind == ElementKind.OTHER) {
        return this.signatures[0].replace (Target.DEFAULT.syntheticNameChar(),'.');    //NOI18N
    }
    else {
        throw new IllegalStateException ();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ElementHandle.java

示例10: createModuleElementHandle

/**
 * Creates an {@link ElementHandle} representing a {@link ModuleElement}.
 * @param moduleName the name of the module
 * @return the created {@link ElementHandle}
 * @since 2.26
 */
@NonNull
public static ElementHandle<ModuleElement> createModuleElementHandle(
        @NonNull final String moduleName) {
    Parameters.notNull("moduleName", moduleName); //NOI18N
    return new ElementHandle<>(ElementKind.MODULE, moduleName);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:ElementHandle.java

示例11: isErroneous

public boolean isErroneous(@NullAllowed Element e) {
    if (e == null) {
        return true;
    }
    if (e.getKind() == ElementKind.MODULE) {
        return false;
    }
    final TypeMirror type = e.asType();
    if (type == null) {
        return false;
    }
    return type.getKind() == TypeKind.ERROR || type.getKind() == TypeKind.OTHER;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:UnusedImports.java

示例12: visitProvides

@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitProvides(ProvidesTree tree, Void ignore) {
    Element e = env.trees.getElement(env.currPath);
    if (e.getKind() != ElementKind.MODULE) {
        env.messages.error(REFERENCE, tree, "dc.invalid.provides");
    }
    ReferenceTree serviceType = tree.getServiceType();
    Element se = env.trees.getElement(new DocTreePath(getCurrentPath(), serviceType));
    if (se == null) {
        env.messages.error(REFERENCE, tree, "dc.service.not.found");
    }
    return super.visitProvides(tree, ignore);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:Checker.java

示例13: visitUses

@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitUses(UsesTree tree, Void ignore) {
    Element e = env.trees.getElement(env.currPath);
    if (e.getKind() != ElementKind.MODULE) {
        env.messages.error(REFERENCE, tree, "dc.invalid.uses");
    }
    ReferenceTree serviceType = tree.getServiceType();
    Element se = env.trees.getElement(new DocTreePath(getCurrentPath(), serviceType));
    if (se == null) {
        env.messages.error(REFERENCE, tree, "dc.service.not.found");
    }
    return super.visitUses(tree, ignore);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:Checker.java

示例14: moduleElementConvertor

@NonNull
public static Convertor<Document,ElementHandle<ModuleElement>> moduleElementConvertor() {
    return new ElementHandleConvertor<>(ElementKind.MODULE);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:DocumentUtil.java

示例15: visitMemberSelect

@Override
        public Void visitMemberSelect(MemberSelectTree tree, EnumSet<UseTypes> d) {
            long memberSelectBypassLoc = memberSelectBypass;
            
            memberSelectBypass = -1;
            
            Element el = info.getTrees().getElement(getCurrentPath());
            
            if (el != null && el.getKind() == ElementKind.MODULE) {
                handlePossibleIdentifier(getCurrentPath(), EnumSet.of(UseTypes.MODULE_USE));
                tl.moduleNameHere(tree, tree2Tokens);
                return null;
            }

            Tree expr = tree.getExpression();
            
            if (expr instanceof IdentifierTree) {
                TreePath tp = new TreePath(getCurrentPath(), expr);
                handlePossibleIdentifier(tp, EnumSet.of(UseTypes.READ));
            }
            
            if (el != null && el.getKind().isField()) {
                handlePossibleIdentifier(getCurrentPath(), d == null ? EnumSet.of(UseTypes.READ) : d);
            }
	    
	    if (el != null && (el.getKind().isClass() || el.getKind().isInterface()) && 
		    getCurrentPath().getParentPath().getLeaf().getKind() != Kind.NEW_CLASS) {
		handlePossibleIdentifier(getCurrentPath(), EnumSet.of(UseTypes.CLASS_USE));
	    }
	    
//            System.err.println("XXXX=" + tree.toString());
//            System.err.println("YYYY=" + info.getElement(tree));
            
            super.visitMemberSelect(tree, d);
            
            tl.moveToEnd(tree.getExpression());
            
            if (memberSelectBypassLoc != (-1)) {
                tl.moveToOffset(memberSelectBypassLoc);
            }
            
            firstIdentifier(tree.getIdentifier().toString());
            
            return null;
        }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:45,代碼來源:SemanticHighlighterBase.java


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