8282756: Make ElementKind checks more specific
Reviewed-by: jjg
This commit is contained in:
parent
1012d59e64
commit
9d200d6e7a
@ -237,9 +237,8 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter, Membe
|
||||
target.add(resources.getText("doclet.Package_private"));
|
||||
target.add(" ");
|
||||
}
|
||||
boolean isAnnotatedTypeElement = utils.isAnnotationType(member.getEnclosingElement());
|
||||
if (!isAnnotatedTypeElement && utils.isMethod(member)) {
|
||||
if (!utils.isInterface(member.getEnclosingElement()) && utils.isAbstract(member)) {
|
||||
if (!utils.isAnnotationInterface(member.getEnclosingElement()) && utils.isMethod(member)) {
|
||||
if (!utils.isPlainInterface(member.getEnclosingElement()) && utils.isAbstract(member)) {
|
||||
target.add("abstract ");
|
||||
}
|
||||
if (utils.isDefault(member)) {
|
||||
@ -322,15 +321,13 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter, Membe
|
||||
Content typeContent = new ContentBuilder();
|
||||
if (te != null
|
||||
&& !utils.isConstructor(element)
|
||||
&& !utils.isClass(element)
|
||||
&& !utils.isInterface(element)
|
||||
&& !utils.isAnnotationType(element)) {
|
||||
&& !utils.isTypeElement(element)) {
|
||||
var name = new HtmlTree(TagName.SPAN);
|
||||
name.setStyle(HtmlStyle.typeNameLabel);
|
||||
name.add(name(te) + ".");
|
||||
typeContent.add(name);
|
||||
}
|
||||
addSummaryLink(utils.isClass(element) || utils.isInterface(element)
|
||||
addSummaryLink(utils.isClass(element) || utils.isPlainInterface(element)
|
||||
? HtmlLinkInfo.Kind.CLASS_USE
|
||||
: HtmlLinkInfo.Kind.MEMBER,
|
||||
te, element, typeContent);
|
||||
|
@ -117,7 +117,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
|
||||
var sectionHeading = HtmlTree.HEADING_TITLE(Headings.CONTENT_HEADING,
|
||||
headingContent);
|
||||
var section = HtmlTree.SECTION(HtmlStyle.hierarchy, sectionHeading);
|
||||
addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null,
|
||||
addLevelInfo(!utils.isPlainInterface(firstTypeElement) ? firstTypeElement : null,
|
||||
sset, isEnums, section);
|
||||
content.add(section);
|
||||
}
|
||||
@ -137,14 +137,14 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
|
||||
{
|
||||
SortedSet<TypeElement> interfaces = new TreeSet<>(comparators.makeGeneralPurposeComparator());
|
||||
typeElement.getInterfaces().forEach(t -> interfaces.add(utils.asTypeElement(t)));
|
||||
if (interfaces.size() > (utils.isInterface(typeElement) ? 1 : 0)) {
|
||||
if (interfaces.size() > (utils.isPlainInterface(typeElement) ? 1 : 0)) {
|
||||
boolean isFirst = true;
|
||||
for (TypeElement intf : interfaces) {
|
||||
if (parent != intf) {
|
||||
if (utils.isPublic(intf) || utils.isLinkable(intf)) {
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
if (utils.isInterface(typeElement)) {
|
||||
if (utils.isPlainInterface(typeElement)) {
|
||||
content.add(" (");
|
||||
content.add(contents.also);
|
||||
content.add(" extends ");
|
||||
|
@ -116,12 +116,12 @@ public class AllClassesIndexWriter extends HtmlDocletWriter {
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
|
||||
.setId(HtmlIds.ALL_CLASSES_TABLE)
|
||||
.setDefaultTab(contents.allClassesAndInterfacesLabel)
|
||||
.addTab(contents.interfaces, utils::isInterface)
|
||||
.addTab(contents.classes, e -> utils.isOrdinaryClass((TypeElement)e))
|
||||
.addTab(contents.interfaces, utils::isPlainInterface)
|
||||
.addTab(contents.classes, e -> utils.isNonThrowableClass((TypeElement)e))
|
||||
.addTab(contents.enums, utils::isEnum)
|
||||
.addTab(contents.records, e -> utils.isRecord((TypeElement)e))
|
||||
.addTab(contents.exceptionClasses, e -> utils.isThrowable((TypeElement)e))
|
||||
.addTab(contents.annotationTypes, utils::isAnnotationType);
|
||||
.addTab(contents.annotationTypes, utils::isAnnotationInterface);
|
||||
for (Character unicode : indexBuilder.getFirstCharacters()) {
|
||||
for (IndexItem indexItem : indexBuilder.getItems(unicode)) {
|
||||
TypeElement typeElement = (TypeElement) indexItem.getElement();
|
||||
|
@ -269,7 +269,7 @@ public class AnnotationTypeMemberWriterImpl extends AbstractMemberWriter
|
||||
}
|
||||
|
||||
public void addDefaultValueInfo(Element member, Content annotationContent) {
|
||||
if (utils.isAnnotationType(member)) {
|
||||
if (utils.isAnnotationInterface(member.getEnclosingElement())) {
|
||||
ExecutableElement ee = (ExecutableElement) member;
|
||||
AnnotationValue value = ee.getDefaultValue();
|
||||
if (value != null) {
|
||||
|
@ -268,7 +268,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
|
||||
* @param content the content to which the package annotation elements will be added
|
||||
*/
|
||||
protected void addPackageAnnotationList(Content content) {
|
||||
if (!utils.isAnnotationType(typeElement) ||
|
||||
if (!utils.isAnnotationInterface(typeElement) ||
|
||||
pkgToPackageAnnotations == null ||
|
||||
pkgToPackageAnnotations.isEmpty()) {
|
||||
return;
|
||||
|
@ -302,7 +302,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
|
||||
@Override
|
||||
public void addSubInterfacesInfo(Content target) {
|
||||
if (utils.isInterface(typeElement)) {
|
||||
if (utils.isPlainInterface(typeElement)) {
|
||||
Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
|
||||
if (!subInterfaces.isEmpty()) {
|
||||
var dl = HtmlTree.DL(HtmlStyle.notes);
|
||||
@ -315,7 +315,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
|
||||
@Override
|
||||
public void addInterfaceUsageInfo(Content target) {
|
||||
if (!utils.isInterface(typeElement)) {
|
||||
if (!utils.isPlainInterface(typeElement)) {
|
||||
return;
|
||||
}
|
||||
for (String s : suppressImplementingSet) {
|
||||
@ -350,7 +350,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
new TreeSet<>(comparators.makeTypeMirrorIndexUseComparator());
|
||||
interfaces.addAll(utils.getAllInterfaces(typeElement));
|
||||
|
||||
if (utils.isInterface(typeElement) && !interfaces.isEmpty()) {
|
||||
if (utils.isPlainInterface(typeElement) && !interfaces.isEmpty()) {
|
||||
var dl = HtmlTree.DL(HtmlStyle.notes);
|
||||
dl.add(HtmlTree.DT(contents.allSuperinterfacesLabel));
|
||||
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.SUPER_INTERFACES, interfaces)));
|
||||
@ -367,7 +367,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
@Override
|
||||
public Void visitType(TypeElement e, Void p) {
|
||||
var dl = HtmlTree.DL(HtmlStyle.notes);
|
||||
dl.add(HtmlTree.DT(utils.isInterface(e)
|
||||
dl.add(HtmlTree.DT(utils.isPlainInterface(e)
|
||||
? contents.enclosingInterfaceLabel
|
||||
: contents.enclosingClassLabel));
|
||||
dl.add(HtmlTree.DD(getClassLinks(HtmlLinkInfo.Kind.CLASS, List.of(e))));
|
||||
@ -462,7 +462,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
public Content getMemberDetails(Content content) {
|
||||
var section = HtmlTree.SECTION(HtmlStyle.details, content);
|
||||
// The following id is required by the Navigation bar
|
||||
if (utils.isAnnotationType(typeElement)) {
|
||||
if (utils.isAnnotationInterface(typeElement)) {
|
||||
section.setId(HtmlIds.ANNOTATION_TYPE_ELEMENT_DETAIL);
|
||||
}
|
||||
return section;
|
||||
|
@ -325,7 +325,7 @@ public class HtmlDocletWriter {
|
||||
return;
|
||||
}
|
||||
var dl = HtmlTree.DL(HtmlStyle.notes);
|
||||
if (utils.isExecutableElement(e) && !utils.isConstructor(e)) {
|
||||
if (utils.isMethod(e)) {
|
||||
addMethodInfo((ExecutableElement)e, dl);
|
||||
}
|
||||
Content output = getBlockTagOutput(e);
|
||||
|
@ -258,10 +258,10 @@ public class HtmlLinkFactory extends LinkFactory {
|
||||
if (isTypeLink) {
|
||||
return resources.getText("doclet.Href_Type_Param_Title",
|
||||
utils.getSimpleName(typeElement));
|
||||
} else if (utils.isInterface(typeElement)){
|
||||
} else if (utils.isPlainInterface(typeElement)){
|
||||
return resources.getText("doclet.Href_Interface_Title",
|
||||
m_writer.getLocalizedPackageName(utils.containingPackage(typeElement)));
|
||||
} else if (utils.isAnnotationType(typeElement)) {
|
||||
} else if (utils.isAnnotationInterface(typeElement)) {
|
||||
return resources.getText("doclet.Href_Annotation_Title",
|
||||
m_writer.getLocalizedPackageName(utils.containingPackage(typeElement)));
|
||||
} else if (utils.isEnum(typeElement)) {
|
||||
|
@ -330,7 +330,7 @@ public class IndexWriter extends HtmlDocletWriter {
|
||||
case CONSTRUCTOR ->
|
||||
"doclet.Constructor_for";
|
||||
case METHOD ->
|
||||
utils.isAnnotationType(enclosing) ? "doclet.Element_in"
|
||||
utils.isAnnotationInterface(enclosing) ? "doclet.Element_in"
|
||||
: utils.isStatic(member) ? "doclet.Static_method_in" : "doclet.Method_in";
|
||||
case RECORD_COMPONENT ->
|
||||
"doclet.Record_component_in";
|
||||
|
@ -200,7 +200,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
|
||||
.addTab(contents.getContent("doclet.Instance_Methods"), e -> !utils.isStatic(e))
|
||||
.addTab(contents.getContent("doclet.Abstract_Methods"), utils::isAbstract)
|
||||
.addTab(contents.getContent("doclet.Concrete_Methods"),
|
||||
e -> !utils.isAbstract(e) && !utils.isInterface(e.getEnclosingElement()))
|
||||
e -> !utils.isAbstract(e) && !utils.isPlainInterface(e.getEnclosingElement()))
|
||||
.addTab(contents.getContent("doclet.Default_Methods"), utils::isDefault)
|
||||
.addTab(contents.getContent("doclet.Deprecated_Methods"),
|
||||
e -> utils.isDeprecated(e) || utils.isDeprecated(typeElement));
|
||||
|
@ -82,7 +82,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
|
||||
|
||||
@Override
|
||||
public TableHeader getSummaryTableHeader(Element member) {
|
||||
Content label = utils.isInterface(member) ?
|
||||
Content label = utils.isPlainInterface(member) ?
|
||||
contents.interfaceLabel : contents.classLabel;
|
||||
|
||||
return new TableHeader(contents.modifierAndTypeLabel, label, contents.descriptionLabel);
|
||||
@ -104,11 +104,11 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
|
||||
Content classLink = writer.getPreQualifiedClassLink(HtmlLinkInfo.Kind.MEMBER, typeElement);
|
||||
Content label;
|
||||
if (options.summarizeOverriddenMethods()) {
|
||||
label = Text.of(utils.isInterface(typeElement)
|
||||
label = Text.of(utils.isPlainInterface(typeElement)
|
||||
? resources.getText("doclet.Nested_Classes_Interfaces_Declared_In_Interface")
|
||||
: resources.getText("doclet.Nested_Classes_Interfaces_Declared_In_Class"));
|
||||
} else {
|
||||
label = Text.of(utils.isInterface(typeElement)
|
||||
label = Text.of(utils.isPlainInterface(typeElement)
|
||||
? resources.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Interface")
|
||||
: resources.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
|
||||
}
|
||||
|
@ -251,12 +251,12 @@ public class PackageWriterImpl extends HtmlDocletWriter
|
||||
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
|
||||
.setId(HtmlIds.CLASS_SUMMARY)
|
||||
.setDefaultTab(contents.allClassesAndInterfacesLabel)
|
||||
.addTab(contents.interfaces, utils::isInterface)
|
||||
.addTab(contents.classes, e -> utils.isOrdinaryClass((TypeElement)e))
|
||||
.addTab(contents.interfaces, utils::isPlainInterface)
|
||||
.addTab(contents.classes, e -> utils.isNonThrowableClass((TypeElement)e))
|
||||
.addTab(contents.enums, utils::isEnum)
|
||||
.addTab(contents.records, e -> utils.isRecord((TypeElement)e))
|
||||
.addTab(contents.exceptionClasses, e -> utils.isThrowable((TypeElement)e))
|
||||
.addTab(contents.annotationTypes, utils::isAnnotationType);
|
||||
.addTab(contents.annotationTypes, utils::isAnnotationInterface);
|
||||
for (TypeElement typeElement : allClasses) {
|
||||
if (typeElement != null && utils.isCoreClass(typeElement)) {
|
||||
Content classLink = getLink(new HtmlLinkInfo(
|
||||
|
@ -145,10 +145,10 @@ public class Signatures {
|
||||
if (utils.isRecord(typeElement)) {
|
||||
content.add(getRecordComponents());
|
||||
}
|
||||
if (!utils.isAnnotationType(typeElement)) {
|
||||
if (!utils.isAnnotationInterface(typeElement)) {
|
||||
var extendsImplements = new HtmlTree(TagName.SPAN)
|
||||
.setStyle(HtmlStyle.extendsImplements);
|
||||
if (!utils.isInterface(typeElement)) {
|
||||
if (!utils.isPlainInterface(typeElement)) {
|
||||
TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement);
|
||||
if (superclass != null) {
|
||||
content.add(DocletConstants.NL);
|
||||
@ -169,7 +169,7 @@ public class Signatures {
|
||||
}
|
||||
if (isFirst) {
|
||||
extendsImplements.add(DocletConstants.NL);
|
||||
extendsImplements.add(utils.isInterface(typeElement) ? "extends " : "implements ");
|
||||
extendsImplements.add(utils.isPlainInterface(typeElement) ? "extends " : "implements ");
|
||||
isFirst = false;
|
||||
} else {
|
||||
extendsImplements.add(", ");
|
||||
@ -507,7 +507,7 @@ public class Signatures {
|
||||
// interface methods and fields.
|
||||
if ((utils.isField(element) || utils.isMethod(element))) {
|
||||
Element te = element.getEnclosingElement();
|
||||
if (utils.isInterface(te) || utils.isAnnotationType(te)) {
|
||||
if (utils.isInterface(te)) {
|
||||
// Remove the implicit abstract and public modifiers
|
||||
if (utils.isMethod(element)) {
|
||||
set.remove(ABSTRACT);
|
||||
|
@ -266,7 +266,7 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
|
||||
configuration.cmtUtils.updatePropertyMethodComment(ee, property);
|
||||
}
|
||||
List<? extends DocTree> firstSentenceTags = utils.getFirstSentenceTrees(member);
|
||||
if (utils.isExecutableElement(member) && firstSentenceTags.isEmpty()) {
|
||||
if (utils.isMethod(member) && firstSentenceTags.isEmpty()) {
|
||||
//Inherit comments from overridden or implemented method if
|
||||
//necessary.
|
||||
DocFinder.Output inheritedDoc =
|
||||
|
@ -169,6 +169,7 @@ public class MethodBuilder extends AbstractMemberBuilder {
|
||||
*/
|
||||
protected void buildMethodComments(Content methodContent) {
|
||||
if (!options.noComment()) {
|
||||
assert utils.isMethod(currentMethod); // not all executables are methods
|
||||
ExecutableElement method = currentMethod;
|
||||
if (utils.getFullBody(currentMethod).isEmpty()) {
|
||||
DocFinder.Output docs = DocFinder.search(configuration,
|
||||
|
@ -243,7 +243,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
|
||||
if (dt != null) {
|
||||
result.add(processParamTag(e, kind, writer, dt,
|
||||
ch.getParameterName(dt), result.isEmpty()));
|
||||
} else if (writer.configuration().utils.isExecutableElement(e)) {
|
||||
} else if (writer.configuration().utils.isMethod(e)) {
|
||||
result.add(getInheritedTagletOutput(kind, e, writer,
|
||||
formalParameters.get(i), i, result.isEmpty()));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -71,7 +71,7 @@ public class SeeTaglet extends BaseTaglet implements InheritableTaglet {
|
||||
Utils utils = writer.configuration().utils;
|
||||
List<? extends SeeTree> tags = utils.getSeeTrees(holder);
|
||||
Element e = holder;
|
||||
if (tags.isEmpty() && utils.isExecutableElement(holder)) {
|
||||
if (tags.isEmpty() && utils.isMethod(holder)) {
|
||||
Input input = new DocFinder.Input(utils, holder, this);
|
||||
DocFinder.Output inheritedDoc = DocFinder.search(writer.configuration(), input);
|
||||
if (inheritedDoc.holder != null) {
|
||||
|
@ -130,7 +130,7 @@ public class ThrowsTaglet extends BaseTaglet
|
||||
Map<String, TypeMirror> typeSubstitutions, TagletWriter writer) {
|
||||
Utils utils = writer.configuration().utils;
|
||||
Content result = writer.getOutputInstance();
|
||||
if (utils.isExecutableElement(holder)) {
|
||||
if (utils.isMethod(holder)) {
|
||||
Map<List<? extends ThrowsTree>, ExecutableElement> declaredExceptionTags = new LinkedHashMap<>();
|
||||
for (TypeMirror declaredExceptionType : declaredExceptionTypes) {
|
||||
Input input = new DocFinder.Input(utils, holder, this,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -180,9 +180,9 @@ public class ClassTree {
|
||||
processType(aClass, configuration, baseEnums, subEnums);
|
||||
} else if (utils.isClass(aClass)) {
|
||||
processType(aClass, configuration, baseClasses, subClasses);
|
||||
} else if (utils.isInterface(aClass)) {
|
||||
} else if (utils.isPlainInterface(aClass)) {
|
||||
processInterface(aClass);
|
||||
} else if (utils.isAnnotationType(aClass)) {
|
||||
} else if (utils.isAnnotationInterface(aClass)) {
|
||||
processType(aClass, configuration, baseAnnotationTypes,
|
||||
subAnnotationTypes);
|
||||
}
|
||||
@ -336,9 +336,9 @@ public class ClassTree {
|
||||
private SortedSet<TypeElement> directSubClasses0(TypeElement typeElement, boolean isEnum) {
|
||||
if (isEnum) {
|
||||
return get(subEnums, typeElement);
|
||||
} else if (utils.isAnnotationType(typeElement)) {
|
||||
} else if (utils.isAnnotationInterface(typeElement)) {
|
||||
return get(subAnnotationTypes, typeElement);
|
||||
} else if (utils.isInterface(typeElement)) {
|
||||
} else if (utils.isPlainInterface(typeElement)) {
|
||||
return get(subInterfaces, typeElement);
|
||||
} else if (utils.isClass(typeElement)) {
|
||||
return get(subClasses, typeElement);
|
||||
|
@ -93,7 +93,7 @@ public class MetaKeywords {
|
||||
*/
|
||||
protected List<String> getClassKeyword(TypeElement typeElement) {
|
||||
ArrayList<String> metakeywords = new ArrayList<>(1);
|
||||
String cltypelower = utils.isInterface(typeElement) ? "interface" : "class";
|
||||
String cltypelower = utils.isPlainInterface(typeElement) ? "interface" : "class";
|
||||
metakeywords.add(utils.getFullyQualifiedName(typeElement) + " " + cltypelower);
|
||||
return metakeywords;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -161,7 +161,7 @@ public class SummaryAPIListBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (utils.isAnnotationType(te)) {
|
||||
if (utils.isAnnotationInterface(te)) {
|
||||
composeSummaryList(summaryMap.get(SummaryElementKind.ANNOTATION_TYPE_MEMBER),
|
||||
utils.getAnnotationMembers(te));
|
||||
|
||||
|
@ -52,7 +52,6 @@ import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.lang.model.AnnotatedConstruct;
|
||||
import javax.lang.model.SourceVersion;
|
||||
@ -73,7 +72,6 @@ import javax.lang.model.type.ArrayType;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.ErrorType;
|
||||
import javax.lang.model.type.ExecutableType;
|
||||
import javax.lang.model.type.NoType;
|
||||
import javax.lang.model.type.PrimitiveType;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.type.TypeVariable;
|
||||
@ -284,35 +282,21 @@ public class Utils {
|
||||
return !e.getAnnotationMirrors().isEmpty();
|
||||
}
|
||||
|
||||
public boolean isAnnotationType(Element e) {
|
||||
return new SimpleElementVisitor14<Boolean, Void>() {
|
||||
@Override
|
||||
public Boolean visitExecutable(ExecutableElement e, Void p) {
|
||||
return visit(e.getEnclosingElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visitUnknown(Element e, Void p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean defaultAction(Element e, Void p) {
|
||||
return e.getKind() == ANNOTATION_TYPE;
|
||||
}
|
||||
}.visit(e);
|
||||
public boolean isAnnotationInterface(Element e) {
|
||||
return e.getKind() == ANNOTATION_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* An Enum implementation is almost identical, thus this method returns if
|
||||
* this element represents a CLASS or an ENUM
|
||||
* @param e element
|
||||
* @return true if class or enum
|
||||
*/
|
||||
// Note that e.getKind().isClass() is not the same as e.getKind() == CLASS
|
||||
public boolean isClass(Element e) {
|
||||
return e.getKind().isClass();
|
||||
}
|
||||
|
||||
// Note that e.getKind().isInterface() is not the same as e.getKind() == INTERFACE
|
||||
// See Also: isPlainInterface(Element)
|
||||
public boolean isInterface(Element e) {
|
||||
return e.getKind().isInterface();
|
||||
}
|
||||
|
||||
public boolean isConstructor(Element e) {
|
||||
return e.getKind() == CONSTRUCTOR;
|
||||
}
|
||||
@ -325,7 +309,7 @@ public class Utils {
|
||||
return e.getKind() == FIELD;
|
||||
}
|
||||
|
||||
public boolean isInterface(Element e) {
|
||||
public boolean isPlainInterface(Element e) {
|
||||
return e.getKind() == INTERFACE;
|
||||
}
|
||||
|
||||
@ -447,46 +431,30 @@ public class Utils {
|
||||
return t.getKind() == NONE;
|
||||
}
|
||||
|
||||
public boolean isOrdinaryClass(TypeElement te) {
|
||||
if (isEnum(te) || isInterface(te) || isAnnotationType(te) || isRecord(te)) {
|
||||
return false;
|
||||
}
|
||||
return !isThrowable(te);
|
||||
}
|
||||
|
||||
public boolean isUndocumentedEnclosure(TypeElement enclosingTypeElement) {
|
||||
return (isPackagePrivate(enclosingTypeElement) || isPrivate(enclosingTypeElement)
|
||||
|| hasHiddenTag(enclosingTypeElement))
|
||||
&& !isLinkable(enclosingTypeElement);
|
||||
}
|
||||
|
||||
public boolean isNonThrowableClass(TypeElement te) {
|
||||
return te.getKind() == CLASS && !isThrowable(te);
|
||||
}
|
||||
|
||||
public boolean isThrowable(TypeElement te) {
|
||||
if (isEnum(te) || isInterface(te) || isAnnotationType(te)) {
|
||||
return false;
|
||||
}
|
||||
return typeUtils.isSubtype(te.asType(), getThrowableType());
|
||||
return te.getKind() == CLASS && typeUtils.isSubtype(te.asType(), getThrowableType());
|
||||
}
|
||||
|
||||
public boolean isExecutableElement(Element e) {
|
||||
return switch (e.getKind()) {
|
||||
case CONSTRUCTOR, METHOD, INSTANCE_INIT -> true;
|
||||
default -> false;
|
||||
};
|
||||
return e.getKind().isExecutable();
|
||||
}
|
||||
|
||||
public boolean isVariableElement(Element e) {
|
||||
return switch (e.getKind()) {
|
||||
case ENUM_CONSTANT, EXCEPTION_PARAMETER, FIELD, LOCAL_VARIABLE,
|
||||
PARAMETER, RESOURCE_VARIABLE -> true;
|
||||
default -> false;
|
||||
};
|
||||
return e.getKind().isVariable();
|
||||
}
|
||||
|
||||
public boolean isTypeElement(Element e) {
|
||||
return switch (e.getKind()) {
|
||||
case CLASS, ENUM, INTERFACE, ANNOTATION_TYPE, RECORD -> true;
|
||||
default -> false;
|
||||
};
|
||||
return e.getKind().isDeclaredType();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -869,7 +837,7 @@ public class Utils {
|
||||
if (typeUtils.isSameType(t, getObjectType()))
|
||||
continue;
|
||||
TypeElement e = asTypeElement(t);
|
||||
if (isInterface(e)) {
|
||||
if (isPlainInterface(e)) {
|
||||
if (!visited.add(e)) {
|
||||
continue; // seen it before
|
||||
}
|
||||
@ -1127,8 +1095,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
private boolean checkType(TypeElement te) {
|
||||
return isInterface(te) || typeUtils.isSameType(te.asType(), getObjectType())
|
||||
|| isAnnotationType(te);
|
||||
return isInterface(te) || typeUtils.isSameType(te.asType(), getObjectType());
|
||||
}
|
||||
|
||||
public TypeElement getFirstVisibleSuperClassAsTypeElement(TypeElement te) {
|
||||
|
@ -407,8 +407,8 @@ public class VisibleMemberTable {
|
||||
}
|
||||
|
||||
private void computeParents() {
|
||||
// suppress parents of annotation types
|
||||
if (utils.isAnnotationType(te)) {
|
||||
// suppress parents of annotation interfaces
|
||||
if (utils.isAnnotationInterface(te)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -577,7 +577,7 @@ public class VisibleMemberTable {
|
||||
|
||||
boolean isEnclosureInterface(Element e) {
|
||||
TypeElement enclosing = utils.getEnclosingTypeElement(e);
|
||||
return utils.isInterface(enclosing);
|
||||
return utils.isPlainInterface(enclosing);
|
||||
}
|
||||
|
||||
boolean allowInheritedMethod(ExecutableElement inheritedMethod,
|
||||
@ -777,7 +777,7 @@ public class VisibleMemberTable {
|
||||
addMember(e, Kind.FIELDS);
|
||||
break;
|
||||
case METHOD:
|
||||
if (utils.isAnnotationType(te)) {
|
||||
if (utils.isAnnotationInterface(te)) {
|
||||
ExecutableElement ee = (ExecutableElement) e;
|
||||
addMember(e, Kind.ANNOTATION_TYPE_MEMBER);
|
||||
addMember(e, ee.getDefaultValue() == null
|
||||
|
Loading…
Reference in New Issue
Block a user