Class TypeSystem


  • public class TypeSystem
    extends Object
    • Constructor Detail

      • TypeSystem

        public TypeSystem()
    • 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 class javaClass to get the type from. If you do have such an object, use getFromObject(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)
      • 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,
                                              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 type
        typeUses - 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,
                                          IModule module)
      • 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)
      • getByFullNameIfValid

        public static IType getByFullNameIfValid​(String typeName,
                                                 IModule module)
      • 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
      • 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()
      • getComponentType

        public static IType getComponentType​(IType valueType)
      • 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.
      • getPureGenericType

        public static <E extends IType> E getPureGenericType​(E type)
      • isBeanType

        public static boolean isBeanType​(IType typeSource)
      • isNumericType

        public static boolean isNumericType​(IType intrType)
      • isBoxedTypeFor

        public static boolean isBoxedTypeFor​(IType primitiveType,
                                             IType boxedType)
      • 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)
      • findParameterizedType

        public static IType findParameterizedType​(IType type,
                                                  IType rhsType)
      • addTypeLoaderListenerAsWeakRef

        public static void addTypeLoaderListenerAsWeakRef​(ITypeLoaderListener listener)
      • 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()
      • getCompilingType

        public static IType getCompilingType​(String strName)
      • pushCompilingType

        public static void pushCompilingType​(IType type)
      • popCompilingType

        public static void popCompilingType()
      • getUnqualifiedClassName

        public static String getUnqualifiedClassName​(IType cls)
      • 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()
      • getGenericRelativeName

        public static String getGenericRelativeName​(IType type,
                                                    boolean bRelativeBounds)
      • getGenericName

        public static String getGenericName​(IType type)
      • getGenericName

        public static String getGenericName​(IType type,
                                            boolean bRelative,
                                            boolean bRelativeBounds)
      • getNameWithQualifiedTypeVariables

        public static String getNameWithQualifiedTypeVariables​(IType type)
      • getDefaultParameterizedType

        public static IType getDefaultParameterizedType​(IType type)
      • getDefaultParameterizedTypeWithTypeVars

        public static IType getDefaultParameterizedTypeWithTypeVars​(IType type)
      • canCast

        public static boolean canCast​(IType lhsType,
                                      IType rhsType)
      • removeTypeLoaderListener

        public static void removeTypeLoaderListener​(ITypeLoaderListener listener)
      • getPrimitiveType

        public static IJavaType getPrimitiveType​(String name)
      • getPrimitiveType

        public static IType getPrimitiveType​(IType boxType)
      • getBoxType

        public static IType getBoxType​(IType primitiveType)
      • boxPrimitiveTypeParams

        public static IType[] boxPrimitiveTypeParams​(IType[] typeParams)
      • 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
      • getTypeFromObject

        public static IType getTypeFromObject​(Object obj)
      • 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)
      • getDeclaredMethods

        public static Method[] getDeclaredMethods​(Class cls)
      • isBytecodeType

        public static boolean isBytecodeType​(IType type)
      • getTypeFromJavaBackedType

        public static IType getTypeFromJavaBackedType​(IType type)
      • getTypeFromJavaBasedType

        public static IType getTypeFromJavaBasedType​(IJavaBackedType javaType)
      • getModuleFromType

        public static IModule getModuleFromType​(IType type)
      • pushModule

        public static void pushModule​(IModule gosuModule)
      • popModule

        public static void popModule​(IModule gosuModule)
      • dumpGosuClassLoader

        public static void dumpGosuClassLoader()
      • getGlobalModule

        public static IModule getGlobalModule()
      • getDefaultType

        public static IMetaType getDefaultType()
      • getTypesForFile

        public static String[] getTypesForFile​(IModule module,
                                               IFile file)
      • 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)
      • deleted

        public static void deleted​(IResource resource,
                                   String typeName)
      • created

        public static void created​(IResource resource)
      • created

        public static void created​(IResource resource,
                                   String typeName)
      • 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()
      • getCompoundType

        public static IType getCompoundType​(Set<IType> types)
      • getFunctionalInterface

        public static IType getFunctionalInterface​(IFunctionType type)