org.eclipse.xtext.xbase.typing
Class AbstractTypeProvider

java.lang.Object
  extended by org.eclipse.xtext.xbase.typing.AbstractTypeProvider
All Implemented Interfaces:
ITypeProvider
Direct Known Subclasses:
XbaseTypeProvider

public abstract class AbstractTypeProvider
extends java.lang.Object
implements ITypeProvider

Author:
Sven Efftinge - Initial contribution and API

Nested Class Summary
static class AbstractTypeProvider.EarlyExitAcceptor
           
protected static class AbstractTypeProvider.ImmutableLinkedItem<T>
           
 
Field Summary
protected  org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<XExpression> getExpectedType
           
protected  org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<Pair<XExpression,JvmTypeReference>> getType
           
protected  org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<JvmIdentifiableElement> getTypeForIdentifiable
           
 
Constructor Summary
AbstractTypeProvider()
           
 
Method Summary
protected  void _earlyExits(org.eclipse.emf.ecore.EObject expr, AbstractTypeProvider.EarlyExitAcceptor acceptor)
           
protected  void _earlyExits(JvmTypeReference ref, AbstractTypeProvider.EarlyExitAcceptor a)
          Computes early exits of type references.
protected  void _earlyExits(java.lang.Void expr, AbstractTypeProvider.EarlyExitAcceptor a)
          Computes early exits of null.
protected  JvmTypeReference _expectedType(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, int index, boolean rawType)
           
protected  JvmTypeReference _type(XExpression expression, JvmTypeReference rawExpectation, boolean rawType)
           
protected  JvmTypeReference _typeForIdentifiable(JvmIdentifiableElement identifiable, boolean rawType)
           
protected  void checkIsSingelton()
           
protected
<T> JvmTypeReference
doGetType(java.lang.String key, T object, boolean rawType, org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<T> typeComputer)
           
protected  JvmTypeReference expectedType(org.eclipse.emf.ecore.EObject container, org.eclipse.emf.ecore.EReference reference, int index, boolean rawType)
           
 JvmTypeReference getCommonReturnType(XExpression expression, boolean assumeImplicitReturnExpression)
          The return type of an expression is the common super type of all types used within a return expression.
protected  JvmConstructor getConstructor(XConstructorCall expr)
           
protected  JvmConstructor getConstructor(XConstructorCall expr, boolean resolve)
           
protected  Triple<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EReference,java.lang.Integer> getContainingInfo(XExpression obj)
           
protected  java.lang.String getDebugIndentation(boolean rawType)
           
 JvmTypeReference getExpectedType(XExpression expression)
          Return the resolved expected type of the given expression.
 JvmTypeReference getExpectedType(XExpression expression, boolean rawType)
           
protected  JvmIdentifiableElement getFeature(XAbstractFeatureCall expr)
           
protected  JvmIdentifiableElement getFeature(XAbstractFeatureCall expr, boolean resolve)
           
protected  ILogicalContainerProvider getLogicalContainerProvider()
           
protected  org.eclipse.emf.ecore.EObject getLogicalOrRealContainer(org.eclipse.emf.ecore.EObject obj)
           
protected
<T> T
getLogicalOrRealContainer(org.eclipse.emf.ecore.EObject obj, java.lang.Class<T> type)
           
protected  JvmTypeParameterDeclarator getNearestTypeParameterDeclarator(org.eclipse.emf.ecore.EObject obj)
           
 java.lang.Iterable<JvmTypeReference> getThrownExceptionTypes(XExpression expression)
          returns all exception types, thrown within the given expression.
 JvmTypeReference getType(XExpression expression)
          Return the resolved type of the given expression.
 JvmTypeReference getType(XExpression expression, boolean rawType)
           
 JvmTypeReference getType(XExpression expression, JvmTypeReference rawExpectation, boolean rawType)
           
protected  TypeArgumentContextProvider getTypeArgumentContextProvider()
           
