Package gw.internal.gosu.parser
Class TypeLord
- java.lang.Object
-
- gw.internal.gosu.parser.TypeLord
-
public class TypeLord extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static TypeSystemAwareCache<Pair<IType,IType>,java.lang.Boolean>ASSIGNABILITY_CACHEprivate static intDEFAULT_ASSIGNABILITY_CACHE_SIZE
-
Constructor Summary
Constructors Constructor Description TypeLord()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String_getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType, boolean bIncludeModule, java.util.Set<IType> visited)private static boolean_isRecursiveType(IType declaringClass, java.util.Set<IType> visited)private static boolean_isRecursiveType(ITypeVariableType subject, java.util.Set<IType> visited, IType... types)static voidaddAllClassesInClassHierarchy(IType type, java.util.Set<IType> set)static voidaddAllClassesInClassHierarchy(IType type, java.util.Set<IType> set, boolean bForce)private static voidaddAllClassesInClassHierarchy(IJavaClassInfo entityClass, java.util.Set<IJavaClassInfo> set)static voidaddAllClassesInClassHierarchy(java.lang.Class entityClass, java.util.Set<java.lang.Class> set)static voidaddNamespace(java.util.Set<java.lang.String> namespaces, java.lang.String strType)static voidaddReferencedTypeVarsThatAreNotInMap(IType type, TypeVarToTypeMap map)private static java.lang.StringBuilderappendTypeName(boolean bWithEnclosingType, boolean bIncludeModule, java.lang.StringBuilder sb, IType paramType, java.util.Set<IType> visited)private static booleanareAllTypesBlocks(java.util.List<? extends IType> types)static booleanareGenericOrParameterizedTypesAssignable(IType to, IType from)private static booleanareGenericOrParameterizedTypesAssignableInternal(IType to, IType from)private static booleanareTypeVariablesEquivalent(TypeVariableType possible, TypeVariableType inferred)static ITypeboundTypes(IType type, java.util.List<IType> typesToBound)static ITypeboundTypes(IType type, java.util.List<IType> typesToBound, boolean bKeepTypeVars)private static java.lang.BooleancompareWithDeclarationSiteVariance(IType to, IType from, int iIndex)static ITypederiveParameterizedTypeFromContext(IType type, IType contextType)static booleanencloses(IType type, IType inner)static booleanenclosingTypeInstanceInScope(IType type, IGosuClassInternal inner)private static ITypefindActualDeclaringType(IType ownersType, IType declaringType)static ITypefindGreatestLowerBound(IType t1, IType t2)static ITypefindLeastUpperBound(java.util.List<? extends IType> types)private static ITypefindLeastUpperBoundImpl(java.util.List<? extends IType> types, java.util.Set<IType> resolvingTypes)private static java.util.Set<IType>findLubForBlockTypes(java.util.List<? extends IBlockType> types, java.util.Set<IType> resolvingTypes)private static intfindNthPositionOfString(int n, java.lang.StringBuilder sb, java.lang.String str)private static java.util.Set<IType>findParameterizationLUBS(java.util.List<? extends IType> currentTypes, java.util.Set<IType> lubSet, java.util.Set<IType> resolvingTypes)static ITypefindParameterizedStructureType(IType structureType, IType from)static ITypefindParameterizedType(IType sourceType, IType rawGenericType)Finds a parameterized type in the ancestry of a given type.static ITypefindParameterizedType(IType sourceType, IType rawGenericType, boolean bForAssignability)static ITypefindParameterizedType_Reverse(IType sourceType, IType targetType)static ITypefindParameterizedTypeInHierarchy(IType sourceType, IType rawGenericType)(package private) static java.lang.StringfixSunInnerClassBug(java.lang.String type)static ITypegetActualType(IType type, TypeVarToTypeMap actualParamByVarName)static ITypegetActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)static ITypegetActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.Set<IType> visited)static ITypegetActualType(IAsmType type, TypeVarToTypeMap actualParamByVarName)static ITypegetActualType(IAsmType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.LinkedHashSet<IAsmType> recursiveTypes)static ITypegetActualType(java.lang.reflect.Type type, TypeVarToTypeMap actualParamByVarName)static ITypegetActualType(java.lang.reflect.Type type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)static ITypegetActualType(java.lang.reflect.Type type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.LinkedHashSet<java.lang.reflect.Type> recursiveTypes)static java.util.Set<IType>getAllClassesInClassHierarchyAsIntrinsicTypes(IType type)static java.util.Set<IType>getAllClassesInClassHierarchyAsIntrinsicTypes(IJavaClassInfo cls)static java.util.Set<IType>getArrayVersionsOfEachType(java.util.Set componentTypes)private static intgetAssignabilityCacheSize()static ITypegetBoxedTypeFromPrimitiveType(IType primitiveType)static ITypegetConcreteType(IType type)static ITypegetCoreType(IType type)static ITypegetDefaultParameterizedType(IType type)static ITypegetDefaultParameterizedTypeWithTypeVars(IType type)static ITypegetDefaultParameterizedTypeWithTypeVars(IType type, TypeVarToTypeMap map)static ITypegetDefaultParameterizedTypeWithTypeVars(IType type, TypeVarToTypeMap map, java.util.Set<IType> visited)static ITypegetExpandableComponentType(IType type)static ITypegetExpandableComponentType(IType type, boolean bCore)static ITypegetFunctionalInterface(IFunctionType funcType)private static intgetIndex(IType type)static ITypegetLeastUpperBoundForPrimitiveTypes(IType t0, IType t1)static java.lang.StringgetNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType)static java.lang.StringgetNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType, boolean bIncludeModule)static java.util.Set<java.lang.String>getNamespacesFromTypeNames(java.util.Set<? extends java.lang.CharSequence> typeNames, java.util.Set<java.lang.String> namespaces)static java.lang.StringgetNameWithBoundQualifiedTypeVariables(IType type, boolean includeModules)static java.lang.StringgetNameWithQualifiedTypeVariables(IType type, boolean includeModules)static ITypegetOuterMostEnclosingClass(IType innerClass)static IJavaClassInfogetOuterMostEnclosingClass(IJavaClassInfo innerClass)static <E extends IType>
EgetPureGenericType(E type)static ITypegetRootType(IType type)static ITypegetTopLevelType(IType type)static java.util.List<ITypeVariableType>getTypeVariables(IType type)static booleangetTypeVariables(IType type, java.util.function.Predicate<ITypeVariableType> cb)static booleanhasTypeVariable(IType type)private static ITypeinferringType(IType type, java.util.List<IType> currentlyInferringTypes, boolean bKeepTypeVars)static voidinferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap)static voidinferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap, java.util.HashSet<ITypeVariableType> inferredInCallStack, boolean bReverse)static voidinferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap)private static booleanisAWideningConversion(IType to, IType from)private static booleanisContravariantWildcardOnFunctionalInterface(AsmWildcardType typeArg, java.lang.String fqn)static booleanisDelegatableInterface(IType declaringType, IType iface)static booleanisEvalProgram(IType type)static booleanisExpandable(IType type)static booleanisParameterizedType(IType type)static booleanisParameterizedWith(IType type, TypeVariableType typeVar)static booleanisRecursiveType(IType declaringClass)static booleanisRecursiveType(ITypeVariableType subject, IType... types)static booleanisRecursiveType(IJavaType javaType)static booleanisRecursiveTypeFromBase(IType rootType)static booleanisSubtype(IType subtype, IType supertype)static ITypemakeDefaultParameterizedType(IType type)private static ITypemakeDefaultParameterizedTypeForCompoundType(IType type)static ITypemakeParameteredType(IType genType, TypeVarToTypeMap inferenceMap)private static TypeVarToTypeMapmapActualTypeByVarName(IType ownersType)private static TypeVarToTypeMapmapGenericTypeByVarName(IType ownersType)static TypeVarToTypeMapmapTypeByVarName(IType ownersType, IType declaringType)private static java.lang.reflect.TypemaybeGetLowerBound(java.lang.reflect.WildcardType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.LinkedHashSet<java.lang.reflect.Type> recursiveTypes)static ITypeparseType(java.lang.String strParameterizedTypeName, TypeVarToTypeMap actualParamByVarName)static ITypeparseType(java.lang.String strParameterizedTypeName, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)static ITypeLiteralExpressionparseTypeLiteral(java.lang.String strParameterizedTypeName, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)private static voidpruneNonLUBs(java.util.Set<IType> typeSet)(package private) static voidremoveDuplicateClassName(java.lang.StringBuilder sb, int dollarSignPosition)(package private) static booleanrepeatsWithDot(java.lang.StringBuilder sb)static ITypereplaceRawGenericTypesWithDefaultParameterizedTypes(IType type)static ITypereplaceTypeVariableTypeParametersWithBoundingTypes(IType type)static ITypereplaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclType)private static ITyperesolveParameterizedType(IType parameterizedType, TypeVarToTypeMap actualParamByVarName)private static booleansameAsDefaultProxiedType(IType to, IType from)private static ITypesolveType(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap, boolean bReverse, ITypeVariableType tvType, IType type)
-
-
-
Field Detail
-
ASSIGNABILITY_CACHE
private static final TypeSystemAwareCache<Pair<IType,IType>,java.lang.Boolean> ASSIGNABILITY_CACHE
-
DEFAULT_ASSIGNABILITY_CACHE_SIZE
private static final int DEFAULT_ASSIGNABILITY_CACHE_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAssignabilityCacheSize
private static int getAssignabilityCacheSize()
-
getAllClassesInClassHierarchyAsIntrinsicTypes
public static java.util.Set<IType> getAllClassesInClassHierarchyAsIntrinsicTypes(IJavaClassInfo cls)
-
getAllClassesInClassHierarchyAsIntrinsicTypes
public static java.util.Set<IType> getAllClassesInClassHierarchyAsIntrinsicTypes(IType type)
-
enclosingTypeInstanceInScope
public static boolean enclosingTypeInstanceInScope(IType type, IGosuClassInternal inner)
-
getArrayVersionsOfEachType
public static java.util.Set<IType> getArrayVersionsOfEachType(java.util.Set componentTypes)
-
getActualType
public static IType getActualType(java.lang.reflect.Type type, TypeVarToTypeMap actualParamByVarName)
-
getActualType
public static IType getActualType(java.lang.reflect.Type type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)
-
getActualType
public static IType getActualType(java.lang.reflect.Type type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.LinkedHashSet<java.lang.reflect.Type> recursiveTypes)
-
maybeGetLowerBound
private static java.lang.reflect.Type maybeGetLowerBound(java.lang.reflect.WildcardType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.LinkedHashSet<java.lang.reflect.Type> recursiveTypes)
-
getActualType
public static IType getActualType(IAsmType type, TypeVarToTypeMap actualParamByVarName)
-
getActualType
public static IType getActualType(IAsmType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.LinkedHashSet<IAsmType> recursiveTypes)
-
isContravariantWildcardOnFunctionalInterface
private static boolean isContravariantWildcardOnFunctionalInterface(AsmWildcardType typeArg, java.lang.String fqn)
-
getActualType
public static IType getActualType(IType type, TypeVarToTypeMap actualParamByVarName)
-
getActualType
public static IType getActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars)
-
getActualType
public static IType getActualType(IType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, java.util.Set<IType> visited)
-
isParameterizedWith
public static boolean isParameterizedWith(IType type, TypeVariableType typeVar)
-
parseType
public static IType parseType(java.lang.String strParameterizedTypeName, TypeVarToTypeMap actualParamByVarName)
-
parseType
public static IType parseType(java.lang.String strParameterizedTypeName, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap)
-
parseTypeLiteral
public static ITypeLiteralExpression parseTypeLiteral(java.lang.String strParameterizedTypeName, TypeVarToTypeMap actualParamByVarName, ITypeUsesMap typeUsesMap) throws ParseResultsException
- Throws:
ParseResultsException
-
resolveParameterizedType
private static IType resolveParameterizedType(IType parameterizedType, TypeVarToTypeMap actualParamByVarName)
-
mapTypeByVarName
public static TypeVarToTypeMap mapTypeByVarName(IType ownersType, IType declaringType)
-
makeParameteredType
public static IType makeParameteredType(IType genType, TypeVarToTypeMap inferenceMap)
-
findActualDeclaringType
private static IType findActualDeclaringType(IType ownersType, IType declaringType)
-
mapActualTypeByVarName
private static TypeVarToTypeMap mapActualTypeByVarName(IType ownersType)
-
mapGenericTypeByVarName
private static TypeVarToTypeMap mapGenericTypeByVarName(IType ownersType)
-
getNameWithQualifiedTypeVariables
public static java.lang.String getNameWithQualifiedTypeVariables(IType type, boolean includeModules)
-
getNameWithBoundQualifiedTypeVariables
public static java.lang.String getNameWithBoundQualifiedTypeVariables(IType type, boolean includeModules)
-
getNameOfParams
public static java.lang.String getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType)
-
getNameOfParams
public static java.lang.String getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType, boolean bIncludeModule)
-
_getNameOfParams
private static java.lang.String _getNameOfParams(IType[] paramTypes, boolean bRelative, boolean bWithEnclosingType, boolean bIncludeModule, java.util.Set<IType> visited)
-
appendTypeName
private static java.lang.StringBuilder appendTypeName(boolean bWithEnclosingType, boolean bIncludeModule, java.lang.StringBuilder sb, IType paramType, java.util.Set<IType> visited)
-
isDelegatableInterface
public static boolean isDelegatableInterface(IType declaringType, IType iface)
-
findParameterizedStructureType
public static IType findParameterizedStructureType(IType structureType, IType from)
-
getFunctionalInterface
public static IType getFunctionalInterface(IFunctionType funcType)
-
findParameterizedType
public static IType findParameterizedType(IType sourceType, IType rawGenericType)
Finds a parameterized type in the ancestry of a given type. For instance, given the type for ArrayList<Person> as the sourceType and List as the rawGenericType, returns List<Person>.- Parameters:
sourceType- The type to search in.rawGenericType- The raw generic type of the parameterized type to search for e.g., List is the raw generic type of List<String>.- Returns:
- A parameterization of rawGenericType corresponding with the type params of sourceType.
-
findParameterizedType
public static IType findParameterizedType(IType sourceType, IType rawGenericType, boolean bForAssignability)
-
findParameterizedType_Reverse
public static IType findParameterizedType_Reverse(IType sourceType, IType targetType)
-
findParameterizedTypeInHierarchy
public static IType findParameterizedTypeInHierarchy(IType sourceType, IType rawGenericType)
-
addAllClassesInClassHierarchy
public static void addAllClassesInClassHierarchy(java.lang.Class entityClass, java.util.Set<java.lang.Class> set)
-
addAllClassesInClassHierarchy
private static void addAllClassesInClassHierarchy(IJavaClassInfo entityClass, java.util.Set<IJavaClassInfo> set)
-
addAllClassesInClassHierarchy
public static void addAllClassesInClassHierarchy(IType type, java.util.Set<IType> set)
-
addAllClassesInClassHierarchy
public static void addAllClassesInClassHierarchy(IType type, java.util.Set<IType> set, boolean bForce)
-
getPureGenericType
public static <E extends IType> E getPureGenericType(E type)
-
deriveParameterizedTypeFromContext
public static IType deriveParameterizedTypeFromContext(IType type, IType contextType)
-
replaceTypeVariableTypeParametersWithBoundingTypes
public static IType replaceTypeVariableTypeParametersWithBoundingTypes(IType type)
-
replaceTypeVariableTypeParametersWithBoundingTypes
public static IType replaceTypeVariableTypeParametersWithBoundingTypes(IType type, IType enclType)
-
replaceRawGenericTypesWithDefaultParameterizedTypes
public static IType replaceRawGenericTypesWithDefaultParameterizedTypes(IType type)
-
makeDefaultParameterizedTypeForCompoundType
private static IType makeDefaultParameterizedTypeForCompoundType(IType type)
-
getDefaultParameterizedTypeWithTypeVars
public static IType getDefaultParameterizedTypeWithTypeVars(IType type)
-
getDefaultParameterizedTypeWithTypeVars
public static IType getDefaultParameterizedTypeWithTypeVars(IType type, TypeVarToTypeMap map)
-
getDefaultParameterizedTypeWithTypeVars
public static IType getDefaultParameterizedTypeWithTypeVars(IType type, TypeVarToTypeMap map, java.util.Set<IType> visited)
-
isRecursiveTypeFromBase
public static boolean isRecursiveTypeFromBase(IType rootType)
-
isRecursiveType
public static boolean isRecursiveType(IType declaringClass)
-
_isRecursiveType
private static boolean _isRecursiveType(IType declaringClass, java.util.Set<IType> visited)
-
fixSunInnerClassBug
static java.lang.String fixSunInnerClassBug(java.lang.String type)
-
findNthPositionOfString
private static int findNthPositionOfString(int n, java.lang.StringBuilder sb, java.lang.String str)
-
removeDuplicateClassName
static void removeDuplicateClassName(java.lang.StringBuilder sb, int dollarSignPosition)
-
repeatsWithDot
static boolean repeatsWithDot(java.lang.StringBuilder sb)
-
areGenericOrParameterizedTypesAssignable
public static boolean areGenericOrParameterizedTypesAssignable(IType to, IType from)
-
areGenericOrParameterizedTypesAssignableInternal
private static boolean areGenericOrParameterizedTypesAssignableInternal(IType to, IType from)
-
compareWithDeclarationSiteVariance
private static java.lang.Boolean compareWithDeclarationSiteVariance(IType to, IType from, int iIndex)
-
getNamespacesFromTypeNames
public static java.util.Set<java.lang.String> getNamespacesFromTypeNames(java.util.Set<? extends java.lang.CharSequence> typeNames, java.util.Set<java.lang.String> namespaces)
-
addNamespace
public static void addNamespace(java.util.Set<java.lang.String> namespaces, java.lang.String strType)
-
findLeastUpperBoundImpl
private static IType findLeastUpperBoundImpl(java.util.List<? extends IType> types, java.util.Set<IType> resolvingTypes)
-
findLubForBlockTypes
private static java.util.Set<IType> findLubForBlockTypes(java.util.List<? extends IBlockType> types, java.util.Set<IType> resolvingTypes)
-
areAllTypesBlocks
private static boolean areAllTypesBlocks(java.util.List<? extends IType> types)
-
getLeastUpperBoundForPrimitiveTypes
public static IType getLeastUpperBoundForPrimitiveTypes(IType t0, IType t1)
-
getIndex
private static int getIndex(IType type)
-
findParameterizationLUBS
private static java.util.Set<IType> findParameterizationLUBS(java.util.List<? extends IType> currentTypes, java.util.Set<IType> lubSet, java.util.Set<IType> resolvingTypes)
-
pruneNonLUBs
private static void pruneNonLUBs(java.util.Set<IType> typeSet)
-
isRecursiveType
public static boolean isRecursiveType(IJavaType javaType)
-
isRecursiveType
public static boolean isRecursiveType(ITypeVariableType subject, IType... types)
-
_isRecursiveType
private static boolean _isRecursiveType(ITypeVariableType subject, java.util.Set<IType> visited, IType... types)
-
getOuterMostEnclosingClass
public static IJavaClassInfo getOuterMostEnclosingClass(IJavaClassInfo innerClass)
-
isParameterizedType
public static boolean isParameterizedType(IType type)
-
isEvalProgram
public static boolean isEvalProgram(IType type)
-
addReferencedTypeVarsThatAreNotInMap
public static void addReferencedTypeVarsThatAreNotInMap(IType type, TypeVarToTypeMap map)
-
hasTypeVariable
public static boolean hasTypeVariable(IType type)
-
getTypeVariables
public static java.util.List<ITypeVariableType> getTypeVariables(IType type)
-
getTypeVariables
public static boolean getTypeVariables(IType type, java.util.function.Predicate<ITypeVariableType> cb)
-
isExpandable
public static boolean isExpandable(IType type)
-
getExpandableComponentType
public static IType getExpandableComponentType(IType type, boolean bCore)
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType
public static void inferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap)
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse
public static void inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap)
-
inferTypeVariableTypesFromGenParamTypeAndConcreteType
public static void inferTypeVariableTypesFromGenParamTypeAndConcreteType(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap, java.util.HashSet<ITypeVariableType> inferredInCallStack, boolean bReverse)
-
solveType
private static IType solveType(IType genParamType, IType argType, TypeVarToTypeMap inferenceMap, boolean bReverse, ITypeVariableType tvType, IType type)
-
getBoxedTypeFromPrimitiveType
public static IType getBoxedTypeFromPrimitiveType(IType primitiveType)
-
boundTypes
public static IType boundTypes(IType type, java.util.List<IType> typesToBound, boolean bKeepTypeVars)
-
inferringType
private static IType inferringType(IType type, java.util.List<IType> currentlyInferringTypes, boolean bKeepTypeVars)
-
areTypeVariablesEquivalent
private static boolean areTypeVariablesEquivalent(TypeVariableType possible, TypeVariableType inferred)
-
-