本文整理汇总了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;
}
示例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 ();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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 ();
}
}
示例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 ();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例14: moduleElementConvertor
@NonNull
public static Convertor<Document,ElementHandle<ModuleElement>> moduleElementConvertor() {
return new ElementHandleConvertor<>(ElementKind.MODULE);
}
示例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;
}