8282582: Unused methods in Utils
Reviewed-by: prappo
This commit is contained in:
parent
5c187e34a5
commit
57020fd582
@ -184,14 +184,6 @@ public class Utils {
|
||||
return getSymbol("java.io.Externalizable");
|
||||
}
|
||||
|
||||
public TypeMirror getIllegalArgumentExceptionType() {
|
||||
return getSymbol("java.lang.IllegalArgumentException");
|
||||
}
|
||||
|
||||
public TypeMirror getNullPointerExceptionType() {
|
||||
return getSymbol("java.lang.NullPointerException");
|
||||
}
|
||||
|
||||
public TypeMirror getDeprecatedType() {
|
||||
return getSymbol("java.lang.Deprecated");
|
||||
}
|
||||
@ -200,22 +192,6 @@ public class Utils {
|
||||
return getSymbol("java.lang.FunctionalInterface");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of class members whose documentation is to be generated.
|
||||
* If the member is deprecated do not include such a member in the
|
||||
* returned array.
|
||||
*
|
||||
* @param members Array of members to choose from.
|
||||
* @return List List of eligible members for whom
|
||||
* documentation is getting generated.
|
||||
*/
|
||||
public List<Element> excludeDeprecatedMembers(List<? extends Element> members) {
|
||||
return members.stream()
|
||||
.filter(member -> !isDeprecated(member))
|
||||
.sorted(comparators.makeGeneralPurposeComparator())
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the given method in the given class.
|
||||
*
|
||||
@ -309,10 +285,6 @@ public class Utils {
|
||||
return !e.getAnnotationMirrors().isEmpty();
|
||||
}
|
||||
|
||||
public boolean isAnnotated(Element e) {
|
||||
return !e.getAnnotationMirrors().isEmpty();
|
||||
}
|
||||
|
||||
public boolean isAnnotationType(Element e) {
|
||||
return new SimpleElementVisitor14<Boolean, Void>() {
|
||||
@Override
|
||||
@ -350,10 +322,6 @@ public class Utils {
|
||||
return e.getKind() == ENUM;
|
||||
}
|
||||
|
||||
boolean isEnumConstant(Element e) {
|
||||
return e.getKind() == ENUM_CONSTANT;
|
||||
}
|
||||
|
||||
public boolean isField(Element e) {
|
||||
return e.getKind() == FIELD;
|
||||
}
|
||||
@ -500,28 +468,6 @@ public class Utils {
|
||||
return typeUtils.isSubtype(te.asType(), getThrowableType());
|
||||
}
|
||||
|
||||
public boolean isPrimitive(TypeMirror t) {
|
||||
return new SimpleTypeVisitor14<Boolean, Void>() {
|
||||
|
||||
@Override
|
||||
public Boolean visitNoType(NoType t, Void p) {
|
||||
return t.getKind() == VOID;
|
||||
}
|
||||
@Override
|
||||
public Boolean visitPrimitive(PrimitiveType t, Void p) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Boolean visitArray(ArrayType t, Void p) {
|
||||
return visit(t.getComponentType());
|
||||
}
|
||||
@Override
|
||||
protected Boolean defaultAction(TypeMirror e, Void p) {
|
||||
return false;
|
||||
}
|
||||
}.visit(t);
|
||||
}
|
||||
|
||||
public boolean isExecutableElement(Element e) {
|
||||
return switch (e.getKind()) {
|
||||
case CONSTRUCTOR, METHOD, INSTANCE_INIT -> true;
|
||||
@ -673,14 +619,6 @@ public class Utils {
|
||||
return t.getKind() == DECLARED;
|
||||
}
|
||||
|
||||
public boolean isErrorType(TypeMirror t) {
|
||||
return t.getKind() == ERROR;
|
||||
}
|
||||
|
||||
public boolean isIntersectionType(TypeMirror t) {
|
||||
return t.getKind() == INTERSECTION;
|
||||
}
|
||||
|
||||
public boolean isTypeParameterElement(Element e) {
|
||||
return e.getKind() == TYPE_PARAMETER;
|
||||
}
|
||||
@ -693,10 +631,6 @@ public class Utils {
|
||||
return t.getKind() == VOID;
|
||||
}
|
||||
|
||||
public boolean isWildCard(TypeMirror t) {
|
||||
return t.getKind() == WILDCARD;
|
||||
}
|
||||
|
||||
public boolean ignoreBounds(TypeMirror bound) {
|
||||
return typeUtils.isSameType(bound, getObjectType()) && !isAnnotated(bound);
|
||||
}
|
||||
@ -789,20 +723,6 @@ public class Utils {
|
||||
return getType(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class that originally defined the method that
|
||||
* is overridden by the current definition, or null if no
|
||||
* such class exists.
|
||||
*
|
||||
* @return a TypeElement representing the superclass that
|
||||
* originally defined this method, or null if this method does
|
||||
* not override a definition in a superclass.
|
||||
*/
|
||||
public TypeElement overriddenClass(ExecutableElement ee) {
|
||||
TypeMirror type = overriddenType(ee);
|
||||
return (type != null) ? asTypeElement(type) : null;
|
||||
}
|
||||
|
||||
public ExecutableElement overriddenMethod(ExecutableElement method) {
|
||||
if (isStatic(method)) {
|
||||
return null;
|
||||
@ -985,13 +905,6 @@ public class Utils {
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enclose in quotes, used for paths and filenames that contains spaces
|
||||
*/
|
||||
public String quote(String filepath) {
|
||||
return ("\"" + filepath + "\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the package name. We only want to display package name up to
|
||||
* 2 levels.
|
||||
@ -1558,19 +1471,6 @@ public class Utils {
|
||||
return compareStrings(true, s1, s2);
|
||||
}
|
||||
|
||||
/**
|
||||
* A general purpose case sensitive String comparator, which
|
||||
* compares two Strings using a Collator strength of "SECONDARY".
|
||||
*
|
||||
* @param s1 first String to compare.
|
||||
* @param s2 second String to compare.
|
||||
* @return a negative integer, zero, or a positive integer as the first
|
||||
* argument is less than, equal to, or greater than the second.
|
||||
*/
|
||||
public int compareCaseCompare(String s1, String s2) {
|
||||
return compareStrings(false, s1, s2);
|
||||
}
|
||||
|
||||
private DocCollator tertiaryCollator = null;
|
||||
private DocCollator secondaryCollator = null;
|
||||
|
||||
@ -1762,26 +1662,6 @@ public class Utils {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the documented annotation interfaces in a package.
|
||||
*
|
||||
* @param pkg the package
|
||||
* @return the annotation interfaces
|
||||
*/
|
||||
public List<TypeElement> getAnnotationTypes(PackageElement pkg) {
|
||||
return getDocumentedItems(pkg, ANNOTATION_TYPE, TypeElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the documented record classes in a package.
|
||||
*
|
||||
* @param pkg the package
|
||||
* @return the record classes
|
||||
*/
|
||||
public List<TypeElement> getRecords(PackageElement pkg) {
|
||||
return getDocumentedItems(pkg, RECORD, TypeElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the documented fields in a type element.
|
||||
*
|
||||
@ -1834,13 +1714,6 @@ public class Utils {
|
||||
return getDocumentedItems(te, METHOD, ExecutableElement.class);
|
||||
}
|
||||
|
||||
public int getOrdinalValue(VariableElement member) {
|
||||
if (member == null || member.getKind() != ENUM_CONSTANT) {
|
||||
throw new IllegalArgumentException("must be an enum constant: " + member);
|
||||
}
|
||||
return member.getEnclosingElement().getEnclosedElements().indexOf(member);
|
||||
}
|
||||
|
||||
private Map<ModuleElement, Set<PackageElement>> modulePackageMap = null;
|
||||
public Map<ModuleElement, Set<PackageElement>> getModulePackageMap() {
|
||||
if (modulePackageMap == null) {
|
||||
@ -1912,16 +1785,6 @@ public class Utils {
|
||||
return lineMap.getLineNumber(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the documented interfaces in a package.
|
||||
*
|
||||
* @param pkg the package
|
||||
* @return the interfaces
|
||||
*/
|
||||
public List<TypeElement> getInterfaces(PackageElement pkg) {
|
||||
return getDocumentedItems(pkg, INTERFACE, TypeElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the documented enum constants in a type element.
|
||||
*
|
||||
@ -1932,16 +1795,6 @@ public class Utils {
|
||||
return getDocumentedItems(te, ENUM_CONSTANT, VariableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the documented enum classes in a package.
|
||||
*
|
||||
* @param pkg the package
|
||||
* @return the interfaces
|
||||
*/
|
||||
public List<TypeElement> getEnums(PackageElement pkg) {
|
||||
return getDocumentedItems(pkg, ENUM, TypeElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the classes in a package.
|
||||
*
|
||||
@ -2343,102 +2196,6 @@ public class Utils {
|
||||
return mdle.getQualifiedName().toString();
|
||||
}
|
||||
|
||||
public boolean isAttribute(DocTree doctree) {
|
||||
return isKind(doctree, ATTRIBUTE);
|
||||
}
|
||||
|
||||
public boolean isAuthor(DocTree doctree) {
|
||||
return isKind(doctree, AUTHOR);
|
||||
}
|
||||
|
||||
public boolean isComment(DocTree doctree) {
|
||||
return isKind(doctree, COMMENT);
|
||||
}
|
||||
|
||||
public boolean isDeprecated(DocTree doctree) {
|
||||
return isKind(doctree, DEPRECATED);
|
||||
}
|
||||
|
||||
public boolean isDocComment(DocTree doctree) {
|
||||
return isKind(doctree, DOC_COMMENT);
|
||||
}
|
||||
|
||||
public boolean isDocRoot(DocTree doctree) {
|
||||
return isKind(doctree, DOC_ROOT);
|
||||
}
|
||||
|
||||
public boolean isEndElement(DocTree doctree) {
|
||||
return isKind(doctree, END_ELEMENT);
|
||||
}
|
||||
|
||||
public boolean isEntity(DocTree doctree) {
|
||||
return isKind(doctree, ENTITY);
|
||||
}
|
||||
|
||||
public boolean isErroneous(DocTree doctree) {
|
||||
return isKind(doctree, ERRONEOUS);
|
||||
}
|
||||
|
||||
public boolean isException(DocTree doctree) {
|
||||
return isKind(doctree, EXCEPTION);
|
||||
}
|
||||
|
||||
public boolean isIdentifier(DocTree doctree) {
|
||||
return isKind(doctree, IDENTIFIER);
|
||||
}
|
||||
|
||||
public boolean isInheritDoc(DocTree doctree) {
|
||||
return isKind(doctree, INHERIT_DOC);
|
||||
}
|
||||
|
||||
public boolean isLink(DocTree doctree) {
|
||||
return isKind(doctree, LINK);
|
||||
}
|
||||
|
||||
public boolean isLinkPlain(DocTree doctree) {
|
||||
return isKind(doctree, LINK_PLAIN);
|
||||
}
|
||||
|
||||
public boolean isLiteral(DocTree doctree) {
|
||||
return isKind(doctree, LITERAL);
|
||||
}
|
||||
|
||||
public boolean isOther(DocTree doctree) {
|
||||
return doctree.getKind() == DocTree.Kind.OTHER;
|
||||
}
|
||||
|
||||
public boolean isParam(DocTree doctree) {
|
||||
return isKind(doctree, PARAM);
|
||||
}
|
||||
|
||||
public boolean isReference(DocTree doctree) {
|
||||
return isKind(doctree, REFERENCE);
|
||||
}
|
||||
|
||||
public boolean isReturn(DocTree doctree) {
|
||||
return isKind(doctree, RETURN);
|
||||
}
|
||||
|
||||
public boolean isSee(DocTree doctree) {
|
||||
return isKind(doctree, SEE);
|
||||
}
|
||||
|
||||
public boolean isSerial(DocTree doctree) {
|
||||
return isKind(doctree, SERIAL);
|
||||
}
|
||||
|
||||
public boolean isSerialData(DocTree doctree) {
|
||||
return isKind(doctree, SERIAL_DATA);
|
||||
}
|
||||
|
||||
public boolean isSerialField(DocTree doctree) {
|
||||
return isKind(doctree, SERIAL_FIELD);
|
||||
}
|
||||
|
||||
public boolean isSince(DocTree doctree) {
|
||||
return isKind(doctree, SINCE);
|
||||
}
|
||||
|
||||
public boolean isStartElement(DocTree doctree) {
|
||||
return isKind(doctree, START_ELEMENT);
|
||||
}
|
||||
@ -2447,26 +2204,6 @@ public class Utils {
|
||||
return isKind(doctree, TEXT);
|
||||
}
|
||||
|
||||
public boolean isThrows(DocTree doctree) {
|
||||
return isKind(doctree, THROWS);
|
||||
}
|
||||
|
||||
public boolean isUnknownBlockTag(DocTree doctree) {
|
||||
return isKind(doctree, UNKNOWN_BLOCK_TAG);
|
||||
}
|
||||
|
||||
public boolean isUnknownInlineTag(DocTree doctree) {
|
||||
return isKind(doctree, UNKNOWN_INLINE_TAG);
|
||||
}
|
||||
|
||||
public boolean isValue(DocTree doctree) {
|
||||
return isKind(doctree, VALUE);
|
||||
}
|
||||
|
||||
public boolean isVersion(DocTree doctree) {
|
||||
return isKind(doctree, VERSION);
|
||||
}
|
||||
|
||||
private boolean isKind(DocTree doctree, DocTree.Kind match) {
|
||||
return doctree.getKind() == match;
|
||||
}
|
||||
@ -2512,10 +2249,6 @@ public class Utils {
|
||||
return getBlockTags(element, t -> t.getKind() == kind, tClass);
|
||||
}
|
||||
|
||||
public List<? extends DocTree> getBlockTags(Element element, DocTree.Kind kind, DocTree.Kind altKind) {
|
||||
return getBlockTags(element, t -> t.getKind() == kind || t.getKind() == altKind);
|
||||
}
|
||||
|
||||
public List<? extends DocTree> getBlockTags(Element element, Taglet taglet) {
|
||||
return getBlockTags(element, t -> {
|
||||
if (taglet instanceof BaseTaglet baseTaglet) {
|
||||
@ -2791,19 +2524,6 @@ public class Utils {
|
||||
return elementUtils.getPackageOf(e);
|
||||
}
|
||||
|
||||
public TypeElement getTopMostContainingTypeElement(Element e) {
|
||||
if (isPackage(e)) {
|
||||
return null;
|
||||
}
|
||||
TypeElement outer = getEnclosingTypeElement(e);
|
||||
if (outer == null)
|
||||
return (TypeElement)e;
|
||||
while (outer != null && outer.getNestingKind().isNested()) {
|
||||
outer = getEnclosingTypeElement(outer);
|
||||
}
|
||||
return outer;
|
||||
}
|
||||
|
||||
/**
|
||||
* A memory-sensitive cache for {@link CommentHelper} objects,
|
||||
* which are expensive to compute.
|
||||
|
Loading…
x
Reference in New Issue
Block a user