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 InvocationCountertyeLoadingCounterstatic InvocationCountertyeRequestCounter
-
Constructor Summary
Constructors Constructor Description TypeSystem()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddShutdownListener(TypeSystemShutdownListener listener)static voidaddTypeLoaderListenerAsWeakRef(ITypeLoaderListener listener)static ITypeboundTypes(IType targetType, List<IType> typesToBound)static IType[]boxPrimitiveTypeParams(IType[] typeParams)static booleancanCast(IType lhsType, IType rhsType)static voidclearErrorTypes()static voidcreated(IResource resource)static voidcreated(IResource resource, String typeName)static voiddeleted(IResource resource)static voiddeleted(IResource resource, String typeName)static voiddumpGosuClassLoader()static ITypefindParameterizedType(IType type, IType rhsType)static ITypeget(IJavaClassInfo javaClassInfo)static ITypeget(IJavaClassInfo classInfo, IModule module)static ITypeget(Class javaClass)Gets the intrinsic type for a given class.static ITypeget(Class javaClass, IModule module)static ITypegetActualType(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 ITypegetBoxType(IType primitiveType)static ITypegetByFullName(String fullyQualifiedName)Gets an intrinsic type based on a fully-qualified name.static ITypegetByFullName(String fullyQualifiedName, IModule module)static ITypegetByFullName(String fullyQualifiedName, String moduleName)Deprecated.call getByFullName( String, IModule )static ITypegetByFullNameIfValid(String fullyQualifiedName)Gets a type based on a fully-qualified name.static ITypegetByFullNameIfValid(String typeName, IModule module)static ITypegetByFullNameIfValidNoJava(String fullyQualifiedName)static ITypegetByRelativeName(String relativeName)static ITypegetByRelativeName(String relativeName, ITypeUsesMap typeUses)Gets an intrinsic type based on a relative name.static ISymbolTablegetCompiledGosuClassSymbolTable()static ITypegetCompilingType(String strName)static ITypegetComponentType(IType valueType)static ITypegetCompoundType(Set<IType> types)static ITypegetCurrentCompilingType()static IModulegetCurrentModule()static Method[]getDeclaredMethods(Class cls)static ITypegetDefaultParameterizedType(IType type)static ITypegetDefaultParameterizedTypeWithTypeVars(IType type)static IMetaTypegetDefaultType()static IDefaultTypeLoadergetDefaultTypeLoader()static ITypeUsesMapgetDefaultTypeUsesMap()static IErrorTypegetErrorType()static IErrorTypegetErrorType(ParseResultsException pe)static IErrorTypegetErrorType(String strErrantName)static IExecutionEnvironmentgetExecutionEnvironment()static IExecutionEnvironmentgetExecutionEnvironment(IProject project)static ITypegetFromObject(Object object)Returns the intrinsic type for the given Object.static ITypegetFromObject(Object object, IModule module)static ITypegetFunctionalInterface(IFunctionType type)static StringgetGenericName(IType type)static StringgetGenericName(IType type, boolean bRelative, boolean bRelativeBounds)static StringgetGenericRelativeName(IType type, boolean bRelativeBounds)static LockgetGlobalLock()static IModulegetGlobalModule()static IGosuClassLoadergetGosuClassLoader()static IJavaClassInfogetJavaClassInfo(Class jClass)static IJavaClassInfogetJavaClassInfo(Class jClass, IModule module)static IJavaClassInfogetJavaClassInfo(String fullyQualifiedName, IModule module)static ITypegetJavaType(Class javaClass)Deprecated.static IModulegetJreModule()static ITypegetKeyType()static List<? extends IMethodInfo>getMethods(ITypeInfo beanInfo, IType ownersIntrinsicType)static IModulegetModuleFromType(IType type)static StringgetNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType)static INamespaceTypegetNamespace(String strFqNamespace)static INamespaceTypegetNamespace(String strType, IModule module)static Set<String>getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces)static StringgetNameWithQualifiedTypeVariables(IType type)static IFunctionTypegetOrCreateFunctionType(IMethodInfo mi)static IFunctionTypegetOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes)static ITypeRefgetOrCreateTypeReference(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 ITypeVariableTypegetOrCreateTypeVariableType(String strName, IType boundingType, IType enclosingType)static ITypegetPrimitiveType(IType boxType)static IJavaTypegetPrimitiveType(String name)static List<? extends IPropertyInfo>getProperties(ITypeInfo beanInfo, IType classSource)static IPropertyInfogetPropertyInfo(IType classBean, String strProperty, IFeatureFilter filter, IParserPart parserBase, IScriptabilityModifier scriptabilityConstraint)static <E extends IType>
EgetPureGenericType(E type)static intgetRefreshChecksum()static intgetSingleRefreshChecksum()static TypeSystemStategetState()static ISymbolTablegetSymTableCtx()static ITypegetTypeFromJavaBackedType(IType type)static ITypegetTypeFromJavaBasedType(IJavaBackedType javaType)static ITypegetTypeFromObject(Object obj)static <T extends ITypeLoader>
TgetTypeLoader(Class<? extends T> loaderClass)static <T extends ITypeLoader>
TgetTypeLoader(Class<? extends T> loaderClass, IModule module)static ITypeRefgetTypeReference(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 StringgetUnqualifiedClassName(IType cls)static voidinferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap map, boolean bReverse)static booleanisBeanType(IType typeSource)static booleanisBoxedTypeFor(IType primitiveType, IType boxedType)static booleanisBytecodeType(IType type)static booleanisDeleted(IType type)static booleanisExpandable(IType type)static booleanisIncludeAll()static booleanisNumericType(IType intrType)static booleanisParameterizedWith(IType type, ITypeVariableType... typeVar)static voidlock()Acquires the global type-system lockstatic TypeVarToTypeMapmapTypeByVarName(IType ownersType, IType declaringType)static ITypeparseType(String typeString)Converts a String name of a type into an IType.static ITypeparseType(String typeString, ITypeUsesMap typeUsesMap)static ITypeparseType(String typeString, TypeVarToTypeMap actualParamByVarName)static ITypeparseType(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)static ITypeLiteralExpressionparseTypeExpression(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)static ITypeparseTypeLiteral(String typeName)Parses a type name such as Iterable<Claim>.static voidpopCompilingType()static voidpopGlobalModule()static voidpopIncludeAll()static voidpopModule(IModule gosuModule)static voidpopSymTableCtx()static voidpushCompilingType(IType type)static voidpushGlobalModule()static voidpushIncludeAll()static voidpushModule(IModule gosuModule)static voidpushSymTableCtx(ISymbolTable ctx)static voidpushTypeLoader(IModule module, ITypeLoader loader)static voidrefresh(boolean bRefreshCaches)static voidrefresh(ITypeRef typeRef)Refresh just the specified type i.e., a gosu editor calls this on changesstatic voidrefresh(IModule module)static voidrefreshed(IResource resource)static voidrefreshedFiles(String[] filePaths)DO NOT USE OR DELETE.static voidremoveTypeLoader(Class<? extends ITypeLoader> loader)static voidremoveTypeLoaderListener(ITypeLoaderListener listener)static ITypereplaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclosingType)static voidshutdown(IExecutionEnvironment execEnv)static voidunlock()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.
Note: you should use this method only if you do not have an Object of classjavaClassto 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)
-
-