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 booleanprivate intprivate intprivate 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 DefaultTypeLoaderprivate voidaddGosuProxyClass(IdentitySet<ITypeRef> allTypes, IType type) voidvoidMaintains weak refs to listeners.boundTypes(IType targetType, List<IType> typesToBound) booleanprivate booleancanCastCompountType(ICompoundType lhsType, IType rhsType) private booleancanCastMetaType(IType lhsType, IType rhsType) voidprivate StringcomputeFullyQualifiedName(Class<?> javaClass) voidprivate voiddumpMaps()findParameterizedType(IType type, IType rhsType) private voidprivate booleangenericInterfacesClash(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 ITypegetByFullNameIfValid(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 ModuleTypeLoadergetDefaultType(String name) (package private) Map<CharSequence,TypeLoaderAccess.TypeGetter> private static voidgetErrorType(String strErrantName) private static ExecutionEnvironmentgetExecutionEnvironment(IProject project) getFromObject(Object object) Returns the intrinsic type for the given Object.private ModuleTypeLoadergetIntrinsicTypeByFullName(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) intintprivate ITypeRefgetTopLevelType(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 booleanvoidvoidinferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap map) voidinferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse(IType genParamType, IType argType, TypeVarToTypeMap map) private voidstatic TypeLoaderAccessinstance()private booleanisDefaultType(String fqn) booleanisExpandable(IType type) booleanbooleanisParameterizedWith(IType type, ITypeVariableType... typeVars) private final booleanisValidTypeName(String fqn) makeGosucCompiler(String gosucProjectFile, ICustomParser custParser) private voidmapBoxType(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) voidvoidvoidvoidvoidpushCompilingType(IType type) voidvoidpushModule(IModule module) voidvoidpushTypeLoader(ITypeLoader loader) voidpushTypeLoader(IModule module, ITypeLoader typeLoader) voidrefresh(boolean clearCachedTypes) voidvoidvoidrefreshed(IResource file, String typeName, RefreshKind refreshKind) voidrefreshTypes(RefreshRequest request) voidremoveTypeLoader(Class<? extends ITypeLoader> loaderType) voidreplaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclosingType) private <E,A> E returnFirstNonNull(TypeLoaderAccess.ArgCallable<E, A> callable, A argument) voidshutdown()private StringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getCurrentModulein interfaceITypeSystem
-
pushModule
- Specified by:
pushModulein interfaceITypeSystem
-
popModule
- Specified by:
popModulein interfaceITypeSystem
-
makeGosucCompiler
- Specified by:
makeGosucCompilerin interfaceITypeSystem
-
getDefaultType
-
isParameterizedWith
- Specified by:
isParameterizedWithin interfaceITypeSystem
-
getCompoundType
- Specified by:
getCompoundTypein interfaceITypeSystem
-
getDefaultTypes
Map<CharSequence,TypeLoaderAccess.TypeGetter> getDefaultTypes() -
getAllTypeLoaders
- Specified by:
getAllTypeLoadersin interfaceITypeSystem
-
pushTypeLoader
- Specified by:
pushTypeLoaderin interfaceITypeSystem
-
removeTypeLoader
- Specified by:
removeTypeLoaderin interfaceITypeSystem
-
getListeners
-
getTypeReference
- Specified by:
getTypeReferencein interfaceITypeSystem
-
getOrCreateTypeReference
- Specified by:
getOrCreateTypeReferencein interfaceITypeSystem
-
getTypeLoader
- Specified by:
getTypeLoaderin interfaceITypeSystem
-
getNamespace
- Specified by:
getNamespacein 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:
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
-
getAllTypeNames
Description copied from interface:ITypeSystemReturns all type names in the system for all type loaders.- Specified by:
getAllTypeNamesin interfaceITypeSystem- Returns:
- all type names in the system.
-
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
-
getGlobalModuleTypeLoader
-
addGosuProxyClass
-
getTopLevelType
-
getRefreshChecksum
public int getRefreshChecksum()- Specified by:
getRefreshChecksumin interfaceITypeSystem
-
getSingleRefreshChecksum
public int getSingleRefreshChecksum()- Specified by:
getSingleRefreshChecksumin 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:
addTypeLoaderListenerAsWeakRefin interfaceITypeSystem- Parameters:
l- Your type loader listener
-
removeTypeLoaderListener
- Specified by:
removeTypeLoaderListenerin interfaceITypeSystem
-
hasListener
-
fireRefreshed
private void fireRefreshed() -
incrementChecksums
public void incrementChecksums() -
getExecutionEnv
-
returnFirstNonNull
-
addShutdownListener
- Specified by:
addShutdownListenerin interfaceITypeSystem
-
getDefaultTypes
-
_getDefaultLoader
-
get
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:
-
unproxy
-
computeFullyQualifiedName
-
get
Description copied from interface:ITypeSystemGets the intrinsic type for a given class info object.- Specified by:
getin 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:
getFromObjectin interfaceITypeSystem- Parameters:
object- the object to get an IType for- Returns:
- the IType for the object
- See Also:
-
getByRelativeName
- Specified by:
getByRelativeNamein 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:
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
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
- Specified by:
getByFullNameIfValidNoJavain interfaceITypeSystem
-
getByFullNameIfValid
-
isValidTypeName
-
isDefaultType
-
boundTypes
- Specified by:
boundTypesin interfaceITypeSystem
-
refresh
- Specified by:
refreshin interfaceITypeSystem
-
dumpMaps
private void dumpMaps() -
refresh
- Specified by:
refreshin interfaceITypeSystem
-
refreshed
- Specified by:
refreshedin interfaceITypeSystem
-
getTypesForFile
- Specified by:
getTypesForFilein interfaceITypeSystem
-
parseType
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
- Specified by:
parseTypein interfaceITypeSystem- Throws:
IllegalArgumentException
-
parseType
- 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
- Specified by:
getComponentTypein interfaceITypeSystem
-
getOrCreateTypeVariableType
public ITypeVariableType getOrCreateTypeVariableType(String strName, IType boundingType, IType enclosingType) - Specified by:
getOrCreateTypeVariableTypein interfaceITypeSystem
-
getOrCreateFunctionType
- Specified by:
getOrCreateFunctionTypein interfaceITypeSystem
-
getOrCreateFunctionType
public IFunctionType getOrCreateFunctionType(String strFunctionName, IType retType, IType[] paramTypes) - Specified by:
getOrCreateFunctionTypein interfaceITypeSystem
-
mapTypeByVarName
- 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
- Specified by:
getErrorTypein interfaceITypeSystem
-
getErrorType
- Specified by:
getErrorTypein interfaceITypeSystem
-
getErrorType
- Specified by:
getErrorTypein interfaceITypeSystem
-
getDefaultTypeLoader
- Specified by:
getDefaultTypeLoaderin interfaceITypeSystem
-
findParameterizedType
- Specified by:
findParameterizedTypein interfaceITypeSystem
-
getNamespacesFromTypeNames
public Set<String> getNamespacesFromTypeNames(Set<? extends CharSequence> allTypeNames, Set<String> namespaces) - Specified by:
getNamespacesFromTypeNamesin interfaceITypeSystem
-
pushTypeLoader
- 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
- Specified by:
getCurrentCompilingTypein interfaceITypeSystem
-
pushCompilingType
- Specified by:
pushCompilingTypein interfaceITypeSystem
-
popCompilingType
public void popCompilingType()- Specified by:
popCompilingTypein interfaceITypeSystem
-
getCompilingType
- Specified by:
getCompilingTypein interfaceITypeSystem
-
pushSymTableCtx
- Specified by:
pushSymTableCtxin interfaceITypeSystem
-
popSymTableCtx
public void popSymTableCtx()- Specified by:
popSymTableCtxin interfaceITypeSystem
-
getSymTableCtx
- Specified by:
getSymTableCtxin interfaceITypeSystem
-
getTypeFromObject
- Specified by:
getTypeFromObjectin interfaceITypeSystem
-
isExpandable
- Specified by:
isExpandablein interfaceITypeSystem
-
getNameOfParams
- Specified by:
getNameOfParamsin interfaceITypeSystem
-
getCompiledGosuClassSymbolTable
- Specified by:
getCompiledGosuClassSymbolTablein interfaceITypeSystem
-
getJavaType
- Specified by:
getJavaTypein interfaceITypeSystem
-
getNameWithQualifiedTypeVariables
- Specified by:
getNameWithQualifiedTypeVariablesin interfaceITypeSystem
-
getDefaultParameterizedType
- Specified by:
getDefaultParameterizedTypein interfaceITypeSystem
-
getDefaultParameterizedTypeWithTypeVars
- Specified by:
getDefaultParameterizedTypeWithTypeVarsin interfaceITypeSystem
-
canCast
- Specified by:
canCastin interfaceITypeSystem
-
canCastCompountType
-
genericInterfacesClash
-
_genericInterfacesClash
-
canCastMetaType
-
getPrimitiveType
- Specified by:
getPrimitiveTypein interfaceITypeSystem
-
getPrimitiveType
- Specified by:
getPrimitiveTypein interfaceITypeSystem
-
getBoxType
- Specified by:
getBoxTypein interfaceITypeSystem
-
getExpandableComponentType
- Specified by:
getExpandableComponentTypein interfaceITypeSystem
-
initBoxMapsIfNeeded
private void initBoxMapsIfNeeded() -
mapBoxType
-
getExecutionEnvironment
- Specified by:
getExecutionEnvironmentin interfaceITypeSystem
-
getExecutionEnvironment
- Specified by:
getExecutionEnvironmentin interfaceITypeSystem
-
getGosuClassLoader
- Specified by:
getGosuClassLoaderin interfaceITypeSystem
-
dumpGosuClassLoader
public void dumpGosuClassLoader()- Specified by:
dumpGosuClassLoaderin interfaceITypeSystem
-
replaceTypeVariableTypeParametersWithBoundingTypes
- Specified by:
replaceTypeVariableTypeParametersWithBoundingTypesin interfaceITypeSystem
-
getDefaultType
- Specified by:
getDefaultTypein interfaceITypeSystem
-
getFunctionalInterface
- Specified by:
getFunctionalInterfacein interfaceITypeSystem
-