Class TypeConformanceComputer
- java.lang.Object
-
- org.eclipse.xtext.xbase.typesystem.conformance.RawTypeConformanceComputer
-
- org.eclipse.xtext.xbase.typesystem.conformance.TypeConformanceComputer
-
public class TypeConformanceComputer extends RawTypeConformanceComputer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
TypeConformanceComputer.CommonSuperTypeFinder
Extracted helper class to compute the common super type of an arbitrary list of given types.protected static class
TypeConformanceComputer.ListSizeMemento
protected static class
TypeConformanceComputer.MaxDistanceRawTypeAcceptor
Populates aMultiset
with the maximum number of necessary steps from a given type to its super types.
-
Field Summary
-
Fields inherited from class org.eclipse.xtext.xbase.typesystem.conformance.RawTypeConformanceComputer
ALLOW_BOXING, ALLOW_BOXING_UNBOXING, ALLOW_FUNCTION_CONVERSION, ALLOW_PRIMITIVE_WIDENING, ALLOW_RAW_TYPE_CONVERSION, ALLOW_SYNONYMS, ALLOW_UNBOXING, AS_NESTED_TYPE_ARGUMENT, AS_TYPE_ARGUMENT, BOXING, DEMAND_CONVERSION, INCOMPATIBLE, PRIMITIVE_WIDENING, RAW_TYPE, RAW_TYPE_CONVERSION, SUBTYPE, SUCCESS, SYNONYM, UNBOUND_COMPUTATION_ADDS_HINTS, UNBOXING, UNKNOWN_TYPE_PARTICIPATED
-
-
Constructor Summary
Constructors Constructor Description TypeConformanceComputer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addComponentType(LightweightTypeReference reference, java.util.List<LightweightTypeReference> result)
protected LightweightTypeReference
conformsToAll(LightweightTypeReference type, java.util.List<LightweightTypeReference> types)
protected boolean
containsPrimitiveOrAnyReferences(java.util.List<LightweightTypeReference> types)
protected void
cumulateDistance(java.util.List<LightweightTypeReference> references, com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, com.google.common.collect.Multiset<org.eclipse.xtext.common.types.JvmType> cumulatedDistance)
Keeps the cumulated distance for all the common raw super types of the given references.protected int
doIsConformant(FunctionTypeReference left, FunctionTypeReference right, int flags)
protected int
doIsConformantOuterType(LightweightTypeReference left, LightweightTypeReference right, int flags)
protected int
doIsConformantTypeArguments(LightweightTypeReference left, LightweightTypeReference right, int flags)
This is a hook for theTypeConformanceComputer
to implement the type argument check.protected boolean
enhanceSuperType(java.util.List<LightweightTypeReference> superTypes, java.util.List<LightweightTypeReference> initiallyRequested, ParameterizedTypeReference result)
LightweightTypeReference
getCommonParameterSuperType(java.util.List<LightweightTypeReference> types, java.util.List<LightweightTypeReference> initiallyRequested, ITypeReferenceOwner owner)
LightweightTypeReference
getCommonSuperType(java.util.List<LightweightTypeReference> types, ITypeReferenceOwner owner)
Compute the common super type for the given types.protected LightweightTypeReference
getFirstForRawType(com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, org.eclipse.xtext.common.types.JvmType rawType)
LightweightTypeReference
getMostSpecialType(java.util.List<LightweightTypeReference> candidates)
protected LightweightTypeReference
getSuperType(ParameterizedTypeReference current, org.eclipse.xtext.common.types.JvmType type)
This is a hook for theTypeConformanceComputer
to provide the resolved super type.protected LightweightTypeReference
getTypeParametersForSupertype(com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, org.eclipse.xtext.common.types.JvmType rawType, ITypeReferenceOwner owner, java.util.List<LightweightTypeReference> initiallyRequested)
protected void
initializeDistance(LightweightTypeReference firstType, com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, com.google.common.collect.Multiset<org.eclipse.xtext.common.types.JvmType> cumulatedDistance)
protected void
inplaceSortByDistanceAndName(java.util.List<com.google.common.collect.Multiset.Entry<org.eclipse.xtext.common.types.JvmType>> candidates)
protected boolean
isClass(org.eclipse.xtext.common.types.JvmType type)
boolean
isConformant(LightweightTypeReference left, LightweightTypeReference right)
int
isConformant(LightweightTypeReference left, LightweightTypeReference right, int flags)
int
isConformant(LightweightTypeReference left, LightweightTypeReference right, TypeConformanceComputationArgument argument)
protected boolean
isRecursiveRequest(java.util.List<LightweightTypeReference> types, java.util.Set<java.lang.String> allNames, java.util.List<LightweightTypeReference> initiallyRequested)
protected TypeConformanceComputer.CommonSuperTypeFinder
newCommonSuperTypeFinder(ITypeReferenceOwner owner)
protected java.util.List<LightweightTypeReference>
replacePrimitivesAndRemoveAnyReferences(java.util.List<LightweightTypeReference> types)
protected int
toFlags(TypeConformanceComputationArgument argument)
-
Methods inherited from class org.eclipse.xtext.xbase.typesystem.conformance.RawTypeConformanceComputer
addHintAndAnnounceSuccess, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformant, doIsConformantOuter, doIsConformantToAnyType, internalGetPrimitiveKindFromWrapper, isAssignableAsFunctionType, isConformantMergeResult, isConformantToConstraints, isSynonymConformant, setSynonymTypesProvider, tryResolveAndCheckConformance, tryResolveAndCheckConformance
-
-
-
-
Method Detail
-
isConformant
public boolean isConformant(LightweightTypeReference left, LightweightTypeReference right)
-
isConformant
public int isConformant(LightweightTypeReference left, LightweightTypeReference right, TypeConformanceComputationArgument argument)
-
toFlags
protected int toFlags(TypeConformanceComputationArgument argument)
-
isConformant
public int isConformant(LightweightTypeReference left, LightweightTypeReference right, int flags)
- Overrides:
isConformant
in classRawTypeConformanceComputer
-
getSuperType
protected LightweightTypeReference getSuperType(ParameterizedTypeReference current, org.eclipse.xtext.common.types.JvmType type)
Description copied from class:RawTypeConformanceComputer
This is a hook for theTypeConformanceComputer
to provide the resolved super type.- Overrides:
getSuperType
in classRawTypeConformanceComputer
-
doIsConformantTypeArguments
protected int doIsConformantTypeArguments(LightweightTypeReference left, LightweightTypeReference right, int flags)
Description copied from class:RawTypeConformanceComputer
This is a hook for theTypeConformanceComputer
to implement the type argument check.- Overrides:
doIsConformantTypeArguments
in classRawTypeConformanceComputer
-
doIsConformantOuterType
protected int doIsConformantOuterType(LightweightTypeReference left, LightweightTypeReference right, int flags)
-
doIsConformant
protected int doIsConformant(FunctionTypeReference left, FunctionTypeReference right, int flags)
- Overrides:
doIsConformant
in classRawTypeConformanceComputer
-
getCommonSuperType
public LightweightTypeReference getCommonSuperType(java.util.List<LightweightTypeReference> types, ITypeReferenceOwner owner)
Compute the common super type for the given types. May returnnull
in case one of the types is primitive void but not all of them are.
-
newCommonSuperTypeFinder
protected TypeConformanceComputer.CommonSuperTypeFinder newCommonSuperTypeFinder(ITypeReferenceOwner owner)
-
isClass
protected boolean isClass(org.eclipse.xtext.common.types.JvmType type)
-
initializeDistance
protected void initializeDistance(LightweightTypeReference firstType, com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, com.google.common.collect.Multiset<org.eclipse.xtext.common.types.JvmType> cumulatedDistance)
-
cumulateDistance
protected void cumulateDistance(java.util.List<LightweightTypeReference> references, com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, com.google.common.collect.Multiset<org.eclipse.xtext.common.types.JvmType> cumulatedDistance)
Keeps the cumulated distance for all the common raw super types of the given references. Interfaces that are more directly implemented will get a lower total count than more general interfaces.
-
inplaceSortByDistanceAndName
protected void inplaceSortByDistanceAndName(java.util.List<com.google.common.collect.Multiset.Entry<org.eclipse.xtext.common.types.JvmType>> candidates)
-
replacePrimitivesAndRemoveAnyReferences
protected java.util.List<LightweightTypeReference> replacePrimitivesAndRemoveAnyReferences(java.util.List<LightweightTypeReference> types)
-
containsPrimitiveOrAnyReferences
protected boolean containsPrimitiveOrAnyReferences(java.util.List<LightweightTypeReference> types)
-
getFirstForRawType
protected LightweightTypeReference getFirstForRawType(com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, org.eclipse.xtext.common.types.JvmType rawType)
-
getTypeParametersForSupertype
@Deprecated protected final LightweightTypeReference getTypeParametersForSupertype(com.google.common.collect.Multimap<org.eclipse.xtext.common.types.JvmType,LightweightTypeReference> all, org.eclipse.xtext.common.types.JvmType rawType, ITypeReferenceOwner owner, java.util.List<LightweightTypeReference> initiallyRequested)
Deprecated.Logic was moved to inner class CommonSuperTypeFinder in the context of bug 495314. This method is scheduled for deletion in Xtext 2.15
-
enhanceSuperType
@Deprecated protected final boolean enhanceSuperType(java.util.List<LightweightTypeReference> superTypes, java.util.List<LightweightTypeReference> initiallyRequested, ParameterizedTypeReference result)
Deprecated.Logic was moved to inner class CommonSuperTypeFinder in the context of bug 495314. This method is scheduled for deletion in Xtext 2.15
-
getCommonParameterSuperType
@Deprecated public final LightweightTypeReference getCommonParameterSuperType(java.util.List<LightweightTypeReference> types, java.util.List<LightweightTypeReference> initiallyRequested, ITypeReferenceOwner owner)
Logic was moved to inner class CommonSuperTypeFinder in the context of bug 495314. This method is scheduled for deletion in Xtext 2.15
-
isRecursiveRequest
@Deprecated protected final boolean isRecursiveRequest(java.util.List<LightweightTypeReference> types, java.util.Set<java.lang.String> allNames, java.util.List<LightweightTypeReference> initiallyRequested)
Logic was moved to inner class CommonSuperTypeFinder in the context of bug 495314. This method is scheduled for deletion in Xtext 2.15
-
getMostSpecialType
public LightweightTypeReference getMostSpecialType(java.util.List<LightweightTypeReference> candidates)
-
addComponentType
protected void addComponentType(LightweightTypeReference reference, java.util.List<LightweightTypeReference> result)
-
conformsToAll
protected LightweightTypeReference conformsToAll(LightweightTypeReference type, java.util.List<LightweightTypeReference> types)
-
-