org.eclipse.xtext.common.types.util
Class TypeConformanceComputer

java.lang.Object
  extended by org.eclipse.xtext.common.types.util.TypeConformanceComputer
Direct Known Subclasses:
JvmOnlyTypeConformanceComputer, XbaseTypeConformanceComputer

public class TypeConformanceComputer
extends java.lang.Object

Author:
Sven Efftinge - Initial contribution and API, Sebastian Zarnekow

Nested Class Summary
protected static class TypeConformanceComputer.ArgumentResolver
           
protected static class TypeConformanceComputer.MaxDistanceRawTypeAcceptor
          Populates a Multiset with the maximum number of necessary steps from a given type to its super types.
 
Field Summary
protected  TypesFactory factory
           
protected  AbstractConformanceVisitor<JvmTypeReference> leftDispatcher
           
protected  Primitives primitives
           
protected  SuperTypeCollector superTypeCollector
           
protected  TypeArgumentContextProvider typeArgumentContextProvider
           
protected  TypeReferences typeReferences
           
 
Constructor Summary
TypeConformanceComputer()
           
 
Method Summary
protected  boolean allTypesAreArrays(java.util.List<JvmTypeReference> types)
           
protected  boolean conformsToAll(JvmTypeReference type, java.util.List<JvmTypeReference> types)
           
protected  boolean containsPrimitiveOrAnyReferences(java.util.List<JvmTypeReference> types)
           
protected  TypeConformanceStrategySelector createStrategySelector()
           
protected  void cumulateDistance(java.util.List<JvmTypeReference> references, com.google.common.collect.Multimap<JvmType,JvmTypeReference> all, com.google.common.collect.Multiset<JvmType> cumulatedDistance)
          Keeps the cumulated distance for all the common raw super types of the given references.
protected  JvmType findContext(JvmTypeReference firstType)
           
 JvmTypeReference getCommonParameterSuperType(java.util.List<JvmTypeReference> types, java.util.List<JvmTypeReference> initiallyRequested)
           
 JvmTypeReference getCommonSuperType(java.util.List<JvmTypeReference> types)
          Compute the common super type for the given types.
protected  java.util.List<JvmTypeReference> getComponentTypes(java.util.List<JvmTypeReference> types)
           
protected  JvmTypeReference getFirstForRawType(com.google.common.collect.Multimap<JvmType,JvmTypeReference> all, JvmType rawType)
           
protected  Primitives getPrimitives()
           
protected  SuperTypeCollector getSuperTypeCollector()
           
protected  TypeArgumentContextProvider getTypeArgumentContextProvider()
           
protected  JvmTypeReference getTypeParametersForSupertype(com.google.common.collect.Multimap<JvmType,JvmTypeReference> all, JvmType rawType, java.util.List<JvmTypeReference> initiallyRequested)
           
protected  TypeReferences getTypeReferences()
           
protected  void initializeDistance(JvmTypeReference firstType, com.google.common.collect.Multimap<JvmType,JvmTypeReference> all, com.google.common.collect.Multiset<JvmType> cumulatedDistance)
           
protected  void inplaceSortByDistanceAndName(java.util.List<com.google.common.collect.Multiset.Entry<JvmType>> candidates)
           
protected  boolean isClass(JvmType type)
           
 boolean isConformant(JvmTypeReference left, JvmTypeReference right)
           
 boolean isConformant(JvmTypeReference left, JvmTypeReference right, boolean ignoreGenerics)
           
 TypeConformanceResult isConformant(JvmTypeReference left, JvmTypeReference right, TypeConformanceComputationArgument flags)
           
protected  boolean isPrimitiveType(JvmTypeReference reference)
           
protected  boolean isPrimitiveVoid(JvmTypeReference reference)
           
protected  java.util.List<JvmTypeReference> replacePrimitivesAndRemoveAnyReferences(java.util.List<JvmTypeReference> types)
           
 void setFactory(TypesFactory factory)
           
 void setPrimitives(Primitives primitives)
           
 void setSuperTypeCollector(SuperTypeCollector superTypeCollector)
           
 void setTypeArgumentContextProvider(TypeArgumentContextProvider typeArgumentContextProvider)
           
 void setTypeReferences(TypeReferences typeReferences)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftDispatcher

