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:
getCurrentModulein interfaceITypeSystem
-
pushModule
public void pushModule(IModule module)
- Specified by:
pushModulein interfaceITypeSystem
-
popModule
public void popModule(IModule module)
- Specified by:
popModulein interfaceITypeSystem
-
makeGosucCompiler
public IGosuc makeGosucCompiler(String gosucProjectFile, ICustomParser custParser)
- Specified by:
makeGosucCompilerin interfaceITypeSystem
-
isParameterizedWith
public boolean isParameterizedWith(IType type, ITypeVariableType... typeVars)
- Specified by:
isParameterizedWithin interfaceITypeSystem
-
getCompoundType
public IType getCompoundType(Set<IType> types)
- Specified by:
getCompoundTypein interfaceITypeSystem
-
getAllTypeLoaders
public List<ITypeLoader> getAllTypeLoaders()
- Specified by:
getAllTypeLoadersin interfaceITypeSystem
-
pushTypeLoader
public void pushTypeLoader(IModule module, ITypeLoader typeLoader)
- Specified by:
pushTypeLoaderin interfaceITypeSystem
-
removeTypeLoader
public void removeTypeLoader(Class<? extends ITypeLoader> loaderType)
- Specified by:
removeTypeLoaderin interfaceITypeSystem
-
getTypeReference
public ITypeRef getTypeReference(IType type)
- Specified by:
getTypeReferencein interfaceITypeSystem
-
getOrCreateTypeReference
public ITypeRef getOrCreateTypeReference(IType type)
- Specified by:
getOrCreateTypeReferencein interfaceITypeSystem
-
getTypeLoader
public <T extends ITypeLoader> T getTypeLoader(Class<? extends T> loaderType, IModule module)
- Specified by:
getTypeLoaderin interfaceITypeSystem
-
getNamespace
public INamespaceType getNamespace(String strFqNamespace)
- Specified by:
getNamespacein 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:
getByRelativeNamein 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()
- Specified by:
getAllTypeNamesin interfaceITypeSystem
-
clearErrorTypes
public void clearErrorTypes()
- Specified by:
clearErrorTypesin interfaceITypeSystem
-
refresh
public void refresh(boolean clearCachedTypes)
- Specified by:
refreshin interfaceITypeSystem
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceITypeSystem
-
refreshTypes
public void refreshTypes(RefreshRequest request)
-
getRefreshChecksum
public int getRefreshChecksum()
- Specified by:
getRefreshChecksumin interfaceITypeSystem
-
getSingleRefreshChecksum
public int getSingleRefreshChecksum()
- Specified by:
getSingleRefreshChecksumin 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:
addTypeLoaderListenerAsWeakRefin interfaceITypeSystem- Parameters:
l- Your type loader listener
-
removeTypeLoaderListener
public void removeTypeLoaderListener(ITypeLoaderListener l)
- Specified by:
removeTypeLoaderListenerin interfaceITypeSystem
-
incrementChecksums
public void incrementChecksums()
-
addShutdownListener
public void addShutdownListener(TypeSystemShutdownListener listener)
- Specified by:
addShutdownListenerin interfaceITypeSystem
-
get
public 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.- Specified by:
getin 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)
- Specified by:
getin interfaceITypeSystem
-
getFromObject
public IType getFromObject(Object object)
Returns the intrinsic type for the given Object.- Specified by:
getFromObjectin 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:
getByRelativeNamein 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:
getByFullNamein 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:
getByFullNameIfValidin 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:
getByFullNameIfValidNoJavain interfaceITypeSystem
-
boundTypes
public IType boundTypes(IType targetType, List<IType> typesToBound)
- Specified by:
boundTypesin interfaceITypeSystem
-
refresh
public void refresh(ITypeRef typeRef)
- Specified by:
refreshin interfaceITypeSystem
-
refresh
public void refresh(IModule module)
- Specified by:
refreshin interfaceITypeSystem
-
refreshed
public void refreshed(IResource file, String typeName, RefreshKind refreshKind)
- Specified by:
refreshedin interfaceITypeSystem
-
getTypesForFile
public String[] getTypesForFile(IModule module, IFile file)
- Specified by:
getTypesForFilein interfaceITypeSystem
-
parseType
public IType parseType(String typeString) throws IllegalArgumentException
Converts a String name of a type into an IType.- Specified by:
parseTypein 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:
parseTypein interfaceITypeSystem- Throws:
IllegalArgumentException
-
parseType
public IType parseType(String typeString, TypeVarToTypeMap actualParamByVarName)
- Specified by:
parseTypein interfaceITypeSystem
-
parseType
public IType parseType(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)
- Specified by:
parseTypein interfaceITypeSystem
-
parseTypeExpression
public ITypeLiteralExpression parseTypeExpression(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) throws ParseResultsException
- Specified by:
parseTypeExpressionin interfaceITypeSystem- Throws:
ParseResultsException
-
getComponentType
public IType getComponentType(IType valueType)
- Specified by:
getComponentTypein interfaceITypeSystem
-
getOrCreateTypeVariableType
public ITypeVariableType getOrCreateTypeVariableType(String strName, IType boundingType, IType enclosingType)
- Specified by:
getOrCreateTypeVariableTypein interfaceITypeSystem
-
getOrCreateFunctionType
public IFunctionType getOrCreateFunctionType(IMethodInfo mi)
- Specified by:
getOrCreateFunctionTypein interfaceITypeSystem
-
getOrCreateFunctionType
public IFunctionType getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes)
- Specified by:
getOrCreateFunctionTypein interfaceITypeSystem
-
mapTypeByVarName
public TypeVarToTypeMap mapTypeByVarName(IType ownersType, IType declaringType)
- Specified by:
mapTypeByVarNamein interfaceITypeSystem
-
getActualType
public IType getActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)
- Specified by:
getActualTypein interfaceITypeSystem
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType
public void inferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap map)
- Specified by:
inferTypeVariableTypesFromGenParamTypeAndConcreteTypein interfaceITypeSystem
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse
public void inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse(IType genParamType, IType argType, TypeVarToTypeMap map)
- Specified by:
inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reversein interfaceITypeSystem
-
getErrorType
public IErrorType getErrorType()
- Specified by:
getErrorTypein interfaceITypeSystem
-
getErrorType
public IErrorType getErrorType(String strErrantName)
- Specified by:
getErrorTypein interfaceITypeSystem
-
getErrorType
public IErrorType getErrorType(ParseResultsException pe)
- Specified by:
getErrorTypein interfaceITypeSystem
-
getDefaultTypeLoader
public IDefaultTypeLoader getDefaultTypeLoader()
- Specified by:
getDefaultTypeLoaderin interfaceITypeSystem
-
findParameterizedType
public IType findParameterizedType(IType type, IType rhsType)
- Specified by:
findParameterizedTypein interfaceITypeSystem
-
getNamespacesFromTypeNames
public Set<String> getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces)
- Specified by:
getNamespacesFromTypeNamesin interfaceITypeSystem
-
pushTypeLoader
public void pushTypeLoader(ITypeLoader loader)
- Specified by:
pushTypeLoaderin interfaceITypeSystem
-
pushIncludeAll
public void pushIncludeAll()
- Specified by:
pushIncludeAllin interfaceITypeSystem
-
popIncludeAll
public void popIncludeAll()
- Specified by:
popIncludeAllin interfaceITypeSystem
-
isIncludeAll
public boolean isIncludeAll()
- Specified by:
isIncludeAllin interfaceITypeSystem
-
getCurrentCompilingType
public IType getCurrentCompilingType()
- Specified by:
getCurrentCompilingTypein interfaceITypeSystem
-
pushCompilingType
public void pushCompilingType(IType type)
- Specified by:
pushCompilingTypein interfaceITypeSystem
-
popCompilingType
public void popCompilingType()
- Specified by:
popCompilingTypein interfaceITypeSystem
-
getCompilingType
public IType getCompilingType(String strName)
- Specified by:
getCompilingTypein interfaceITypeSystem
-
pushSymTableCtx
public void pushSymTableCtx(ISymbolTable ctx)
- Specified by:
pushSymTableCtxin interfaceITypeSystem
-
popSymTableCtx
public void popSymTableCtx()
- Specified by:
popSymTableCtxin interfaceITypeSystem
-
getSymTableCtx
public ISymbolTable getSymTableCtx()
- Specified by:
getSymTableCtxin interfaceITypeSystem
-
getTypeFromObject
public IType getTypeFromObject(Object obj)
- Specified by:
getTypeFromObjectin interfaceITypeSystem
-
isExpandable
public boolean isExpandable(IType type)
- Specified by:
isExpandablein interfaceITypeSystem
-
getNameOfParams
public String getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType)
- Specified by:
getNameOfParamsin interfaceITypeSystem
-
getCompiledGosuClassSymbolTable
public ISymbolTable getCompiledGosuClassSymbolTable()
- Specified by:
getCompiledGosuClassSymbolTablein interfaceITypeSystem
-
getJavaType
public IType getJavaType(Class javaClass)
- Specified by:
getJavaTypein interfaceITypeSystem
-
getNameWithQualifiedTypeVariables
public String getNameWithQualifiedTypeVariables(IType type)
- Specified by:
getNameWithQualifiedTypeVariablesin interfaceITypeSystem
-
getDefaultParameterizedType
public IType getDefaultParameterizedType(IType type)
- Specified by:
getDefaultParameterizedTypein interfaceITypeSystem
-
getDefaultParameterizedTypeWithTypeVars
public IType getDefaultParameterizedTypeWithTypeVars(IType type)
- Specified by:
getDefaultParameterizedTypeWithTypeVarsin interfaceITypeSystem
-
canCast
public boolean canCast(IType lhsType, IType rhsType)
- Specified by:
canCastin interfaceITypeSystem
-
getPrimitiveType
public IJavaType getPrimitiveType(String name)
- Specified by:
getPrimitiveTypein interfaceITypeSystem
-
getPrimitiveType
public IType getPrimitiveType(IType boxType)
- Specified by:
getPrimitiveTypein interfaceITypeSystem
-
getBoxType
public IType getBoxType(IType primitiveType)
- Specified by:
getBoxTypein interfaceITypeSystem
-
getExpandableComponentType
public IType getExpandableComponentType(IType type)
- Specified by:
getExpandableComponentTypein interfaceITypeSystem
-
getExecutionEnvironment
public IExecutionEnvironment getExecutionEnvironment()
- Specified by:
getExecutionEnvironmentin interfaceITypeSystem
-
getExecutionEnvironment
public IExecutionEnvironment getExecutionEnvironment(IProject project)
- Specified by:
getExecutionEnvironmentin interfaceITypeSystem
-
getGosuClassLoader
public IGosuClassLoader getGosuClassLoader()
- Specified by:
getGosuClassLoaderin interfaceITypeSystem
-
dumpGosuClassLoader
public void dumpGosuClassLoader()
- Specified by:
dumpGosuClassLoaderin interfaceITypeSystem
-
replaceTypeVariableTypeParametersWithBoundingTypes
public IType replaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclosingType)
- Specified by:
replaceTypeVariableTypeParametersWithBoundingTypesin interfaceITypeSystem
-
getDefaultType
public IMetaType getDefaultType()
- Specified by:
getDefaultTypein interfaceITypeSystem
-
getFunctionalInterface
public IType getFunctionalInterface(IFunctionType type)
- Specified by:
getFunctionalInterfacein interfaceITypeSystem
-
-