Class XbaseTypeComputer
- java.lang.Object
-
- org.eclipse.xtext.xbase.typesystem.computation.AbstractTypeComputer
-
- org.eclipse.xtext.xbase.typesystem.computation.XbaseTypeComputer
-
- All Implemented Interfaces:
ITypeComputer
- Direct Known Subclasses:
XbaseWithAnnotationsTypeComputer
public class XbaseTypeComputer extends AbstractTypeComputer implements ITypeComputer
Base implementation for theITypeComputer
. The interface contract fully applies to this class. This implementation handles all expression that are defined in Xbase.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
XbaseTypeComputer.BranchExpressionProcessor
-
Constructor Summary
Constructors Constructor Description XbaseTypeComputer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_computeTypes(XAbstractFeatureCall featureCall, ITypeComputationState state)
protected void
_computeTypes(XAssignment assignment, ITypeComputationState state)
protected void
_computeTypes(XBasicForLoopExpression object, ITypeComputationState state)
protected void
_computeTypes(XBlockExpression object, ITypeComputationState state)
protected void
_computeTypes(XBooleanLiteral object, ITypeComputationState state)
protected void
_computeTypes(XCastedExpression object, ITypeComputationState state)
protected void
_computeTypes(XClosure object, ITypeComputationState state)
protected void
_computeTypes(XConstructorCall constructorCall, ITypeComputationState state)
protected void
_computeTypes(XDoWhileExpression object, ITypeComputationState state)
Since we are sure that the loop body is executed at least once, the early exit information of the loop body expression can be used for the outer expression.protected void
_computeTypes(XForLoopExpression object, ITypeComputationState state)
protected void
_computeTypes(XIfExpression object, ITypeComputationState state)
protected void
_computeTypes(XInstanceOfExpression object, ITypeComputationState state)
protected void
_computeTypes(XListLiteral literal, ITypeComputationState state)
protected void
_computeTypes(XNullLiteral object, ITypeComputationState state)
protected void
_computeTypes(XNumberLiteral object, ITypeComputationState state)
protected void
_computeTypes(XReturnExpression object, ITypeComputationState state)
protected void
_computeTypes(XSetLiteral literal, ITypeComputationState state)
protected void
_computeTypes(XStringLiteral object, ITypeComputationState state)
protected void
_computeTypes(XSwitchExpression object, ITypeComputationState state)
protected void
_computeTypes(XSynchronizedExpression expr, ITypeComputationState state)
protected void
_computeTypes(XThrowExpression object, ITypeComputationState state)
protected void
_computeTypes(XTryCatchFinallyExpression object, ITypeComputationState state)
protected void
_computeTypes(XTypeLiteral object, ITypeComputationState state)
protected void
_computeTypes(XVariableDeclaration object, ITypeComputationState state)
protected void
_computeTypes(XWhileExpression object, ITypeComputationState state)
protected void
addLocalToCurrentScope(XExpression expression, ITypeComputationState state)
If the expression is a variable declaration, then add it to the current scope; DSLs introducing new containers for variable declarations should override this method and explicitly add nested variable declarations.protected void
addLocalToCurrentScope(XVariableDeclaration localVariable, ITypeComputationState state)
protected ITypeComputationState
assignType(org.eclipse.xtext.common.types.JvmFormalParameter param, LightweightTypeReference type, ITypeComputationState state)
protected void
checkValidReturn(XReturnExpression object, ITypeComputationState state)
protected void
checkValidReturnExpression(XExpression returnValue, ITypeComputationState expressionState)
protected LightweightTypeReference
computeForLoopParameterType(XForLoopExpression object, ITypeComputationState state)
void
computeTypes(XExpression expression, ITypeComputationState state)
Compute the type for the given expression in the context of the given computation state.protected ITypeComputationResult
computeWhileLoopBody(XAbstractWhileExpression object, ITypeComputationState state, boolean autocast)
protected org.eclipse.xtext.common.types.JvmOperation
findCloseMethod(LightweightTypeReference resourceType)
protected LightweightTypeReference
getAndEnhanceIterableOrArrayFromComponent(LightweightTypeReference parameterType, org.eclipse.xtext.common.types.JvmGenericType iterableType, CompoundTypeReference compoundResult)
protected ILinkingCandidate
getBestCandidate(java.util.List<? extends ILinkingCandidate> candidates)
protected java.util.List<XCasePart>
getCases(XSwitchExpression switchExpression)
Only for testing purpose.protected LightweightTypeReference
getDeclaredParameterType(org.eclipse.xtext.common.types.JvmFormalParameter declaredParam, ITypeComputationState state)
protected LightweightTypeReference
getElementOrComponentType(LightweightTypeReference iterableOrArray, ITypeReferenceOwner owner)
protected XExpression
getElse(XIfExpression ifExpression)
Only for testing purpose.protected org.eclipse.xtext.common.types.JvmIdentifiableElement
getRefinableCandidate(XExpression object, ITypeComputationState state)
protected ITypeComputationState
getSwitchExpressionState(XSwitchExpression expr, ITypeComputationState state)
protected XExpression
getThen(XIfExpression ifExpression)
Only for testing purpose.protected boolean
hasThrowableExpectation(ITypeComputationState state)
protected boolean
isRefinableFeature(org.eclipse.xtext.common.types.JvmIdentifiableElement feature)
protected LightweightTypeReference
normalizedMultiType(ITypeReferenceOwner referenceOwner, org.eclipse.xtext.common.types.JvmTypeReference ref)
protected ITypeComputationState
reassignCheckedType(XExpression condition, XExpression guardedExpression, ITypeComputationState state)
If the condition is atype check
, the checked expression will be automatically casted in the returned state.protected void
validateUnhandledException(LightweightTypeReference thrownException, XExpression object, org.eclipse.emf.ecore.EStructuralFeature feature, ITypeComputationState state, java.util.function.Function<? super org.eclipse.xtext.common.types.JvmType,? extends java.lang.String> message)
Checks if the given thrownexcpetion is handled (as in "taken care of by compiler").-
Methods inherited from class org.eclipse.xtext.xbase.typesystem.computation.AbstractTypeComputer
deferredBindTypeArgument, findDeclaredType, findDeclaredType, findDeclaredType, findDeclaredType, getCommonSuperType, getCommonSuperType, getPrimitiveVoid, getRawTypeForName, getRawTypeForName, getRawTypeForName, getTypeForName, getTypeForName
-
-
-
-
Method Detail
-
computeTypes
public void computeTypes(XExpression expression, ITypeComputationState state)
Description copied from interface:ITypeComputer
Compute the type for the given expression in the context of the given computation state. The state may be used to compute child types but implementations may not invoke this method recursively on their own. The framework handles the control flow.- Specified by:
computeTypes
in interfaceITypeComputer
- See Also:
ITypeComputationState.computeTypes(XExpression)
-
_computeTypes
protected void _computeTypes(XIfExpression object, ITypeComputationState state)
-
reassignCheckedType
protected ITypeComputationState reassignCheckedType(XExpression condition, XExpression guardedExpression, ITypeComputationState state)
If the condition is atype check
, the checked expression will be automatically casted in the returned state.
-
getElse
protected XExpression getElse(XIfExpression ifExpression)
Only for testing purpose.- Noreference:
- This method is not intended to be referenced by clients.
- Nooverride:
- This method is not intended to be re-implemented or extended by clients.
-
getThen
protected XExpression getThen(XIfExpression ifExpression)
Only for testing purpose.- Noreference:
- This method is not intended to be referenced by clients.
- Nooverride:
- This method is not intended to be re-implemented or extended by clients.
-
normalizedMultiType
protected LightweightTypeReference normalizedMultiType(ITypeReferenceOwner referenceOwner, org.eclipse.xtext.common.types.JvmTypeReference ref)
-
_computeTypes
protected void _computeTypes(XSwitchExpression object, ITypeComputationState state)
-
getSwitchExpressionState
protected ITypeComputationState getSwitchExpressionState(XSwitchExpression expr, ITypeComputationState state)
-
getCases
protected java.util.List<XCasePart> getCases(XSwitchExpression switchExpression)
Only for testing purpose.- Noreference:
- This method is not intended to be referenced by clients.
- Nooverride:
- This method is not intended to be re-implemented or extended by clients.
-
_computeTypes
protected void _computeTypes(XBlockExpression object, ITypeComputationState state)
-
addLocalToCurrentScope
protected void addLocalToCurrentScope(XExpression expression, ITypeComputationState state)
If the expression is a variable declaration, then add it to the current scope; DSLs introducing new containers for variable declarations should override this method and explicitly add nested variable declarations.- Since:
- 2.9
-
addLocalToCurrentScope
protected void addLocalToCurrentScope(XVariableDeclaration localVariable, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XVariableDeclaration object, ITypeComputationState state)
-
findCloseMethod
protected org.eclipse.xtext.common.types.JvmOperation findCloseMethod(LightweightTypeReference resourceType)
- Since:
- 2.18
-
_computeTypes
protected void _computeTypes(XConstructorCall constructorCall, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XBooleanLiteral object, ITypeComputationState state)
- Parameters:
object
- used for dispatching
-
_computeTypes
protected void _computeTypes(XNullLiteral object, ITypeComputationState state)
- Parameters:
object
- used for dispatching
-
_computeTypes
protected void _computeTypes(XNumberLiteral object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XStringLiteral object, ITypeComputationState state)
- Parameters:
object
- used for dispatching
-
_computeTypes
protected void _computeTypes(XListLiteral literal, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XSetLiteral literal, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XClosure object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XCastedExpression object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XBasicForLoopExpression object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XForLoopExpression object, ITypeComputationState state)
-
assignType
protected ITypeComputationState assignType(org.eclipse.xtext.common.types.JvmFormalParameter param, LightweightTypeReference type, ITypeComputationState state)
-
computeForLoopParameterType
protected LightweightTypeReference computeForLoopParameterType(XForLoopExpression object, ITypeComputationState state)
-
getAndEnhanceIterableOrArrayFromComponent
protected LightweightTypeReference getAndEnhanceIterableOrArrayFromComponent(LightweightTypeReference parameterType, org.eclipse.xtext.common.types.JvmGenericType iterableType, CompoundTypeReference compoundResult)
-
getElementOrComponentType
protected LightweightTypeReference getElementOrComponentType(LightweightTypeReference iterableOrArray, ITypeReferenceOwner owner)
Delegates toElementOrComponentTypeComputer.compute(LightweightTypeReference, ITypeReferenceOwner)
. Clients may override.
-
getDeclaredParameterType
protected LightweightTypeReference getDeclaredParameterType(org.eclipse.xtext.common.types.JvmFormalParameter declaredParam, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XWhileExpression object, ITypeComputationState state)
-
computeWhileLoopBody
protected ITypeComputationResult computeWhileLoopBody(XAbstractWhileExpression object, ITypeComputationState state, boolean autocast)
-
_computeTypes
protected void _computeTypes(XDoWhileExpression object, ITypeComputationState state)
Since we are sure that the loop body is executed at least once, the early exit information of the loop body expression can be used for the outer expression.
-
_computeTypes
protected void _computeTypes(XTypeLiteral object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XInstanceOfExpression object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XThrowExpression object, ITypeComputationState state)
-
validateUnhandledException
protected void validateUnhandledException(LightweightTypeReference thrownException, XExpression object, org.eclipse.emf.ecore.EStructuralFeature feature, ITypeComputationState state, java.util.function.Function<? super org.eclipse.xtext.common.types.JvmType,? extends java.lang.String> message)
Checks if the given thrownexcpetion is handled (as in "taken care of by compiler").- Parameters:
thrownException
- the exception to validateobject
- the object in which context the exception should be validatedfeature
- which causes the exceptionstate
- bearing the expected exceptionsmessage
- function to specify the exception message- Since:
- 2.18
-
_computeTypes
protected void _computeTypes(XReturnExpression object, ITypeComputationState state)
-
checkValidReturn
protected void checkValidReturn(XReturnExpression object, ITypeComputationState state)
-
hasThrowableExpectation
protected boolean hasThrowableExpectation(ITypeComputationState state)
-
checkValidReturnExpression
protected void checkValidReturnExpression(XExpression returnValue, ITypeComputationState expressionState)
-
_computeTypes
protected void _computeTypes(XTryCatchFinallyExpression object, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XSynchronizedExpression expr, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XAssignment assignment, ITypeComputationState state)
-
_computeTypes
protected void _computeTypes(XAbstractFeatureCall featureCall, ITypeComputationState state)
-
getBestCandidate
protected ILinkingCandidate getBestCandidate(java.util.List<? extends ILinkingCandidate> candidates)
-
getRefinableCandidate
protected org.eclipse.xtext.common.types.JvmIdentifiableElement getRefinableCandidate(XExpression object, ITypeComputationState state)
-
isRefinableFeature
protected boolean isRefinableFeature(org.eclipse.xtext.common.types.JvmIdentifiableElement feature)
-
-