Package gw.lang.reflect
Class TypeSystem
- java.lang.Object
-
- gw.lang.reflect.TypeSystem
-
public class TypeSystem extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static InvocationCounter
tyeLoadingCounter
static InvocationCounter
tyeRequestCounter
-
Constructor Summary
Constructors Constructor Description TypeSystem()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addShutdownListener(TypeSystemShutdownListener listener)
static void
addTypeLoaderListenerAsWeakRef(ITypeLoaderListener listener)
static IType
boundTypes(IType targetType, List<IType> typesToBound)
static IType[]
boxPrimitiveTypeParams(IType[] typeParams)
static boolean
canCast(IType lhsType, IType rhsType)
static void
clearErrorTypes()
static void
created(IResource resource)
static void
created(IResource resource, String typeName)
static void
deleted(IResource resource)
static void
deleted(IResource resource, String typeName)
static void
dumpGosuClassLoader()
static IType
findParameterizedType(IType type, IType rhsType)
static IType
get(IJavaClassInfo javaClassInfo)
static IType
get(IJavaClassInfo classInfo, IModule module)
static IType
get(Class javaClass)
Gets the intrinsic type for a given class.static IType
get(Class javaClass, IModule module)
static IType
getActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)
static List<ITypeLoader>
getAllTypeLoaders()
static Set<? extends CharSequence>
getAllTypeNames()
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
getCompiledGosuClassSymbolTable()
static IType
getCompilingType(String strName)
static IType
getComponentType(IType valueType)
static IType
getCompoundType(Set<IType> types)
static IType
getCurrentCompilingType()
static IModule
getCurrentModule()
static Method[]
getDeclaredMethods(Class cls)
static IType
getDefaultParameterizedType(IType type)
static IType
getDefaultParameterizedTypeWithTypeVars(IType type)
static IMetaType
getDefaultType()
static IDefaultTypeLoader
getDefaultTypeLoader()
static ITypeUsesMap
getDefaultTypeUsesMap()
static IErrorType
getErrorType()
static IErrorType
getErrorType(ParseResultsException pe)
static IErrorType
getErrorType(String strErrantName)
static IExecutionEnvironment
getExecutionEnvironment()
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
getFunctionalInterface(IFunctionType type)
static String
getGenericName(IType type)
static String
getGenericName(IType type, boolean bRelative, boolean bRelativeBounds)
static String
getGenericRelativeName(IType type, boolean bRelativeBounds)
static Lock
getGlobalLock()
static IModule
getGlobalModule()
static IGosuClassLoader
getGosuClassLoader()
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
getJreModule()
static IType
getKeyType()
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)
static Set<String>
getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces)
static String
getNameWithQualifiedTypeVariables(IType type)
static IFunctionType
getOrCreateFunctionType(IMethodInfo mi)
static IFunctionType
getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes)
static ITypeRef
getOrCreateTypeReference(IType type)
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
getRefreshChecksum()
static int
getSingleRefreshChecksum()
static TypeSystemState
getState()
static ISymbolTable
getSymTableCtx()
static IType
getTypeFromJavaBackedType(IType type)
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
getUnqualifiedClassName(IType cls)
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
isDeleted(IType type)
static boolean
isExpandable(IType type)
static boolean
isIncludeAll()
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
parseType(String typeString)
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
popCompilingType()
static void
popGlobalModule()
static void
popIncludeAll()
static void
popModule(IModule gosuModule)
static void
popSymTableCtx()
static void
pushCompilingType(IType type)
static void
pushGlobalModule()
static void
pushIncludeAll()
static void
pushModule(IModule gosuModule)
static void
pushSymTableCtx(ISymbolTable ctx)
static void
pushTypeLoader(IModule module, ITypeLoader loader)
static void
refresh(boolean bRefreshCaches)
static void
refresh(ITypeRef typeRef)
Refresh just the specified type i.e., a gosu editor calls this on changesstatic void
refresh(IModule module)
static void
refreshed(IResource resource)
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 Detail
-
tyeRequestCounter
public static InvocationCounter tyeRequestCounter
-
tyeLoadingCounter
public static InvocationCounter tyeLoadingCounter
-
-
Method Detail
-
get
public static IType get(Class javaClass)
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:
getFromObject(Object)
-
get
public static IType get(IJavaClassInfo javaClassInfo)
-
get
public static IType get(IJavaClassInfo classInfo, IModule module)
-
getFromObject
public static IType getFromObject(Object object)
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:
get(Class)
-
getByRelativeName
public static IType getByRelativeName(String relativeName) throws ClassNotFoundException
- 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
public static IType getByFullName(String fullyQualifiedName)
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
public static IType getByFullName(String fullyQualifiedName, String moduleName)
Deprecated.call getByFullName( String, IModule )
-
pushGlobalModule
public static void pushGlobalModule()
-
popGlobalModule
public static void popGlobalModule()
-
getByFullNameIfValid
public static IType getByFullNameIfValid(String fullyQualifiedName)
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
public static IType getByFullNameIfValidNoJava(String fullyQualifiedName)
-
clearErrorTypes
public static void clearErrorTypes()
-
getRefreshChecksum
public static int getRefreshChecksum()
-
getSingleRefreshChecksum
public static int getSingleRefreshChecksum()
-
parseType
public static IType parseType(String typeString) throws IllegalArgumentException
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
public static Lock getGlobalLock()
-
getNamespace
public static INamespaceType getNamespace(String strFqNamespace)
-
getNamespace
public static INamespaceType getNamespace(String strType, IModule module)
-
getAllTypeNames
public static Set<? extends CharSequence> 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
public static IFunctionType getOrCreateFunctionType(IMethodInfo mi)
-
getOrCreateFunctionType
public static IFunctionType getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes)
-
getPureGenericType
public static <E extends IType> E getPureGenericType(E type)
-
isBeanType
public static boolean isBeanType(IType typeSource)
-
isNumericType
public static boolean isNumericType(IType intrType)
-
mapTypeByVarName
public static TypeVarToTypeMap mapTypeByVarName(IType ownersType, IType declaringType)
-
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
public static IErrorType getErrorType()
-
getErrorType
public static IErrorType getErrorType(String strErrantName)
-
getErrorType
public static IErrorType getErrorType(ParseResultsException pe)
-
getDefaultTypeLoader
public static IDefaultTypeLoader getDefaultTypeLoader()
-
addTypeLoaderListenerAsWeakRef
public static void addTypeLoaderListenerAsWeakRef(ITypeLoaderListener listener)
-
getNamespacesFromTypeNames
public static Set<String> getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces)
-
pushTypeLoader
public static void pushTypeLoader(IModule module, ITypeLoader loader)
-
removeTypeLoader
public static void removeTypeLoader(Class<? extends ITypeLoader> loader)
-
getKeyType
public static IType getKeyType()
-
pushIncludeAll
public static void pushIncludeAll()
-
popIncludeAll
public static void popIncludeAll()
-
isIncludeAll
public static boolean isIncludeAll()
-
getDefaultTypeUsesMap
public static ITypeUsesMap getDefaultTypeUsesMap()
-
getCurrentCompilingType
public static IType getCurrentCompilingType()
-
pushCompilingType
public static void pushCompilingType(IType type)
-
popCompilingType
public static void popCompilingType()
-
pushSymTableCtx
public static void pushSymTableCtx(ISymbolTable ctx)
-
popSymTableCtx
public static void popSymTableCtx()
-
getSymTableCtx
public static ISymbolTable getSymTableCtx()
-
getTypeLoader
public static <T extends ITypeLoader> T getTypeLoader(Class<? extends T> loaderClass)
-
getTypeLoader
public static <T extends ITypeLoader> T getTypeLoader(Class<? extends T> loaderClass, IModule module)
-
getNameOfParams
public static String getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType)
-
getCompiledGosuClassSymbolTable
public static ISymbolTable getCompiledGosuClassSymbolTable()
-
getAllTypeLoaders
public static List<ITypeLoader> getAllTypeLoaders()
-
getGenericRelativeName
public static String getGenericRelativeName(IType type, boolean bRelativeBounds)
-
getGenericName
public static String getGenericName(IType type, boolean bRelative, boolean bRelativeBounds)
-
getPropertyInfo
public static IPropertyInfo getPropertyInfo(IType classBean, String strProperty, IFeatureFilter filter, IParserPart parserBase, IScriptabilityModifier scriptabilityConstraint) throws ParseException
- Throws:
ParseException
-
getProperties
public static List<? extends IPropertyInfo> getProperties(ITypeInfo beanInfo, IType classSource)
-
getMethods
public static List<? extends IMethodInfo> getMethods(ITypeInfo beanInfo, IType ownersIntrinsicType)
-
getJavaType
@Deprecated public static IType getJavaType(Class javaClass)
Deprecated.
-
getNameWithQualifiedTypeVariables
public static String getNameWithQualifiedTypeVariables(IType type)
-
getDefaultParameterizedTypeWithTypeVars
public static IType getDefaultParameterizedTypeWithTypeVars(IType type)
-
removeTypeLoaderListener
public static void removeTypeLoaderListener(ITypeLoaderListener listener)
-
getExecutionEnvironment
public static IExecutionEnvironment getExecutionEnvironment()
-
getExecutionEnvironment
public static IExecutionEnvironment getExecutionEnvironment(IProject project)
-
getCurrentModule
public static IModule getCurrentModule()
-
getOrCreateTypeReference
public static ITypeRef getOrCreateTypeReference(IType type)
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
public 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. 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
-
parseTypeLiteral
public static IType parseTypeLiteral(String typeName)
Parses a type name such as Iterable<Claim>.- Parameters:
typeName
- the name to parse- Returns:
- the type
-
isExpandable
public static boolean isExpandable(IType type)
-
getJavaClassInfo
public static IJavaClassInfo getJavaClassInfo(Class jClass)
-
getJavaClassInfo
public static IJavaClassInfo getJavaClassInfo(Class jClass, IModule module)
-
isBytecodeType
public static boolean isBytecodeType(IType type)
-
getTypeFromJavaBasedType
public static IType getTypeFromJavaBasedType(IJavaBackedType javaType)
-
getJavaClassInfo
public static IJavaClassInfo getJavaClassInfo(String fullyQualifiedName, IModule module)
-
pushModule
public static void pushModule(IModule gosuModule)
-
popModule
public static void popModule(IModule gosuModule)
-
getGosuClassLoader
public static IGosuClassLoader getGosuClassLoader()
-
dumpGosuClassLoader
public static void dumpGosuClassLoader()
-
getGlobalModule
public static IModule getGlobalModule()
-
getDefaultType
public static IMetaType getDefaultType()
-
shutdown
public static void shutdown(IExecutionEnvironment execEnv)
-
addShutdownListener
public static void addShutdownListener(TypeSystemShutdownListener listener)
-
getState
public static TypeSystemState getState()
-
refresh
public static void refresh(boolean bRefreshCaches)
-
refresh
public static void refresh(IModule module)
-
refresh
public static void refresh(ITypeRef typeRef)
Refresh just the specified type i.e., a gosu editor calls this on changes
-
refreshedFiles
public static void refreshedFiles(String[] filePaths)
DO NOT USE OR DELETE. Called form the debugging process (IDE).- Parameters:
filePaths
-
-
refreshed
public static void refreshed(IResource resource)
-
deleted
public static void deleted(IResource resource)
-
created
public static void created(IResource resource)
-
isDeleted
public static boolean isDeleted(IType type)
-
replaceTypeVariableTypeParametersWithBoundingTypes
public static IType replaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclosingType)
-
isParameterizedWith
public static boolean isParameterizedWith(IType type, ITypeVariableType... typeVar)
-
getJreModule
public static IModule getJreModule()
-
getFunctionalInterface
public static IType getFunctionalInterface(IFunctionType type)
-
-