public abstract class CallerContext
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CallerContext.Constants
Constants for use with CallerContext.
|
static class |
CallerContext.InputOptions
Input options for use with CallerContext.
|
static class |
CallerContext.Output
Output data from CallerContext.
|
| Constructor and Description |
|---|
CallerContext() |
| Modifier and Type | Method and Description |
|---|---|
static CallerContext |
createContext(JavaProvider provider,
JavaClass callingClass)
Deprecated.
Not supported
|
static CallerContext |
createContext(SourceElement sourceScope)
In case it isn't clear, the source scope can be any SourceElement
that is attached to a valid SourceFile tree.
|
static CallerContext |
createContext(SourceElement sourceScope,
boolean forgiving)
In case it isn't clear, the source scope can be any SourceElement
that is attached to a valid SourceFile tree.
|
abstract SourceElement |
getSourceScope() |
abstract boolean |
isCompatibleMethodReference(SourceElement scope,
JavaHasType lhs,
java.util.List<JavaType> typeArguments,
java.lang.String methodName,
JavaType functionalInterface)
Determines if a method reference composed of lhs::methodName is
assignment compatible with the functionalInterface type in
the given scope context.
|
abstract CallerContext.Output |
listMethods(JavaHasType lhs,
java.lang.String name,
JavaType[] tArguments,
CallerContext.InputOptions options)
List all matching methods that are both visible and accessible in
this caller context.
|
abstract CallerContext.Output |
listNames(JavaHasType lhs,
CallerContext.InputOptions options)
List all elements that are both visible and accessible in this
caller context.
|
abstract CallerContext.Output |
listNames(JavaPackage lhs,
CallerContext.InputOptions options)
List all member package and member type elements that are both
visible and accessible in this caller context.
|
abstract JavaHasType |
resolveAmbiguousName(JavaHasType lhs,
java.lang.String name)
Looks up the given AmbiguousName with a lhs value in the given
scope.
|
abstract JavaHasType |
resolveAmbiguousName(java.lang.String name)
Looks up the given AmbiguousName in the given scope.
|
JavaMethod |
resolveConstructor(JavaType target,
JavaType[] argumentTypes)
Deprecated.
Use resolveConstructor( JavaType, JavaType[], JavaHasType[], JavaType[] ) instead
|
abstract JavaMethod |
resolveConstructor(JavaType target,
JavaType[] typeArguments,
JavaHasType[] arguments,
JavaType[] argumentTypes)
Looks up a constructor on the target class.
|
abstract JavaHasType |
resolveExpressionName(JavaHasType lhs,
java.lang.String name)
Looks up the given ExpressionName with a lhs value in the given
scope.
|
abstract JavaHasType |
resolveExpressionName(java.lang.String name)
Looks up the given ExpressionName in the given scope.
|
JavaMethod |
resolveMethod(JavaHasType lhs,
java.lang.String name,
JavaType[] argumentTypes)
Deprecated.
Use resolveMethod( JavaHasType, String, JavaType[], JavaHasType[], JavaType[] ) instead
|
abstract JavaMethod |
resolveMethod(JavaHasType lhs,
java.lang.String name,
JavaType[] typeArguments,
JavaHasType[] arguments,
JavaType[] argumentTypes)
Looks up a method.
|
JavaMethod |
resolveMethod(JavaHasType lhs,
java.lang.String name,
JavaType[] typeArguments,
JavaType[] argumentTypes)
Deprecated.
Use resolveMethod( JavaHasType, String, JavaType[], JavaHasType[], JavaType[] ) instead
|
abstract JavaType |
resolveTypeName(JavaHasType lhs,
java.lang.String name)
Looks up the given TypeName with a lhs value in the given
scope.
|
abstract JavaType |
resolveTypeName(java.lang.String name)
Looks up the given TypeName in the given scope.
|
@Deprecated public static CallerContext createContext(JavaProvider provider, JavaClass callingClass)
public static CallerContext createContext(SourceElement sourceScope, boolean forgiving)
sourceScope - Must be a parented SourceElement belonging to
a SourceFile with a valid JavaProvider cookie.forgiving - If true, all calls will try to return a non-null
result even if a compiler generates an error for it.java.lang.IllegalArgumentException - if sourceScope is nulljava.lang.IllegalStateException - if sourceScope has no owning SourceFile,
or if that SourceFile has no JavaProviderpublic static CallerContext createContext(SourceElement sourceScope)
sourceScope - Must be a parented SourceElement belonging to
a SourceFile with a valid JavaProvider cookie.java.lang.IllegalArgumentException - if sourceScope is null, or sourceScope
has no parent, or the SourceFile of sourceScope has no
valid JavaProviderpublic abstract SourceElement getSourceScope()
public abstract JavaType resolveTypeName(java.lang.String name)
name - A namepublic abstract JavaType resolveTypeName(JavaHasType lhs, java.lang.String name)
lhs - The left-hand-side if this is a lhs.name expressionname - A namepublic abstract JavaHasType resolveExpressionName(java.lang.String name)
name - A namepublic abstract JavaHasType resolveExpressionName(JavaHasType lhs, java.lang.String name)
lhs - The left-hand-side if this is a lhs.name expressionname - A namepublic abstract JavaHasType resolveAmbiguousName(java.lang.String name)
name - A namepublic abstract JavaHasType resolveAmbiguousName(JavaHasType lhs, java.lang.String name)
lhs - The left-hand-side if this is a lhs.name expressionname - A name@Deprecated public final JavaMethod resolveMethod(JavaHasType lhs, java.lang.String name, JavaType[] argumentTypes)
lhs - The left hand side primary if it existsname - The name of the methodargumentTypes - The argument types; can use null for no argument types@Deprecated public final JavaMethod resolveMethod(JavaHasType lhs, java.lang.String name, JavaType[] typeArguments, JavaType[] argumentTypes)
lhs - The left hand side primary if it existsname - The name of the methodtypeArguments - The type arguments; can use null for no type argumentsargumentTypes - The argument types; can use null for no argument typespublic abstract JavaMethod resolveMethod(JavaHasType lhs, java.lang.String name, JavaType[] typeArguments, JavaHasType[] arguments, JavaType[] argumentTypes)
lhs - The left hand side primary if it existsname - The name of the methodtypeArguments - The type arguments; can use null for no type argumentsarguments - The argument expressions; can use null for no argument expressionsargumentTypes - The argument types; can use null for no argument types@Deprecated public final JavaMethod resolveConstructor(JavaType target, JavaType[] argumentTypes)
target - The targeet classargumentTypes - The argument types; can use null for no argument typespublic abstract JavaMethod resolveConstructor(JavaType target, JavaType[] typeArguments, JavaHasType[] arguments, JavaType[] argumentTypes)
target - The targeet classtypeArguments - The type arguments; can use null for no type argumentsarguments - The argument expressions; can use null for no argument expressionsargumentTypes - The argument types; can use null for no argument typespublic abstract CallerContext.Output listNames(JavaPackage lhs, CallerContext.InputOptions options)
lhs - Non-null indicates an explicit lhs.options - The options for this lookuppublic abstract CallerContext.Output listNames(JavaHasType lhs, CallerContext.InputOptions options)
lhs - Non-null indicates an explicit lhs.options - The options for this lookuppublic abstract CallerContext.Output listMethods(JavaHasType lhs, java.lang.String name, JavaType[] tArguments, CallerContext.InputOptions options)
lhs - Non-null indicates an explicit lhsname - Method name restriction.If non-null, the output will
only include methods with a matching name. If null, no
name restriction is applied. Use <init> to search for
constructorstArguments - Null indicates no type argumentsoptions - The options for this lookuppublic abstract boolean isCompatibleMethodReference(SourceElement scope, JavaHasType lhs, java.util.List<JavaType> typeArguments, java.lang.String methodName, JavaType functionalInterface)
scope - The scope where the method reference occurslhs - A JavaHasTypetypeArguments - The type arguments of the method, if any,
use null or an empty List for no type argumentsmethodName - A method name; use "new" if this should be
a reference to a constructorfunctionalInterface - A functional interface type