org.eclipse.xtext.xbase.typesystem.internal
Class AbstractTypeComputationState
java.lang.Object
org.eclipse.xtext.xbase.typesystem.internal.AbstractTypeComputationState
- All Implemented Interfaces:
- ITypeComputationState, ITypeComputationState.Fork
- Direct Known Subclasses:
- AbstractRootTypeComputationState, AbstractStackedTypeComputationState
@NonNullByDefault
public abstract class AbstractTypeComputationState
- extends java.lang.Object
- implements ITypeComputationState, ITypeComputationState.Fork
- Author:
- Sebastian Zarnekow - Initial contribution and API
TODO JavaDoc, toString
Method Summary |
void |
acceptActualType(JvmTypeReference type)
|
protected abstract JvmTypeReference |
acceptType(AbstractTypeExpectation expectation,
JvmTypeReference type,
ConformanceHint conformanceHint,
boolean returnType)
|
void |
addLocalToCurrentScope(JvmIdentifiableElement element)
|
AbstractTypeComputationState |
assignType(JvmIdentifiableElement element,
JvmTypeReference type)
|
AbstractTypeComputationState.TypeAssigner |
assignTypes()
|
ITypeComputationResult |
computeTypes(XExpression expression)
|
protected ResolvedTypes |
computeTypes(XExpression expression,
boolean mergeAll)
|
protected StackedResolvedTypes |
computeTypesWithoutMerge(XExpression expression)
|
protected IFeatureLinkingCandidate |
createCandidate(XAbstractFeatureCall featureCall,
IEObjectDescription description)
|
protected IConstructorLinkingCandidate |
createCandidate(XConstructorCall constructorCall,
IEObjectDescription description)
|
protected ExpressionTypeComputationState |
createExpressionComputationState(XExpression expression,
StackedResolvedTypes typeResolution)
|
protected AbstractTypeComputationState.TypeAssigner |
createTypeAssigner(AbstractTypeComputationState state)
|
void |
discardReassignedTypes(XExpression object)
|
AbstractTypeComputationState |
fork()
|
protected IFeatureScopeSession |
getFeatureScopeSession()
|
java.util.List<ITypeExpectation> |
getImmediateExpectations()
The result is never empty. |
protected abstract java.util.List<ITypeExpectation> |
getImmediateExpectations(AbstractTypeComputationState actualState)
|
java.util.List<IFeatureLinkingCandidate> |
getLinkingCandidates(XAbstractFeatureCall featureCall)
The result is never empty. |
java.util.List<IConstructorLinkingCandidate> |
getLinkingCandidates(XConstructorCall constructorCall)
The result is never empty. |
protected ResolvedTypes |
getResolvedTypes()
|
protected DefaultReentrantTypeResolver |
getResolver()
|
java.util.List<ITypeExpectation> |
getReturnExpectations()
The result is never empty. |
protected abstract java.util.List<ITypeExpectation> |
getReturnExpectations(AbstractTypeComputationState actualState)
|
protected CommonTypeComputationServices |
getServices()
|
JvmTypeReference |
getType(JvmIdentifiableElement element)
|
protected BoundTypeArgumentMerger |
getTypeArgumentMerger()
|
protected ITypeComputer |
getTypeComputer()
|
protected TypeReferences |
getTypeReferences()
|
void |
reassignType(XExpression object,
JvmTypeReference type)
|
AbstractTypeComputationState |
withExpectation(JvmTypeReference expectation)
The given expectation will be resolved if it contains unresolved type
arguments, e.g. |
AbstractTypeComputationState |
withNonVoidExpectation()
|
AbstractTypeComputationState |
withoutExpectation()
Discards the current expectation and allows to use return and throw
independently from the parent's state. |
AbstractTypeComputationState |
withoutImmediateExpectation()
Keeps the return type expectation. |
AbstractTypeComputationState |
withReturnExpectation()
Transfers the available return type expectation to the immediate expectation of this
computation step. |
AbstractTypeComputationState |
withTypeCheckpoint()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractTypeComputationState
protected AbstractTypeComputationState(ResolvedTypes resolvedTypes,
IFeatureScopeSession featureScopeSession,
DefaultReentrantTypeResolver reentrantTypeResolver)
getResolvedTypes
protected ResolvedTypes getResolvedTypes()
getFeatureScopeSession
protected IFeatureScopeSession getFeatureScopeSession()
getServices
protected CommonTypeComputationServices getServices()
getTypeReferences
protected TypeReferences getTypeReferences()
getTypeComputer
protected ITypeComputer getTypeComputer()
getResolver
protected DefaultReentrantTypeResolver getResolver()
getTypeArgumentMerger
protected BoundTypeArgumentMerger getTypeArgumentMerger()
computeTypes
public ITypeComputationResult computeTypes(@Nullable
XExpression expression)
- Specified by:
computeTypes
in interface ITypeComputationState
computeTypes
@Nullable
protected ResolvedTypes computeTypes(@Nullable
XExpression expression,
boolean mergeAll)
computeTypesWithoutMerge
@Nullable
protected StackedResolvedTypes computeTypesWithoutMerge(@Nullable
XExpression expression)
createExpressionComputationState
protected ExpressionTypeComputationState createExpressionComputationState(XExpression expression,
StackedResolvedTypes typeResolution)
acceptType
protected abstract JvmTypeReference acceptType(AbstractTypeExpectation expectation,
JvmTypeReference type,
ConformanceHint conformanceHint,
boolean returnType)
fork
public AbstractTypeComputationState fork()
- Specified by:
fork
in interface ITypeComputationState
withExpectation
public AbstractTypeComputationState withExpectation(JvmTypeReference expectation)
- Description copied from interface:
ITypeComputationState.Fork
- The given expectation will be resolved if it contains unresolved type
arguments, e.g. an operation that declares two parameters of the very
same type argument will yield a more detailed expectation if possible.
<T> T foo(T, T)
with
foo<String>(null, 'string')
will allow to pass the unresolved T as expectation
where clients would be invoked with the better candidate 'string'.
- Specified by:
withExpectation
in interface ITypeComputationState.Fork
withNonVoidExpectation
public AbstractTypeComputationState withNonVoidExpectation()
- Specified by:
withNonVoidExpectation
in interface ITypeComputationState.Fork
withoutExpectation
public AbstractTypeComputationState withoutExpectation()
- Description copied from interface:
ITypeComputationState.Fork
- Discards the current expectation and allows to use return and throw
independently from the parent's state.
- Specified by:
withoutExpectation
in interface ITypeComputationState.Fork
withReturnExpectation
public AbstractTypeComputationState withReturnExpectation()
- Description copied from interface:
ITypeComputationState.Fork
- Transfers the available return type expectation to the immediate expectation of this
computation step.
- Specified by:
withReturnExpectation
in interface ITypeComputationState.Fork
withoutImmediateExpectation
public AbstractTypeComputationState withoutImmediateExpectation()
- Description copied from interface:
ITypeComputationState.Fork
- Keeps the return type expectation. Otherwise the state is free of expectations.
- Specified by:
withoutImmediateExpectation
in interface ITypeComputationState.Fork
withTypeCheckpoint
public AbstractTypeComputationState withTypeCheckpoint()
- Specified by:
withTypeCheckpoint
in interface ITypeComputationState.Fork
assignType
public AbstractTypeComputationState assignType(JvmIdentifiableElement element,
JvmTypeReference type)
- Specified by:
assignType
in interface ITypeComputationState
type
- the type of the element. null
or other invalid types will be treated as error types.
addLocalToCurrentScope
public void addLocalToCurrentScope(JvmIdentifiableElement element)
- Specified by:
addLocalToCurrentScope
in interface ITypeComputationState
assignTypes
public AbstractTypeComputationState.TypeAssigner assignTypes()
- Specified by:
assignTypes
in interface ITypeComputationState
createTypeAssigner
protected AbstractTypeComputationState.TypeAssigner createTypeAssigner(AbstractTypeComputationState state)
getImmediateExpectations
public final java.util.List<ITypeExpectation> getImmediateExpectations()
- Description copied from interface:
ITypeComputationState
- The result is never empty.
- Specified by:
getImmediateExpectations
in interface ITypeComputationState
getReturnExpectations
public final java.util.List<ITypeExpectation> getReturnExpectations()
- Description copied from interface:
ITypeComputationState
- The result is never empty.
- Specified by:
getReturnExpectations
in interface ITypeComputationState
getImmediateExpectations
protected abstract java.util.List<ITypeExpectation> getImmediateExpectations(AbstractTypeComputationState actualState)
getReturnExpectations
protected abstract java.util.List<ITypeExpectation> getReturnExpectations(AbstractTypeComputationState actualState)
acceptActualType
public void acceptActualType(JvmTypeReference type)
- Specified by:
acceptActualType
in interface ITypeComputationState
getType
@Nullable
public JvmTypeReference getType(JvmIdentifiableElement element)
- Specified by:
getType
in interface ITypeComputationState
reassignType
public void reassignType(XExpression object,
JvmTypeReference type)
- Specified by:
reassignType
in interface ITypeComputationState
discardReassignedTypes
public void discardReassignedTypes(XExpression object)
- Specified by:
discardReassignedTypes
in interface ITypeComputationState
getLinkingCandidates
public java.util.List<IFeatureLinkingCandidate> getLinkingCandidates(XAbstractFeatureCall featureCall)
- Description copied from interface:
ITypeComputationState
- The result is never empty.
- Specified by:
getLinkingCandidates
in interface ITypeComputationState
createCandidate
protected IFeatureLinkingCandidate createCandidate(XAbstractFeatureCall featureCall,
IEObjectDescription description)
getLinkingCandidates
public java.util.List<IConstructorLinkingCandidate> getLinkingCandidates(XConstructorCall constructorCall)
- Description copied from interface:
ITypeComputationState
- The result is never empty.
- Specified by:
getLinkingCandidates
in interface ITypeComputationState
createCandidate
protected IConstructorLinkingCandidate createCandidate(XConstructorCall constructorCall,
IEObjectDescription description)