protected  TypeConformanceComputer getTypeConformanceComputer()
           
 JvmTypeReference getTypeForIdentifiable(JvmIdentifiableElement identifiableElement)
          Return the resolved type of the element.
 JvmTypeReference getTypeForIdentifiable(JvmIdentifiableElement identifiableElement, boolean rawType)
           
protected  TypeReferences getTypeReferences()
           
protected  JvmTypeReference handleCycleGetExpectedType(XExpression expression, boolean rawType)
          Allows to handle cyclic resolution of expected types.
protected  JvmTypeReference handleCycleGetTypeForIdentifiable(JvmIdentifiableElement identifiableElement, boolean rawType)
          Allows to handle cyclic resolution of types.
protected  JvmTypeReference handleCyclicGetType(XExpression expression, JvmTypeReference rawExpectation, boolean rawType)
          Allows to handle cyclic type resolution.
protected  void internalCollectEarlyExits(org.eclipse.emf.ecore.EObject expr, AbstractTypeProvider.EarlyExitAcceptor acceptor)
           
protected  boolean isDeclaratorOf(JvmTypeParameterDeclarator declarator, JvmTypeParameter param)
           
protected  boolean isResolved(JvmTypeReference reference, JvmTypeParameterDeclarator declarator, boolean rawType)
           
protected  boolean isResolved(JvmTypeReference reference, JvmTypeParameterDeclarator declarator, boolean rawType, boolean allowAnyType, java.util.Set<JvmTypeReference> visited)
           
protected  JvmTypeReference type(XExpression expression, JvmTypeReference rawExpectation, boolean rawType)
           
