use of org.eclipse.xtext.xbase.typesystem.computation.ITypeComputationState in project xtext-xtend by eclipse.
the class XtendTypeComputer method _computeTypes.
protected void _computeTypes(RichString object, ITypeComputationState state) {
List<XExpression> expressions = object.getExpressions();
if (!expressions.isEmpty()) {
for (XExpression expression : expressions) {
ITypeComputationState expressionState = state.withoutExpectation();
expressionState.computeTypes(expression);
if (expression instanceof XVariableDeclaration) {
addLocalToCurrentScope((XVariableDeclaration) expression, state);
}
}
}
for (ITypeExpectation expectation : state.getExpectations()) {
LightweightTypeReference expectedType = expectation.getExpectedType();
if (expectedType != null && expectedType.isType(StringConcatenation.class)) {
expectation.acceptActualType(expectedType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.DEMAND_CONVERSION);
} else if (expectedType != null && expectedType.isType(StringConcatenationClient.class)) {
expectation.acceptActualType(expectedType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.DEMAND_CONVERSION);
} else if (expectedType != null && expectedType.isType(String.class)) {
expectation.acceptActualType(expectedType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.DEMAND_CONVERSION);
// TODO this special treatment here should become obsolete as soon as the expectations are properly propagated
} else if (!(object.eContainer() instanceof XCastedExpression) && object.eContainingFeature() != XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET && (expectedType != null && !expectedType.isResolved() || expectedType == null && !expectation.isVoidTypeAllowed())) {
LightweightTypeReference type = getRawTypeForName(String.class, state);
expectation.acceptActualType(type, ConformanceFlags.UNCHECKED | ConformanceFlags.DEMAND_CONVERSION);
} else {
LightweightTypeReference type = getRawTypeForName(CharSequence.class, state);
expectation.acceptActualType(type, ConformanceFlags.UNCHECKED);
}
}
}
Aggregations