Skip to content

Commit

Permalink
8319300: Remove unused methods in WorkArounds and Utils
Browse files Browse the repository at this point in the history
Reviewed-by: prappo
  • Loading branch information
hns committed Nov 2, 2023
1 parent faa8bde commit e9d19d0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 112 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -128,68 +128,6 @@ FileObject getJavaFileObject(PackageElement packageElement) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,20 +805,6 @@ private void addSuperInterfaces(TypeMirror type, Set<TypeMirror> results, Set<El
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
Expand All @@ -834,30 +820,6 @@ public boolean isGenericType(TypeMirror type) {
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.
Expand Down Expand Up @@ -1563,17 +1525,6 @@ public List<VariableElement> getFieldsUnfiltered(TypeElement te) {
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.
*
Expand Down

1 comment on commit e9d19d0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.