public class Resolver extends Object
Constructor and Description |
---|
Resolver(ProcessingEnvironment env) |
Modifier and Type | Method and Description |
---|---|
protected Object |
buildMethodContext()
Build an instance of
Resolve$MethodResolutionContext . |
Element |
findClass(String name,
TreePath path)
Finds the class literal with name
name . |
@Nullable com.sun.tools.javac.code.Symbol.ClassSymbol |
findClassInPackage(String name,
com.sun.tools.javac.code.Symbol.PackageSymbol pck,
TreePath path)
Finds the class with name
name in a given package. |
@Nullable VariableElement |
findField(String name,
TypeMirror type,
TreePath path)
Finds the field with name
name in type or a superclass or superinterface of
type . |
@Nullable VariableElement |
findLocalVariableOrParameter(String name,
TreePath path)
Finds the local variable (including formal parameters) with name
name in the given
scope. |
@Nullable ExecutableElement |
findMethod(String methodName,
TypeMirror receiverType,
TreePath path,
List<TypeMirror> argumentTypes)
Finds the method element for a given name and list of expected parameter types.
|
@Nullable com.sun.tools.javac.code.Symbol.PackageSymbol |
findPackage(String name,
TreePath path)
Finds the package with name
name . |
com.sun.tools.javac.comp.Env<com.sun.tools.javac.comp.AttrContext> |
getEnvForPath(TreePath path)
Determine the environment for the given path.
|
public Resolver(ProcessingEnvironment env)
public com.sun.tools.javac.comp.Env<com.sun.tools.javac.comp.AttrContext> getEnvForPath(TreePath path)
path
- the tree path to the local scopepublic @Nullable com.sun.tools.javac.code.Symbol.PackageSymbol findPackage(String name, TreePath path)
name
.name
- the name of the packagepath
- the tree path to the local scopePackageSymbol
for the package if it is found, null
otherwisepublic @Nullable VariableElement findField(String name, TypeMirror type, TreePath path)
name
in type
or a superclass or superinterface of
type
.
The method adheres to all the rules of Java's scoping (while also considering the imports) for name resolution.
name
- the name of the fieldtype
- the type of the receiver (i.e., the type in which to look for the field)path
- the tree path to the local scopenull
otherwisepublic @Nullable VariableElement findLocalVariableOrParameter(String name, TreePath path)
name
in the given
scope.name
- the name of the local variablepath
- the tree path to the local scopenull
otherwisepublic Element findClass(String name, TreePath path)
name
.
The method adheres to all the rules of Java's scoping (while also considering the imports) for name resolution.
name
- the name of the classpath
- the tree path to the local scopepublic @Nullable com.sun.tools.javac.code.Symbol.ClassSymbol findClassInPackage(String name, com.sun.tools.javac.code.Symbol.PackageSymbol pck, TreePath path)
name
in a given package.name
- the name of the classpck
- the PackageSymbol for the packagepath
- the tree path to the local scopeClassSymbol
for the class if it is found, null
otherwisepublic @Nullable ExecutableElement findMethod(String methodName, TypeMirror receiverType, TreePath path, List<TypeMirror> argumentTypes)
The method adheres to all the rules of Java's scoping (while also considering the imports) for name resolution.
(This method takes into account autoboxing.)
methodName
- name of the method to findreceiverType
- type of the receiver of the methodpath
- tree pathargumentTypes
- types of arguments passed to the method callprotected Object buildMethodContext() throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException
Resolve$MethodResolutionContext
.