8319300: Remove unused methods in WorkArounds and Utils

Reviewed-by: prappo
This commit is contained in:
Hannes Wallnöfer 2023-11-02 12:21:26 +00:00
parent faa8bde275
commit e9d19d0fff
2 changed files with 1 additions and 112 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -128,68 +128,6 @@ public class WorkArounds {
return ((PackageSymbol)packageElement).sourcefile;
}
// TODO: needs to ported to jx.l.m.
public TypeElement searchClass(TypeElement klass, String className) {
TypeElement te;
// search by qualified name in current module first
ModuleElement me = utils.containingModule(klass);
if (me != null) {
te = elementUtils.getTypeElement(me, className);
if (te != null) {
return te;
}
}
// search inner classes
for (TypeElement ite : utils.getClasses(klass)) {
TypeElement innerClass = searchClass(ite, className);
if (innerClass != null) {
return innerClass;
}
}
// check in this package
te = utils.findClassInPackageElement(utils.containingPackage(klass), className);
if (te != null) {
return te;
}
ClassSymbol tsym = (ClassSymbol)klass;
// make sure that this symbol has been completed
// TODO: do we need this anymore ?
if (tsym.completer != null) {
tsym.complete();
}
// search imports
if (tsym.sourcefile != null) {
//### This information is available only for source classes.
Env<AttrContext> compenv = toolEnv.getEnv(tsym);
if (compenv == null) {
return null;
}
Names names = tsym.name.table.names;
Scope s = compenv.toplevel.namedImportScope;
for (Symbol sym : s.getSymbolsByName(names.fromString(className))) {
if (sym.kind == TYP) {
return (TypeElement)sym;
}
}
s = compenv.toplevel.starImportScope;
for (Symbol sym : s.getSymbolsByName(names.fromString(className))) {
if (sym.kind == TYP) {
return (TypeElement)sym;
}
}
}
// finally, search by qualified name in all modules
return elementUtils.getTypeElement(className);
}
// TODO: jx.l.m ?
public Location getLocationForModule(ModuleElement mdle) {
ModuleSymbol msym = (ModuleSymbol)mdle;

View File

@ -805,20 +805,6 @@ public class Utils {
addSuperInterfaces(superType, results, visited);
}
/**
* Lookup for a class within this package.
*
* @return TypeElement of found class, or null if not found.
*/
public TypeElement findClassInPackageElement(PackageElement pkg, String className) {
for (TypeElement c : getAllClasses(pkg)) {
if (getSimpleName(c).equals(className)) {
return c;
}
}
return null;
}
/**
* Returns true if {@code type} or any of its enclosing types has non-empty type arguments.
* @param type the type
@ -834,30 +820,6 @@ public class Utils {
return false;
}
/**
* TODO: FIXME: port to javax.lang.model
* Find a class within the context of this class. Search order: qualified name, in this class
* (inner), in this package, in the class imports, in the package imports. Return the
* TypeElement if found, null if not found.
*/
//### The specified search order is not the normal rule the
//### compiler would use. Leave as specified or change it?
public TypeElement findClass(Element element, String className) {
TypeElement encl = getEnclosingTypeElement(element);
TypeElement searchResult = configuration.workArounds.searchClass(encl, className);
if (searchResult == null) {
encl = getEnclosingTypeElement(encl);
//Expand search space to include enclosing class.
while (encl != null && getEnclosingTypeElement(encl) != null) {
encl = getEnclosingTypeElement(encl);
}
searchResult = encl == null
? null
: configuration.workArounds.searchClass(encl, className);
}
return searchResult;
}
/**
* Given an annotation, return true if it should be documented and false
* otherwise.
@ -1563,17 +1525,6 @@ public class Utils {
return getAllItems(te, FIELD, VariableElement.class);
}
/**
* Returns the documented classes in an element,
* such as a package element or type element.
*
* @param e the element
* @return the classes
*/
public List<TypeElement> getClasses(Element e) {
return getDocumentedItems(e, CLASS, TypeElement.class);
}
/**
* Returns the documented constructors in a type element.
*