Package gw.lang.reflect
Class TypeSystem
java.lang.Object
gw.lang.reflect.TypeSystem
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Lock
static InvocationCounter
static InvocationCounter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
static IType
boundTypes
(IType targetType, List<IType> typesToBound) static IType[]
boxPrimitiveTypeParams
(IType[] typeParams) static boolean
static void
static void
static void
static void
static void
static void
static IType
findParameterizedType
(IType type, IType rhsType) static IType
get
(IJavaClassInfo javaClassInfo) static IType
get
(IJavaClassInfo classInfo, IModule module) static IType
Gets the intrinsic type for a given class.static IType
static IType
getActualType
(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars) static List<ITypeLoader>
static Set<? extends CharSequence>
Returns all type names in the system for all type loaders.static IType
getBoxType
(IType primitiveType) static IType
getByFullName
(String fullyQualifiedName) Gets an intrinsic type based on a fully-qualified name.static IType
getByFullName
(String fullyQualifiedName, IModule module) static IType
getByFullName
(String fullyQualifiedName, String moduleName) Deprecated.call getByFullName( String, IModule )static IType
getByFullNameIfValid
(String fullyQualifiedName) Gets a type based on a fully-qualified name.static IType
getByFullNameIfValid
(String typeName, IModule module) static IType
getByFullNameIfValidNoJava
(String fullyQualifiedName) static IType
getByRelativeName
(String relativeName) static IType
getByRelativeName
(String relativeName, ITypeUsesMap typeUses) Gets an intrinsic type based on a relative name.static ISymbolTable
static IType
getCompilingType
(String strName) static IType
getComponentType
(IType valueType) static IType
getCompoundType
(Set<IType> types) static IType
static IModule
static Method[]
getDeclaredMethods
(Class cls) static IType
static IType
static IMetaType
static IDefaultTypeLoader
static ITypeUsesMap
static IErrorType
static IErrorType
static IErrorType
getErrorType
(String strErrantName) static IExecutionEnvironment
static IExecutionEnvironment
getExecutionEnvironment
(IProject project) static IType
getFromObject
(Object object) Returns the intrinsic type for the given Object.static IType
getFromObject
(Object object, IModule module) static IType
static String
getGenericName
(IType type) static String
getGenericName
(IType type, boolean bRelative, boolean bRelativeBounds) static String
getGenericRelativeName
(IType type, boolean bRelativeBounds) static Lock
static IModule
static IGosuClassLoader
static IJavaClassInfo
getJavaClassInfo
(Class jClass) static IJavaClassInfo
getJavaClassInfo
(Class jClass, IModule module) static IJavaClassInfo
getJavaClassInfo
(String fullyQualifiedName, IModule module) static IType
getJavaType
(Class javaClass) Deprecated.static IModule
static IType
static List<? extends IMethodInfo>
getMethods
(ITypeInfo beanInfo, IType ownersIntrinsicType) static IModule
getModuleFromType
(IType type) static String
getNameOfParams
(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType) static INamespaceType
getNamespace
(String strFqNamespace) static INamespaceType
getNamespace
(String strType, IModule module) getNamespacesFromTypeNames
(Set<? extends CharSequence> allTypeNames, Set<String> namespaces) static String
static IFunctionType
static IFunctionType
getOrCreateFunctionType
(String strFunctionName, IType retType, IType[] paramTypes) static ITypeRef
IMPORTANT: The only time you should call this method is: 1) within a class implementing IType, or 2) wrapping a call to a Type constructor, typically within a type loader e.g., TypeSystem.getOrCreateTypeReference( new MyVeryOwnType() ) Gets or creates a type ref for the specified type.static ITypeVariableType
getOrCreateTypeVariableType
(String strName, IType boundingType, IType enclosingType) static IType
getPrimitiveType
(IType boxType) static IJavaType
getPrimitiveType
(String name) static List<? extends IPropertyInfo>
getProperties
(ITypeInfo beanInfo, IType classSource) static IPropertyInfo
getPropertyInfo
(IType classBean, String strProperty, IFeatureFilter filter, IParserPart parserBase, IScriptabilityModifier scriptabilityConstraint) static <E extends IType>
EgetPureGenericType
(E type) static int
static int
static TypeSystemState
getState()
static ISymbolTable
static IType
static IType
getTypeFromJavaBasedType
(IJavaBackedType javaType) static IType
getTypeFromObject
(Object obj) static <T extends ITypeLoader>
TgetTypeLoader
(Class<? extends T> loaderClass) static <T extends ITypeLoader>
TgetTypeLoader
(Class<? extends T> loaderClass, IModule module) static ITypeRef
getTypeReference
(IType type) IMPORTANT: The only time you should call this method is: 1) wrapping a call to a Type constructor, typically within a type loader e.g., TypeSystem.getOrCreateTypeReference( new MyVeryOwnType() ) Do NOT call this when creating the type.static String[]
getTypesForFile
(IModule module, IFile file) static String
static void
inferTypeVariableTypesFromGenParamTypeAndConcreteType
(IType genParamType, IType argType, TypeVarToTypeMap map, boolean bReverse) static boolean
isBeanType
(IType typeSource) static boolean
isBoxedTypeFor
(IType primitiveType, IType boxedType) static boolean
isBytecodeType
(IType type) static boolean
static boolean
isExpandable
(IType type) static boolean
static boolean
isNumericType
(IType intrType) static boolean
isParameterizedWith
(IType type, ITypeVariableType... typeVar) static void
lock()
Acquires the global type-system lockstatic TypeVarToTypeMap
mapTypeByVarName
(IType ownersType, IType declaringType) static IType
Converts a String name of a type into an IType.static IType
parseType
(String typeString, ITypeUsesMap typeUsesMap) static IType
parseType
(String typeString, TypeVarToTypeMap actualParamByVarName) static IType
parseType
(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) static ITypeLiteralExpression
parseTypeExpression
(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) static IType
parseTypeLiteral
(String typeName) Parses a type name such as Iterable<Claim>.static void
static void
static void
static void
static void
static void
pushCompilingType
(IType type) static void
static void
static void
pushModule
(IModule gosuModule) static void
static void
pushTypeLoader
(IModule module, ITypeLoader loader) static void
refresh
(boolean bRefreshCaches) static void
Refresh just the specified type i.e., a gosu editor calls this on changesstatic void
static void
static void
refreshedFiles
(String[] filePaths) DO NOT USE OR DELETE.static void
removeTypeLoader
(Class<? extends ITypeLoader> loader) static void
removeTypeLoaderListener
(ITypeLoaderListener listener) static IType
replaceTypeVariableTypeParametersWithBoundingTypes
(IType type, IType enclosingType) static void
shutdown
(IExecutionEnvironment execEnv) static void
unlock()
Releases the global type-system lock
-
Field Details
-
GLOBAL_LOCK
-
tyeRequestCounter
-
tyeLoadingCounter
-
-
Constructor Details
-
TypeSystem
public TypeSystem()
-
-
Method Details
-
get
Gets the intrinsic type for a given class.javaClass
to get the type from. If you do have such an object, usegetFromObject(java.lang.Object)
instead.- Parameters:
javaClass
- the Class to convert to an intrinsic type- Returns:
- the IType that corresponds to that class
- See Also:
-
get
-
get
-
get
-
getFromObject
Returns the intrinsic type for the given Object.- Parameters:
object
- the object to get an IType for- Returns:
- the IType for the object
- See Also:
-
getFromObject
-
getByRelativeName
- Throws:
ClassNotFoundException
-
getByRelativeName
public static IType getByRelativeName(String relativeName, ITypeUsesMap typeUses) throws ClassNotFoundException Gets an intrinsic type based on a relative name. This could either be the name of an entity, like "User", the name of a typekey, like "SystemPermission", or a class name, like "java.lang.String" (relative and fully qualified class names are the same as far as this factory is concerned). Names can have [] appended to them to create arrays, and multi-dimensional arrays are supported.- Parameters:
relativeName
- the relative name of the typetypeUses
- the map of used types to use when resolving- Returns:
- the corresponding IType
- Throws:
ClassNotFoundException
- if the specified name doesn't correspond to any type
-
getByFullName
Gets an intrinsic type based on a fully-qualified name. This could either be the name of an entity, like "entity.User", the name of a typekey, like "typekey.SystemPermission", or a class name, like "java.lang.String". Names can have [] appended to them to create arrays, and multi-dimensional arrays are supported.- Parameters:
fullyQualifiedName
- the fully qualified name of the type- Returns:
- the corresponding IType
- Throws:
RuntimeException
- if the specified name doesn't correspond to any type
-
getByFullName
-
getByFullName
Deprecated.call getByFullName( String, IModule ) -
pushGlobalModule
public static void pushGlobalModule() -
popGlobalModule
public static void popGlobalModule() -
getByFullNameIfValid
Gets a type based on a fully-qualified name. This could either be the name of an entity, like "entity.User", the name of a typekey, like "typekey.SystemPermission", or a class name, like "java.lang.String". Names can have [] appended to them to create arrays, and multi-dimensional arrays are supported. This method behaves the same as getByFullName execept instead of throwing it returns null.- Parameters:
fullyQualifiedName
- the fully qualified name of the type- Returns:
- the corresponding IType or null if the type does not exist
-
getByFullNameIfValidNoJava
-
getByFullNameIfValid
-
clearErrorTypes
public static void clearErrorTypes() -
getRefreshChecksum
public static int getRefreshChecksum() -
getSingleRefreshChecksum
public static int getSingleRefreshChecksum() -
parseType
Converts a String name of a type into an IType.- Parameters:
typeString
- the type name to parse- Returns:
- the parsed type
- Throws:
IllegalArgumentException
- if the type string doesn't correspond to any known IType
-
parseType
public static IType parseType(String typeString, ITypeUsesMap typeUsesMap) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parseType
public static IType parseType(String typeString, TypeVarToTypeMap actualParamByVarName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parseType
public static IType parseType(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
parseTypeExpression
public static ITypeLiteralExpression parseTypeExpression(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) throws ParseResultsException - Throws:
ParseResultsException
-
lock
public static void lock()Acquires the global type-system lock -
unlock
public static void unlock()Releases the global type-system lock -
getGlobalLock
-
getComponentType
-
getNamespace
-
getNamespace
-
getAllTypeNames
Returns all type names in the system for all type loaders.- Returns:
- all type names in the system.
-
getOrCreateTypeVariableType
public static ITypeVariableType getOrCreateTypeVariableType(String strName, IType boundingType, IType enclosingType) -
getOrCreateFunctionType
-
getOrCreateFunctionType
public static IFunctionType getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes) -
getPureGenericType
-
isBeanType
-
isNumericType
-
isBoxedTypeFor
-
mapTypeByVarName
-
getActualType
public static IType getActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars) -
inferTypeVariableTypesFromGenParamTypeAndConcreteType
public static void inferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap map, boolean bReverse) -
getErrorType
-
getErrorType
-
getErrorType
-
getDefaultTypeLoader
-
findParameterizedType
-
addTypeLoaderListenerAsWeakRef
-
getNamespacesFromTypeNames
-
pushTypeLoader
-
removeTypeLoader
-
getKeyType
-
pushIncludeAll
public static void pushIncludeAll() -
popIncludeAll
public static void popIncludeAll() -
isIncludeAll
public static boolean isIncludeAll() -
getDefaultTypeUsesMap
-
getCurrentCompilingType
-
getCompilingType
-
pushCompilingType
-
popCompilingType
public static void popCompilingType() -
getUnqualifiedClassName
-
pushSymTableCtx
-
popSymTableCtx
public static void popSymTableCtx() -
getSymTableCtx
-
getTypeLoader
-
getTypeLoader
public static <T extends ITypeLoader> T getTypeLoader(Class<? extends T> loaderClass, IModule module) -
getNameOfParams
-
getCompiledGosuClassSymbolTable
-
getAllTypeLoaders
-
getGenericRelativeName
-
getGenericName
-
getGenericName
-
getPropertyInfo
public static IPropertyInfo getPropertyInfo(IType classBean, String strProperty, IFeatureFilter filter, IParserPart parserBase, IScriptabilityModifier scriptabilityConstraint) throws ParseException - Throws:
ParseException
-
getProperties
-
getMethods
-
getJavaType
Deprecated. -
getNameWithQualifiedTypeVariables
-
getDefaultParameterizedType
-
getDefaultParameterizedTypeWithTypeVars
-
canCast
-
removeTypeLoaderListener
-
getPrimitiveType
-
getPrimitiveType
-
getBoxType
-
boxPrimitiveTypeParams
-
getExecutionEnvironment
-
getExecutionEnvironment
-
getCurrentModule
-
getOrCreateTypeReference
IMPORTANT: The only time you should call this method is: 1) within a class implementing IType, or 2) wrapping a call to a Type constructor, typically within a type loader e.g., TypeSystem.getOrCreateTypeReference( new MyVeryOwnType() ) Gets or creates a type ref for the specified type.- Parameters:
type
- A raw or proxied type.- Returns:
- If the type is already a reference, returns the type as-is, otherwise creates and returns a new type ref.
-
getTypeReference
IMPORTANT: The only time you should call this method is: 1) wrapping a call to a Type constructor, typically within a type loader e.g., TypeSystem.getOrCreateTypeReference( new MyVeryOwnType() ) Do NOT call this when creating the type. Instead call getOrCreateTypeReference Gets or creates a type ref for the specified type. This method will NOT update the type reference in the proxy.- Parameters:
type
- A raw or proxied type.- Returns:
- returns the already created type reference or throws if the ref does not exist
-
getTypeFromObject
-
parseTypeLiteral
Parses a type name such as Iterable<Claim>.- Parameters:
typeName
- the name to parse- Returns:
- the type
-
isExpandable
-
boundTypes
-
getJavaClassInfo
-
getJavaClassInfo
-
getDeclaredMethods
-
isBytecodeType
-
getTypeFromJavaBackedType
-
getTypeFromJavaBasedType
-
getJavaClassInfo
-
getModuleFromType
-
pushModule
-
popModule
-
getGosuClassLoader
-
dumpGosuClassLoader
public static void dumpGosuClassLoader() -
getGlobalModule
-
getDefaultType
-
shutdown
-
addShutdownListener
-
getState
-
getTypesForFile
-
refresh
public static void refresh(boolean bRefreshCaches) -
refresh
-
refresh
Refresh just the specified type i.e., a gosu editor calls this on changes -
refreshedFiles
DO NOT USE OR DELETE. Called form the debugging process (IDE).- Parameters:
filePaths
-
-
refreshed
-
deleted
-
deleted
-
created
-
created
-
isDeleted
-
replaceTypeVariableTypeParametersWithBoundingTypes
-
isParameterizedWith
-
getJreModule
-
getCompoundType
-
getFunctionalInterface
-