Package gw.internal.gosu.parser
Class TypeLoaderAccess
- java.lang.Object
-
- gw.config.BaseService
-
- gw.internal.gosu.parser.TypeLoaderAccess
-
- All Implemented Interfaces:
IService
,ITypeSystem
,IPluginHost
public class TypeLoaderAccess extends BaseService implements ITypeSystem
-
-
Field Summary
Fields Modifier and Type Field Description static LockingLazyVar<Map<String,IJavaType>>
PRIMITIVE_TYPES_BY_NAME
-
Constructor Summary
Constructors Constructor Description TypeLoaderAccess()
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gw.plugin.IPluginHost
getInterface
-
-
-
-
Field Detail
-
PRIMITIVE_TYPES_BY_NAME
public static LockingLazyVar<Map<String,IJavaType>> PRIMITIVE_TYPES_BY_NAME
-
-
Method Detail
-
instance
public static TypeLoaderAccess instance()
-
getCurrentModule
public Module getCurrentModule()
- Specified by:
getCurrentModule
in interfaceITypeSystem
-
pushModule
public void pushModule(IModule module)
- Specified by:
pushModule
in interfaceITypeSystem
-
popModule
public void popModule(IModule module)
- Specified by:
popModule
in interfaceITypeSystem
-
makeGosucCompiler
public IGosuc makeGosucCompiler(String gosucProjectFile, ICustomParser custParser)
- Specified by:
makeGosucCompiler
in interfaceITypeSystem
-
isParameterizedWith
public boolean isParameterizedWith(IType type, ITypeVariableType... typeVars)
- Specified by:
isParameterizedWith
in interfaceITypeSystem
-
getCompoundType
public IType getCompoundType(Set<IType> types)
- Specified by:
getCompoundType
in interfaceITypeSystem
-
getAllTypeLoaders
public List<ITypeLoader> getAllTypeLoaders()
- Specified by:
getAllTypeLoaders
in interfaceITypeSystem
-
pushTypeLoader
public void pushTypeLoader(IModule module, ITypeLoader typeLoader)
- Specified by:
pushTypeLoader
in interfaceITypeSystem
-
removeTypeLoader
public void removeTypeLoader(Class<? extends ITypeLoader> loaderType)
- Specified by:
removeTypeLoader
in interfaceITypeSystem
-
getTypeReference
public ITypeRef getTypeReference(IType type)
- Specified by:
getTypeReference
in interfaceITypeSystem
-
getOrCreateTypeReference
public ITypeRef getOrCreateTypeReference(IType type)
- Specified by:
getOrCreateTypeReference
in interfaceITypeSystem
-
getTypeLoader
public <T extends ITypeLoader> T getTypeLoader(Class<? extends T> loaderType, IModule module)
- Specified by:
getTypeLoader
in interfaceITypeSystem
-
getNamespace
public INamespaceType getNamespace(String strFqNamespace)
- Specified by:
getNamespace
in interfaceITypeSystem
-
getIntrinsicTypeByFullName
public IType getIntrinsicTypeByFullName(String fullyQualifiedName) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
getByRelativeName
public 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.- Specified by:
getByRelativeName
in interfaceITypeSystem
- 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
-
getTypeByRelativeNameIfValid_NoGenerics
public IType getTypeByRelativeNameIfValid_NoGenerics(String relativeName, ITypeUsesMap typeUses)
-
getAllTypeNames
public Set<? extends CharSequence> getAllTypeNames()
Description copied from interface:ITypeSystem
Returns all type names in the system for all type loaders.- Specified by:
getAllTypeNames
in interfaceITypeSystem
- Returns:
- all type names in the system.
-
clearErrorTypes
public void clearErrorTypes()
- Specified by:
clearErrorTypes
in interfaceITypeSystem
-
refresh
public void refresh(boolean clearCachedTypes)
- Specified by:
refresh
in interfaceITypeSystem
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceITypeSystem
-
refreshTypes
public void refreshTypes(RefreshRequest request)
-
getRefreshChecksum
public int getRefreshChecksum()
- Specified by:
getRefreshChecksum
in interfaceITypeSystem
-
getSingleRefreshChecksum
public int getSingleRefreshChecksum()
- Specified by:
getSingleRefreshChecksum
in interfaceITypeSystem
-
addTypeLoaderListenerAsWeakRef
public void addTypeLoaderListenerAsWeakRef(ITypeLoaderListener l)
Maintains weak refs to listeners. This is primarily so that tests don't accumulate a bunch of listeners over time. Otherwise this is a potential memory gobbler in tests.Note! Callers must manage the lifecycle of the listener, otherwise since this method creates a weak ref, it will be collected when it goes out of scope.
- Specified by:
addTypeLoaderListenerAsWeakRef
in interfaceITypeSystem
- Parameters:
l
- Your type loader listener
-
removeTypeLoaderListener
public void removeTypeLoaderListener(ITypeLoaderListener l)
- Specified by:
removeTypeLoaderListener
in interfaceITypeSystem
-
incrementChecksums
public void incrementChecksums()
-
addShutdownListener
public void addShutdownListener(TypeSystemShutdownListener listener)
- Specified by:
addShutdownListener
in interfaceITypeSystem
-
get
public 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.- Specified by:
get
in interfaceITypeSystem
- Parameters:
javaClass
- the Class to convert to an intrinsic type- Returns:
- the IType that corresponds to that class
- See Also:
getFromObject(Object)
-
get
public IType get(IJavaClassInfo javaClassInfo)
Description copied from interface:ITypeSystem
Gets the intrinsic type for a given class info object.- Specified by:
get
in interfaceITypeSystem
- Parameters:
javaClassInfo
- the Class info object to convert to an intrinsic type- Returns:
- the IType that corresponds to that class
-
getFromObject
public IType getFromObject(Object object)
Returns the intrinsic type for the given Object.- Specified by:
getFromObject
in interfaceITypeSystem
- Parameters:
object
- the object to get an IType for- Returns:
- the IType for the object
- See Also:
get(Class)
-
getByRelativeName
public IType getByRelativeName(String relativeName) throws ClassNotFoundException
- Specified by:
getByRelativeName
in interfaceITypeSystem
- Throws:
ClassNotFoundException
-
getByFullName
public 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.- Specified by:
getByFullName
in interfaceITypeSystem
- 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
-
getByFullNameIfValid
public 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 except instead of throwing it returns null.- Specified by:
getByFullNameIfValid
in interfaceITypeSystem
- Parameters:
fullyQualifiedName
- the fully qualified name of the type- Returns:
- the corresponding IType or null if the type does not exist
-
getByFullNameIfValidNoJava
public IType getByFullNameIfValidNoJava(String fullyQualifiedName)
- Specified by:
getByFullNameIfValidNoJava
in interfaceITypeSystem
-
boundTypes
public IType boundTypes(IType targetType, List<IType> typesToBound)
- Specified by:
boundTypes
in interfaceITypeSystem
-
refresh
public void refresh(ITypeRef typeRef)
- Specified by:
refresh
in interfaceITypeSystem
-
refresh
public void refresh(IModule module)
- Specified by:
refresh
in interfaceITypeSystem
-
refreshed
public void refreshed(IResource file, String typeName, RefreshKind refreshKind)
- Specified by:
refreshed
in interfaceITypeSystem
-
getTypesForFile
public String[] getTypesForFile(IModule module, IFile file)
- Specified by:
getTypesForFile
in interfaceITypeSystem
-
parseType
public IType parseType(String typeString) throws IllegalArgumentException
Converts a String name of a type into an IType.- Specified by:
parseType
in interfaceITypeSystem
- Throws:
IllegalArgumentException
- if the type string doesn't correspond to any known IType
-
parseType
public IType parseType(String typeString, ITypeUsesMap typeUsesMap) throws IllegalArgumentException
- Specified by:
parseType
in interfaceITypeSystem
- Throws:
IllegalArgumentException
-
parseType
public IType parseType(String typeString, TypeVarToTypeMap actualParamByVarName)
- Specified by:
parseType
in interfaceITypeSystem
-
parseType
public IType parseType(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)
- Specified by:
parseType
in interfaceITypeSystem
-
parseTypeExpression
public ITypeLiteralExpression parseTypeExpression(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) throws ParseResultsException
- Specified by:
parseTypeExpression
in interfaceITypeSystem
- Throws:
ParseResultsException
-
getComponentType
public IType getComponentType(IType valueType)
- Specified by:
getComponentType
in interfaceITypeSystem
-
getOrCreateTypeVariableType
public ITypeVariableType getOrCreateTypeVariableType(String strName, IType boundingType, IType enclosingType)
- Specified by:
getOrCreateTypeVariableType
in interfaceITypeSystem
-
getOrCreateFunctionType
public IFunctionType getOrCreateFunctionType(IMethodInfo mi)
- Specified by:
getOrCreateFunctionType
in interfaceITypeSystem
-
getOrCreateFunctionType
public IFunctionType getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes)
- Specified by:
getOrCreateFunctionType
in interfaceITypeSystem
-
mapTypeByVarName
public TypeVarToTypeMap mapTypeByVarName(IType ownersType, IType declaringType)
- Specified by:
mapTypeByVarName
in interfaceITypeSystem
-
getActualType
public IType getActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)
- Specified by:
getActualType
in interfaceITypeSystem
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType
public void inferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap map)
- Specified by:
inferTypeVariableTypesFromGenParamTypeAndConcreteType
in interfaceITypeSystem
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse
public void inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse(IType genParamType, IType argType, TypeVarToTypeMap map)
- Specified by:
inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse
in interfaceITypeSystem
-
getErrorType
public IErrorType getErrorType()
- Specified by:
getErrorType
in interfaceITypeSystem
-
getErrorType
public IErrorType getErrorType(String strErrantName)
- Specified by:
getErrorType
in interfaceITypeSystem
-
getErrorType
public IErrorType getErrorType(ParseResultsException pe)
- Specified by:
getErrorType
in interfaceITypeSystem
-
getDefaultTypeLoader
public IDefaultTypeLoader getDefaultTypeLoader()
- Specified by:
getDefaultTypeLoader
in interfaceITypeSystem
-
findParameterizedType
public IType findParameterizedType(IType type, IType rhsType)
- Specified by:
findParameterizedType
in interfaceITypeSystem
-
getNamespacesFromTypeNames
public Set<String> getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces)
- Specified by:
getNamespacesFromTypeNames
in interfaceITypeSystem
-
pushTypeLoader
public void pushTypeLoader(ITypeLoader loader)
- Specified by:
pushTypeLoader
in interfaceITypeSystem
-
pushIncludeAll
public void pushIncludeAll()
- Specified by:
pushIncludeAll
in interfaceITypeSystem
-
popIncludeAll
public void popIncludeAll()
- Specified by:
popIncludeAll
in interfaceITypeSystem
-
isIncludeAll
public boolean isIncludeAll()
- Specified by:
isIncludeAll
in interfaceITypeSystem
-
getCurrentCompilingType
public IType getCurrentCompilingType()
- Specified by:
getCurrentCompilingType
in interfaceITypeSystem
-
pushCompilingType
public void pushCompilingType(IType type)
- Specified by:
pushCompilingType
in interfaceITypeSystem
-
popCompilingType
public void popCompilingType()
- Specified by:
popCompilingType
in interfaceITypeSystem
-
getCompilingType
public IType getCompilingType(String strName)
- Specified by:
getCompilingType
in interfaceITypeSystem
-
pushSymTableCtx
public void pushSymTableCtx(ISymbolTable ctx)
- Specified by:
pushSymTableCtx
in interfaceITypeSystem
-
popSymTableCtx
public void popSymTableCtx()
- Specified by:
popSymTableCtx
in interfaceITypeSystem
-
getSymTableCtx
public ISymbolTable getSymTableCtx()
- Specified by:
getSymTableCtx
in interfaceITypeSystem
-
getTypeFromObject
public IType getTypeFromObject(Object obj)
- Specified by:
getTypeFromObject
in interfaceITypeSystem
-
isExpandable
public boolean isExpandable(IType type)
- Specified by:
isExpandable
in interfaceITypeSystem
-
getNameOfParams
public String getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType)
- Specified by:
getNameOfParams
in interfaceITypeSystem
-
getCompiledGosuClassSymbolTable
public ISymbolTable getCompiledGosuClassSymbolTable()
- Specified by:
getCompiledGosuClassSymbolTable
in interfaceITypeSystem
-
getJavaType
public IType getJavaType(Class javaClass)
- Specified by:
getJavaType
in interfaceITypeSystem
-
getNameWithQualifiedTypeVariables
public String getNameWithQualifiedTypeVariables(IType type)
- Specified by:
getNameWithQualifiedTypeVariables
in interfaceITypeSystem
-
getDefaultParameterizedType
public IType getDefaultParameterizedType(IType type)
- Specified by:
getDefaultParameterizedType
in interfaceITypeSystem
-
getDefaultParameterizedTypeWithTypeVars
public IType getDefaultParameterizedTypeWithTypeVars(IType type)
- Specified by:
getDefaultParameterizedTypeWithTypeVars
in interfaceITypeSystem
-
canCast
public boolean canCast(IType lhsType, IType rhsType)
- Specified by:
canCast
in interfaceITypeSystem
-
getPrimitiveType
public IJavaType getPrimitiveType(String name)
- Specified by:
getPrimitiveType
in interfaceITypeSystem
-
getPrimitiveType
public IType getPrimitiveType(IType boxType)
- Specified by:
getPrimitiveType
in interfaceITypeSystem
-
getBoxType
public IType getBoxType(IType primitiveType)
- Specified by:
getBoxType
in interfaceITypeSystem
-
getExpandableComponentType
public IType getExpandableComponentType(IType type)
- Specified by:
getExpandableComponentType
in interfaceITypeSystem
-
getExecutionEnvironment
public IExecutionEnvironment getExecutionEnvironment()
- Specified by:
getExecutionEnvironment
in interfaceITypeSystem
-
getExecutionEnvironment
public IExecutionEnvironment getExecutionEnvironment(IProject project)
- Specified by:
getExecutionEnvironment
in interfaceITypeSystem
-
getGosuClassLoader
public IGosuClassLoader getGosuClassLoader()
- Specified by:
getGosuClassLoader
in interfaceITypeSystem
-
dumpGosuClassLoader
public void dumpGosuClassLoader()
- Specified by:
dumpGosuClassLoader
in interfaceITypeSystem
-
replaceTypeVariableTypeParametersWithBoundingTypes
public IType replaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclosingType)
- Specified by:
replaceTypeVariableTypeParametersWithBoundingTypes
in interfaceITypeSystem
-
getDefaultType
public IMetaType getDefaultType()
- Specified by:
getDefaultType
in interfaceITypeSystem
-
getFunctionalInterface
public IType getFunctionalInterface(IFunctionType type)
- Specified by:
getFunctionalInterface
in interfaceITypeSystem
-
-