Package gw.internal.gosu.parser
Class TypeLoaderAccess
java.lang.Object
gw.config.BaseService
gw.internal.gosu.parser.TypeLoaderAccess
- All Implemented Interfaces:
IService
,ITypeSystem
,IPluginHost
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interface
(package private) static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<CharSequence,
TypeLoaderAccess.TypeGetter> private boolean
private int
private int
private final CopyOnWriteArrayList<WeakReference<ITypeLoaderListener>>
private final List<TypeSystemShutdownListener>
private static final Map<CharSequence,
TypeLoaderAccess.TypeGetter> private static final ThreadLocal<ArrayList<IModule>>
private final TypeLoaderAccess.ArgCallable<IType,
Object> private final TypeLoaderAccess.ArgCallable<IType,
String> static LockingLazyVar<Map<String,
IJavaType>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
_genericInterfacesClash
(IType rhsType, IType lhsType) private static DefaultTypeLoader
private void
addGosuProxyClass
(IdentitySet<ITypeRef> allTypes, IType type) void
void
Maintains weak refs to listeners.boundTypes
(IType targetType, List<IType> typesToBound) boolean
private boolean
canCastCompountType
(ICompoundType lhsType, IType rhsType) private boolean
canCastMetaType
(IType lhsType, IType rhsType) void
private String
computeFullyQualifiedName
(Class<?> javaClass) void
private void
dumpMaps()
findParameterizedType
(IType type, IType rhsType) private void
private boolean
genericInterfacesClash
(IType rhsType, IType lhsType) get
(IJavaClassInfo javaClassInfo) Gets the intrinsic type for a given class info object.Gets the intrinsic type for a given class.getActualType
(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars) Set<? extends CharSequence>
Returns all type names in the system for all type loaders.getBoxType
(IType primitiveType) getByFullName
(String fullyQualifiedName) Gets an intrinsic type based on a fully-qualified name.getByFullNameIfValid
(String fullyQualifiedName) Gets a type based on a fully-qualified name.private IType
getByFullNameIfValid
(String fullyQualifiedName, boolean skipJava) getByFullNameIfValidNoJava
(String fullyQualifiedName) getByRelativeName
(String relativeName) getByRelativeName
(String relativeName, ITypeUsesMap typeUses) Gets an intrinsic type based on a relative name.getCompilingType
(String strName) getComponentType
(IType valueType) getCompoundType
(Set<IType> types) private ModuleTypeLoader
getDefaultType
(String name) (package private) Map<CharSequence,
TypeLoaderAccess.TypeGetter> private static void
getErrorType
(String strErrantName) private static ExecutionEnvironment
getExecutionEnvironment
(IProject project) getFromObject
(Object object) Returns the intrinsic type for the given Object.private ModuleTypeLoader
getIntrinsicTypeByFullName
(String fullyQualifiedName) getIntrinsicTypeFromObject
(Object object) getJavaType
(Class javaClass) private List<ITypeLoaderListener>
getNameOfParams
(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType) getNamespace
(String strFqNamespace) getNamespacesFromTypeNames
(Set<? extends CharSequence> allTypeNames, Set<String> namespaces) getOrCreateFunctionType
(String strFunctionName, IType retType, IType[] paramTypes) getOrCreateTypeVariableType
(String strName, IType boundingType, IType enclosingType) getPrimitiveType
(IType boxType) getPrimitiveType
(String name) int
int
private ITypeRef
getTopLevelType
(IType type) getTypeByRelativeNameIfValid_NoGenerics
(String relativeName, ITypeUsesMap typeUses) getTypeFromObject
(Object obj) <T extends ITypeLoader>
TgetTypeLoader
(Class<? extends T> loaderType, IModule module) getTypeReference
(IType type) String[]
getTypesForFile
(IModule module, IFile file) private boolean
void
void
inferTypeVariableTypesFromGenParamTypeAndConcreteType
(IType genParamType, IType argType, TypeVarToTypeMap map) void
inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse
(IType genParamType, IType argType, TypeVarToTypeMap map) private void
static TypeLoaderAccess
instance()
private boolean
isDefaultType
(String fqn) boolean
isExpandable
(IType type) boolean
boolean
isParameterizedWith
(IType type, ITypeVariableType... typeVars) private final boolean
isValidTypeName
(String fqn) makeGosucCompiler
(String gosucProjectFile, ICustomParser custParser) private void
mapBoxType
(IType boxType, IType primitiveType) mapTypeByVarName
(IType ownersType, IType declaringType) Converts a String name of a type into an IType.parseType
(String typeString, ITypeUsesMap typeUsesMap) parseType
(String typeString, TypeVarToTypeMap actualParamByVarName) parseType
(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) parseTypeExpression
(String typeString, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) void
void
void
void
void
pushCompilingType
(IType type) void
void
pushModule
(IModule module) void
void
pushTypeLoader
(ITypeLoader loader) void
pushTypeLoader
(IModule module, ITypeLoader typeLoader) void
refresh
(boolean clearCachedTypes) void
void
void
refreshed
(IResource file, String typeName, RefreshKind refreshKind) void
refreshTypes
(RefreshRequest request) void
removeTypeLoader
(Class<? extends ITypeLoader> loaderType) void
replaceTypeVariableTypeParametersWithBoundingTypes
(IType type, IType enclosingType) private <E,
A> E returnFirstNonNull
(TypeLoaderAccess.ArgCallable<E, A> callable, A argument) void
shutdown()
private String
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 Details
-
_boxToPrimitiveMap
-
_primitiveToBoxMap
-
PRIMITIVE_TYPES_BY_NAME
-
EMPTY_DEFAULT_TYPES
-
g_moduleStack
-
_iRefreshChecksum
private int _iRefreshChecksum -
_iSingleRefreshChecksum
private int _iSingleRefreshChecksum -
_defaultTypes
-
_defaultTypesIniting
private boolean _defaultTypesIniting -
_listeners
-
_shutdownListeners
-
getNamespaceTypeIfValid_Callable
-
getIntrinsicTypeFromObject_Callable
-
-
Constructor Details
-
TypeLoaderAccess
public TypeLoaderAccess()
-
-
Method Details
-
instance
-
getCurrentModuleTypeLoader
-
getCurrentModule
- Specified by:
getCurrentModule
in interfaceITypeSystem
-
pushModule
- Specified by:
pushModule
in interfaceITypeSystem
-
popModule
- Specified by:
popModule
in interfaceITypeSystem
-
makeGosucCompiler
- Specified by:
makeGosucCompiler
in interfaceITypeSystem
-
getDefaultType
-
isParameterizedWith
- Specified by:
isParameterizedWith
in interfaceITypeSystem
-
getCompoundType
- Specified by:
getCompoundType
in interfaceITypeSystem
-
getDefaultTypes
Map<CharSequence,TypeLoaderAccess.TypeGetter> getDefaultTypes() -
getAllTypeLoaders
- Specified by:
getAllTypeLoaders
in interfaceITypeSystem
-
pushTypeLoader
- Specified by:
pushTypeLoader
in interfaceITypeSystem
-
removeTypeLoader
- Specified by:
removeTypeLoader
in interfaceITypeSystem
-
getListeners
-
getTypeReference
- Specified by:
getTypeReference
in interfaceITypeSystem
-
getOrCreateTypeReference
- Specified by:
getOrCreateTypeReference
in interfaceITypeSystem
-
getTypeLoader
- Specified by:
getTypeLoader
in interfaceITypeSystem
-
getNamespace
- Specified by:
getNamespace
in interfaceITypeSystem
-
getIntrinsicTypeFromObject
-
getIntrinsicTypeByFullName
- 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
-
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
-
getGlobalModuleTypeLoader
-
addGosuProxyClass
-
getTopLevelType
-
getRefreshChecksum
public int getRefreshChecksum()- Specified by:
getRefreshChecksum
in interfaceITypeSystem
-
getSingleRefreshChecksum
public int getSingleRefreshChecksum()- Specified by:
getSingleRefreshChecksum
in interfaceITypeSystem
-
addTypeLoaderListenerAsWeakRef
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
- Specified by:
removeTypeLoaderListener
in interfaceITypeSystem
-
hasListener
-
fireRefreshed
private void fireRefreshed() -
incrementChecksums
public void incrementChecksums() -
getExecutionEnv
-
returnFirstNonNull
-
addShutdownListener
- Specified by:
addShutdownListener
in interfaceITypeSystem
-
getDefaultTypes
-
_getDefaultLoader
-
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.- 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:
-
unproxy
-
computeFullyQualifiedName
-
get
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
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:
-
getByRelativeName
- Specified by:
getByRelativeName
in interfaceITypeSystem
- Throws:
ClassNotFoundException
-
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.- 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
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
- Specified by:
getByFullNameIfValidNoJava
in interfaceITypeSystem
-
getByFullNameIfValid
-
isValidTypeName
-
isDefaultType
-
boundTypes
- Specified by:
boundTypes
in interfaceITypeSystem
-
refresh
- Specified by:
refresh
in interfaceITypeSystem
-
dumpMaps
private void dumpMaps() -
refresh
- Specified by:
refresh
in interfaceITypeSystem
-
refreshed
- Specified by:
refreshed
in interfaceITypeSystem
-
getTypesForFile
- Specified by:
getTypesForFile
in interfaceITypeSystem
-
parseType
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
- Specified by:
parseType
in interfaceITypeSystem
- Throws:
IllegalArgumentException
-
parseType
- 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
- Specified by:
getComponentType
in interfaceITypeSystem
-
getOrCreateTypeVariableType
public ITypeVariableType getOrCreateTypeVariableType(String strName, IType boundingType, IType enclosingType) - Specified by:
getOrCreateTypeVariableType
in interfaceITypeSystem
-
getOrCreateFunctionType
- Specified by:
getOrCreateFunctionType
in interfaceITypeSystem
-
getOrCreateFunctionType
public IFunctionType getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes) - Specified by:
getOrCreateFunctionType
in interfaceITypeSystem
-
mapTypeByVarName
- 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
- Specified by:
getErrorType
in interfaceITypeSystem
-
getErrorType
- Specified by:
getErrorType
in interfaceITypeSystem
-
getErrorType
- Specified by:
getErrorType
in interfaceITypeSystem
-
getDefaultTypeLoader
- Specified by:
getDefaultTypeLoader
in interfaceITypeSystem
-
findParameterizedType
- Specified by:
findParameterizedType
in interfaceITypeSystem
-
getNamespacesFromTypeNames
public Set<String> getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces) - Specified by:
getNamespacesFromTypeNames
in interfaceITypeSystem
-
pushTypeLoader
- 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
- Specified by:
getCurrentCompilingType
in interfaceITypeSystem
-
pushCompilingType
- Specified by:
pushCompilingType
in interfaceITypeSystem
-
popCompilingType
public void popCompilingType()- Specified by:
popCompilingType
in interfaceITypeSystem
-
getCompilingType
- Specified by:
getCompilingType
in interfaceITypeSystem
-
pushSymTableCtx
- Specified by:
pushSymTableCtx
in interfaceITypeSystem
-
popSymTableCtx
public void popSymTableCtx()- Specified by:
popSymTableCtx
in interfaceITypeSystem
-
getSymTableCtx
- Specified by:
getSymTableCtx
in interfaceITypeSystem
-
getTypeFromObject
- Specified by:
getTypeFromObject
in interfaceITypeSystem
-
isExpandable
- Specified by:
isExpandable
in interfaceITypeSystem
-
getNameOfParams
- Specified by:
getNameOfParams
in interfaceITypeSystem
-
getCompiledGosuClassSymbolTable
- Specified by:
getCompiledGosuClassSymbolTable
in interfaceITypeSystem
-
getJavaType
- Specified by:
getJavaType
in interfaceITypeSystem
-
getNameWithQualifiedTypeVariables
- Specified by:
getNameWithQualifiedTypeVariables
in interfaceITypeSystem
-
getDefaultParameterizedType
- Specified by:
getDefaultParameterizedType
in interfaceITypeSystem
-
getDefaultParameterizedTypeWithTypeVars
- Specified by:
getDefaultParameterizedTypeWithTypeVars
in interfaceITypeSystem
-
canCast
- Specified by:
canCast
in interfaceITypeSystem
-
canCastCompountType
-
genericInterfacesClash
-
_genericInterfacesClash
-
canCastMetaType
-
getPrimitiveType
- Specified by:
getPrimitiveType
in interfaceITypeSystem
-
getPrimitiveType
- Specified by:
getPrimitiveType
in interfaceITypeSystem
-
getBoxType
- Specified by:
getBoxType
in interfaceITypeSystem
-
getExpandableComponentType
- Specified by:
getExpandableComponentType
in interfaceITypeSystem
-
initBoxMapsIfNeeded
private void initBoxMapsIfNeeded() -
mapBoxType
-
getExecutionEnvironment
- Specified by:
getExecutionEnvironment
in interfaceITypeSystem
-
getExecutionEnvironment
- Specified by:
getExecutionEnvironment
in interfaceITypeSystem
-
getGosuClassLoader
- Specified by:
getGosuClassLoader
in interfaceITypeSystem
-
dumpGosuClassLoader
public void dumpGosuClassLoader()- Specified by:
dumpGosuClassLoader
in interfaceITypeSystem
-
replaceTypeVariableTypeParametersWithBoundingTypes
- Specified by:
replaceTypeVariableTypeParametersWithBoundingTypes
in interfaceITypeSystem
-
getDefaultType
- Specified by:
getDefaultType
in interfaceITypeSystem
-
getFunctionalInterface
- Specified by:
getFunctionalInterface
in interfaceITypeSystem
-