protected AbstractConformanceVisitor<JvmTypeReference> leftDispatcher

superTypeCollector

@Inject
protected SuperTypeCollector superTypeCollector

factory

@Inject
protected TypesFactory factory

typeArgumentContextProvider

@Inject
protected TypeArgumentContextProvider typeArgumentContextProvider

primitives

@Inject
protected Primitives primitives

typeReferences

@Inject
protected TypeReferences typeReferences
Constructor Detail

TypeConformanceComputer

public TypeConformanceComputer()
Method Detail

setSuperTypeCollector

public void setSuperTypeCollector(SuperTypeCollector superTypeCollector)

createStrategySelector

protected TypeConformanceStrategySelector createStrategySelector()

setPrimitives

public void setPrimitives(Primitives primitives)

setFactory

public void setFactory(TypesFactory factory)

setTypeArgumentContextProvider

public void setTypeArgumentContextProvider(TypeArgumentContextProvider typeArgumentContextProvider)

setTypeReferences

public void setTypeReferences(TypeReferences typeReferences)

isConformant

public boolean isConformant(JvmTypeReference left,
                            JvmTypeReference right)

isConformant

public boolean isConformant(JvmTypeReference left,
                            JvmTypeReference right,
                            boolean ignoreGenerics)

isConformant

public TypeConformanceResult isConformant(JvmTypeReference left,
                                          JvmTypeReference right,
                                          TypeConformanceComputationArgument flags)

isPrimitiveVoid

protected boolean isPrimitiveVoid(JvmTypeReference reference)

getCommonSuperType

public JvmTypeReference getCommonSuperType(java.util.List<JvmTypeReference> types)
Compute the common super type for the given types. May return null in case one of the types is primitive void but not all of them are.


isClass

protected boolean isClass(JvmType type)

findContext

protected JvmType findContext(JvmTypeReference firstType)

replacePrimitivesAndRemoveAnyReferences

protected java.util.List<JvmTypeReference> replacePrimitivesAndRemoveAnyReferences(java.util.List<JvmTypeReference> types)

containsPrimitiveOrAnyReferences

protected boolean containsPrimitiveOrAnyReferences(java.util.List<JvmTypeReference> types)

getComponentTypes

protected java.util.List<JvmTypeReference> getComponentTypes(java.util.List<JvmTypeReference> types)

allTypesAreArrays

protected boolean allTypesAreArrays(java.util.List<JvmTypeReference> types)

isPrimitiveType

protected boolean isPrimitiveType(JvmTypeReference reference)

getTypeParametersForSupertype

protected JvmTypeReference getTypeParametersForSupertype(com.google.common.collect.Multimap<JvmType,JvmTypeReference> all,
                                                         JvmType rawType,
                                                         java.util.List<JvmTypeReference> initiallyRequested)

getFirstForRawType

protected JvmTypeReference getFirstForRawType(com.google.common.collect.Multimap<JvmType,JvmTypeReference> all,
                                              JvmType rawType)

initializeDistance

protected void initializeDistance(JvmTypeReference firstType,
                                  com.google.common.collect.Multimap<JvmType,JvmTypeReference> all,
                                  com.google.common.collect.Multiset<JvmType> cumulatedDistance)

cumulateDistance

protected void cumulateDistance(java.util.List<JvmTypeReference> references,
                                com.google.common.collect.Multimap<JvmType,JvmTypeReference> all,
                                com.google.common.collect.Multiset<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<JvmType>> candidates)

getCommonParameterSuperType

public JvmTypeReference getCommonParameterSuperType(java.util.List<JvmTypeReference> types,
                                                    java.util.List<JvmTypeReference> initiallyRequested)

conformsToAll

protected boolean conformsToAll(JvmTypeReference type,
                                java.util.List<JvmTypeReference> types)

getTypeReferences

protected TypeReferences getTypeReferences()

getSuperTypeCollector

protected SuperTypeCollector getSuperTypeCollector()

getPrimitives

protected Primitives getPrimitives()

getTypeArgumentContextProvider

protected TypeArgumentContextProvider getTypeArgumentContextProvider()