|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface TypeContext
A context for type checking. Contexts are immutable, and provide the necessary contextual information for static analysis. To separate concerns, a context has no knowledge of the type system, and requires a TypeSystem to be passed as an argument wherever it may be useful.
| Method Summary | |
|---|---|
Access.Module |
accessModule()
Get the current access module. |
boolean |
fieldExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope field |
boolean |
functionExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope method or local function |
java.lang.ClassLoader |
getClassLoader()
Return the class loader for the current scope. |
java.lang.Iterable<Type> |
getDeclaredThrownTypes()
The types that are allowed to be thrown in the current context. |
java.lang.Iterable<LocalFunction> |
getLocalFunctions(java.lang.String name,
TypeSystem ts)
List all local functions that match the given name (empty if there are none) |
java.lang.Iterable<LocalFunction> |
getLocalFunctions(java.lang.String name,
TypeSystem ts,
java.lang.Iterable<LocalFunction> partial)
Helper for getLocalFunctions: list all matching functions, including those provided. |
LocalVariable |
getLocalVariable(java.lang.String name,
TypeSystem ts)
Return the variable object for the given name, or null if it does not exist. |
Type |
getReturnType()
The expected type of a return statement in the given context, or null
if return statements should not appear here. |
DJClass |
getThis()
Return the class of this in the current context, or null
if there is no such value (for example, in a static context). |
DJClass |
getThis(java.lang.String className)
Return the class of className.this in the current context, or null
if there is no such value (for example, in a static context). |
DJClass |
getThis(Type expected,
TypeSystem ts)
Return the innermost "this" class with the given type in the current context, or null if there is no such value (for example, in a static context). |
DJClass |
getTopLevelClass(java.lang.String name,
TypeSystem ts)
Return the top-level class with the given name, or null if it does not exist. |
VariableType |
getTypeVariable(java.lang.String name,
TypeSystem ts)
Return the type variable with the given name, or null if it does not exist. |
TypeContext |
importField(DJClass c,
java.lang.String name)
Import the field(s) of c with the given name |
TypeContext |
importMemberClass(DJClass outer,
java.lang.String name)
Import the member class(es) of outer with the given name |
TypeContext |
importMemberClasses(DJClass outer)
Import on demand all member classes of the given class |
TypeContext |
importMethod(DJClass c,
java.lang.String name)
Import the method(s) of c with the given name |
TypeContext |
importStaticMembers(DJClass c)
Import on demand all static members of the given class |
TypeContext |
importTopLevelClass(DJClass c)
Import the given top-level class |
TypeContext |
importTopLevelClasses(java.lang.String pkg)
Import on demand all top-level classes in the given package |
DJClass |
initializingClass()
Class which is being initialized (via a constructor or initialization block); null otherwise. |
boolean |
localFunctionExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope local function |
boolean |
localVariableExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope local variable |
java.lang.String |
makeAnonymousClassName()
Return a full name for an anonymous class declared here. |
java.lang.String |
makeClassName(java.lang.String declaredName)
Return a full name for a class with the given name declared here. |
boolean |
memberClassExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope member class |
boolean |
methodExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope method |
TypeContext |
setPackage(java.lang.String name)
Set the current package to the given package name |
boolean |
topLevelClassExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope top-level class |
ClassType |
typeContainingField(java.lang.String name,
TypeSystem ts)
Return the most inner type containing a field with the given name, or null
if there is no such type. |
ClassType |
typeContainingMemberClass(java.lang.String name,
TypeSystem ts)
Return the most inner type containing a class with the given name, or null
if there is no such type. |
Type |
typeContainingMethod(java.lang.String name,
TypeSystem ts)
Return the most inner type containing a method with the given name, or null
if there is no such type. |
boolean |
typeExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope top-level class, member class, or type variable |
boolean |
typeVariableExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope type variable. |
boolean |
variableExists(java.lang.String name,
TypeSystem ts)
Test whether name is an in-scope field or local variable |
| Method Detail |
|---|
TypeContext setPackage(java.lang.String name)
TypeContext importTopLevelClasses(java.lang.String pkg)
TypeContext importMemberClasses(DJClass outer)
TypeContext importStaticMembers(DJClass c)
TypeContext importTopLevelClass(DJClass c)
TypeContext importMemberClass(DJClass outer,
java.lang.String name)
outer with the given name
TypeContext importField(DJClass c,
java.lang.String name)
c with the given name
TypeContext importMethod(DJClass c,
java.lang.String name)
c with the given name
boolean typeExists(java.lang.String name,
TypeSystem ts)
name is an in-scope top-level class, member class, or type variable
boolean topLevelClassExists(java.lang.String name,
TypeSystem ts)
name is an in-scope top-level class
DJClass getTopLevelClass(java.lang.String name,
TypeSystem ts)
throws AmbiguousNameException
null if it does not exist.
AmbiguousNameException
boolean memberClassExists(java.lang.String name,
TypeSystem ts)
name is an in-scope member class
ClassType typeContainingMemberClass(java.lang.String name,
TypeSystem ts)
throws AmbiguousNameException
null
if there is no such type.
AmbiguousNameException
boolean typeVariableExists(java.lang.String name,
TypeSystem ts)
name is an in-scope type variable.
VariableType getTypeVariable(java.lang.String name,
TypeSystem ts)
null if it does not exist.
boolean variableExists(java.lang.String name,
TypeSystem ts)
name is an in-scope field or local variable
boolean fieldExists(java.lang.String name,
TypeSystem ts)
name is an in-scope field
ClassType typeContainingField(java.lang.String name,
TypeSystem ts)
throws AmbiguousNameException
null
if there is no such type.
AmbiguousNameException
boolean localVariableExists(java.lang.String name,
TypeSystem ts)
name is an in-scope local variable
LocalVariable getLocalVariable(java.lang.String name,
TypeSystem ts)
null if it does not exist.
boolean functionExists(java.lang.String name,
TypeSystem ts)
name is an in-scope method or local function
boolean methodExists(java.lang.String name,
TypeSystem ts)
name is an in-scope method
Type typeContainingMethod(java.lang.String name,
TypeSystem ts)
null
if there is no such type.
boolean localFunctionExists(java.lang.String name,
TypeSystem ts)
name is an in-scope local function
java.lang.Iterable<LocalFunction> getLocalFunctions(java.lang.String name,
TypeSystem ts)
java.lang.Iterable<LocalFunction> getLocalFunctions(java.lang.String name,
TypeSystem ts,
java.lang.Iterable<LocalFunction> partial)
Access.Module accessModule()
java.lang.String makeClassName(java.lang.String declaredName)
java.lang.String makeAnonymousClassName()
DJClass getThis()
this in the current context, or null
if there is no such value (for example, in a static context).
DJClass getThis(java.lang.String className)
className.this in the current context, or null
if there is no such value (for example, in a static context).
DJClass getThis(Type expected,
TypeSystem ts)
null if there is no such value (for example, in a static context).
DJClass initializingClass()
null otherwise.
Type getReturnType()
return statement in the given context, or null
if return statements should not appear here.
java.lang.Iterable<Type> getDeclaredThrownTypes()
java.lang.ClassLoader getClassLoader()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||