protected  JvmTypeReference typeForIdentifiable(JvmIdentifiableElement identifiable, boolean rawType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.xtext.xbase.typing.ITypeProvider
getExpectedReturnType, getThrownExceptionForIdentifiable, getTypeArgumentContext, getTypeArgumentContext
 

Field Detail

getType

protected org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<Pair<XExpression,JvmTypeReference>> getType

getExpectedType

protected org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<XExpression> getExpectedType

getTypeForIdentifiable

protected org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<JvmIdentifiableElement> getTypeForIdentifiable
Constructor Detail

AbstractTypeProvider

public AbstractTypeProvider()
Method Detail

checkIsSingelton

protected void checkIsSingelton()

isResolved

protected boolean isResolved(JvmTypeReference reference,
                             JvmTypeParameterDeclarator declarator,
                             boolean rawType)

isResolved

protected boolean isResolved(JvmTypeReference reference,
                             JvmTypeParameterDeclarator declarator,
                             boolean rawType,
                             boolean allowAnyType,
                             java.util.Set<JvmTypeReference> visited)

getNearestTypeParameterDeclarator

protected JvmTypeParameterDeclarator getNearestTypeParameterDeclarator(org.eclipse.emf.ecore.EObject obj)

getLogicalOrRealContainer

protected org.eclipse.emf.ecore.EObject getLogicalOrRealContainer(org.eclipse.emf.ecore.EObject obj)

getLogicalOrRealContainer

protected <T> T getLogicalOrRealContainer(org.eclipse.emf.ecore.EObject obj,
                                          java.lang.Class<T> type)

isDeclaratorOf

protected boolean isDeclaratorOf(JvmTypeParameterDeclarator declarator,
                                 JvmTypeParameter param)

_type

protected JvmTypeReference _type(XExpression expression,
                                 JvmTypeReference rawExpectation,
                                 boolean rawType)
Parameters:
rawExpectation - the expected raw type if set from the outside. May be null.
rawType - true if we are only interested in the raw type

getFeature

protected JvmIdentifiableElement getFeature(XAbstractFeatureCall expr,
                                            boolean resolve)

getFeature

protected JvmIdentifiableElement getFeature(XAbstractFeatureCall expr)

getConstructor

protected JvmConstructor getConstructor(XConstructorCall expr,
                                        boolean resolve)

getConstructor

protected JvmConstructor getConstructor(XConstructorCall expr)

type

protected JvmTypeReference type(XExpression expression,
                                JvmTypeReference rawExpectation,
                                boolean rawType)

getDebugIndentation

protected java.lang.String getDebugIndentation(boolean rawType)

doGetType

protected <T> JvmTypeReference doGetType(java.lang.String key,
                                         T object,
                                         boolean rawType,
                                         org.eclipse.xtext.xbase.typing.AbstractTypeProvider.CyclicHandlingSupport<T> typeComputer)

getType

public JvmTypeReference getType(XExpression expression)
Description copied from interface: ITypeProvider
Return the resolved type of the given expression. Same as getType(expression, false.

Specified by:
getType in interface ITypeProvider
Parameters:
expression - the expression. May not be null.
Returns:
the fully-resolved type of the XExpression, if a correct, fully-linkable model is given. null indicates a problem during resolution.

getType

public JvmTypeReference getType(XExpression expression,
                                boolean rawType)
Specified by:
getType in interface ITypeProvider
Parameters:
expression - the expression. May not be null.
rawType - true if the raw type is sufficient.
Returns:
the fully-resolved type of the XExpression, if a correct, fully-linkable model is given. null indicates a problem during resolution.

getType

public JvmTypeReference getType(XExpression expression,
                                JvmTypeReference rawExpectation,
                                boolean rawType)
Specified by:
getType in interface ITypeProvider
Parameters:
expression - the expression. May not be null.
rawType - true if the raw type is sufficient.
Returns:
the fully-resolved type of the XExpression, if a correct, fully-linkable model is given. null indicates a problem during resolution.

handleCyclicGetType

protected JvmTypeReference handleCyclicGetType(XExpression expression,
                                               JvmTypeReference rawExpectation,
                                               boolean rawType)
Allows to handle cyclic type resolution.

Parameters:
expression - the expression that was asked reentrant for its type.
rawExpectation - the expected raw type if set from the outside. May be null.
rawType - true if we are only interested in the raw type

_expectedType

protected JvmTypeReference _expectedType(org.eclipse.emf.ecore.EObject container,
                                         org.eclipse.emf.ecore.EReference reference,
                                         int index,
                                         boolean rawType)
Parameters:
container - the container that owns the expression that may have a type expectation.
reference - the reference that can be used to obtain the expression with a type expectation.
index - the index if reference is a multi value feature.
rawType - true if we are only interested in the type parameter.

expectedType

protected JvmTypeReference expectedType(org.eclipse.emf.ecore.EObject container,
                                        org.eclipse.emf.ecore.EReference reference,
                                        int index,
                                        boolean rawType)

getExpectedType

public JvmTypeReference getExpectedType(XExpression expression)
Description copied from interface: ITypeProvider
Return the resolved expected type of the given expression. Same as getExpectedType(expression, false.

Specified by:
getExpectedType in interface ITypeProvider
Parameters:
expression - the expression. May not be null.
Returns:
the fully-resolved expected type of the given expression, if a correct, fully-linkable model is given. Returns null if no special type is expected

getExpectedType

public JvmTypeReference getExpectedType(XExpression expression,
                                        boolean rawType)
Specified by:
getExpectedType in interface ITypeProvider
Parameters:
expression - the expression. May not be null.
rawType - true if the raw type is sufficient.
Returns:
the fully-resolved expected type of the given expression, if a correct, fully-linkable model is given. Returns null if no special type is expected

handleCycleGetExpectedType

protected JvmTypeReference handleCycleGetExpectedType(XExpression expression,
                                                      boolean rawType)
Allows to handle cyclic resolution of expected types.

Parameters:
expression - the expression that was asked reentrant for its expected type.
rawType - true if we are only interested in the raw type

getContainingInfo

protected Triple<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EReference,java.lang.Integer> getContainingInfo(XExpression obj)

_typeForIdentifiable

protected JvmTypeReference _typeForIdentifiable(JvmIdentifiableElement identifiable,
                                                boolean rawType)
Parameters:
rawType - true if we are only interested in the type parameter.

typeForIdentifiable

protected JvmTypeReference typeForIdentifiable(JvmIdentifiableElement identifiable,
                                               boolean rawType)

getTypeForIdentifiable

public JvmTypeReference getTypeForIdentifiable(JvmIdentifiableElement identifiableElement)
Description copied from interface: ITypeProvider
Return the resolved type of the element. Same as getTypeForIdentifiable(identifiableElement, false.

Specified by:
getTypeForIdentifiable in interface ITypeProvider
Parameters:
identifiableElement - the identifiable element. May not be null.
Returns:
the fully-resolved type of the JvmIdentifiableElement, if a correct, fully-linkable model is given. null indicates a problem during resolution. given.

getTypeForIdentifiable

public JvmTypeReference getTypeForIdentifiable(JvmIdentifiableElement identifiableElement,
                                               boolean rawType)
Specified by:
getTypeForIdentifiable in interface ITypeProvider
Parameters:
identifiableElement - the identifiable element. May not be null.
rawType - true if the raw type is sufficient.
Returns:
the fully-resolved type of the JvmIdentifiableElement, if a correct, fully-linkable model is given. null indicates a problem during resolution. given.

handleCycleGetTypeForIdentifiable

protected JvmTypeReference handleCycleGetTypeForIdentifiable(JvmIdentifiableElement identifiableElement,
                                                             boolean rawType)
Allows to handle cyclic resolution of types.

Parameters:
identifiableElement - the element that was asked reentrant for its type.
rawType - true if we are only interested in the raw type

getCommonReturnType

public JvmTypeReference getCommonReturnType(XExpression expression,
                                            boolean assumeImplicitReturnExpression)
Description copied from interface: ITypeProvider
The return type of an expression is the common super type of all types used within a return expression.

Specified by:
getCommonReturnType in interface ITypeProvider
Parameters:
expression - May not be null.
assumeImplicitReturnExpression - indicating whether an implicit return expression should be assumed
Returns:
the fully-resolved common return type of the XExpression, if a correct, fully-linkable model is given. null indicates a problem during computation, the primitive void indicates that no return expression was found.

getThrownExceptionTypes

public java.lang.Iterable<JvmTypeReference> getThrownExceptionTypes(XExpression expression)
Description copied from interface: ITypeProvider
returns all exception types, thrown within the given expression. This includes explicitly declared RuntimeExceptions as well.

Specified by:
getThrownExceptionTypes in interface ITypeProvider
Parameters:
expression - May not be null.
Returns:
the iterable of fully-resolved exception types, if a correct, fully-linkable model is given. null indicates a problem during computation, an empty iterable means no thrown exceptions were found.

internalCollectEarlyExits

protected void internalCollectEarlyExits(org.eclipse.emf.ecore.EObject expr,
                                         AbstractTypeProvider.EarlyExitAcceptor acceptor)

_earlyExits

protected void _earlyExits(java.lang.Void expr,
                           AbstractTypeProvider.EarlyExitAcceptor a)
Computes early exits of null.

Parameters:
expr - always null.
a - the collector of the early exit result.

_earlyExits

protected void _earlyExits(JvmTypeReference ref,
                           AbstractTypeProvider.EarlyExitAcceptor a)
Computes early exits of type references.

Parameters:
ref - the type reference.
a - the collector of the early exit result.

_earlyExits

protected void _earlyExits(org.eclipse.emf.ecore.EObject expr,
                           AbstractTypeProvider.EarlyExitAcceptor acceptor)

getTypeConformanceComputer

protected TypeConformanceComputer getTypeConformanceComputer()

getTypeReferences

protected TypeReferences getTypeReferences()

getTypeArgumentContextProvider

protected TypeArgumentContextProvider getTypeArgumentContextProvider()

getLogicalContainerProvider

protected ILogicalContainerProvider getLogicalContainerProvider()