use of org.eclipse.xtext.xbase.typesystem.computation.ITypeComputationState in project xtext-xtend by eclipse.
the class XtendTypeComputer method _computeTypes.
protected void _computeTypes(RichStringForLoop object, ITypeComputationState state) {
LightweightTypeReference charSequence = getRawTypeForName(CharSequence.class, state);
ITypeComputationState eachState = state.withExpectation(charSequence);
JvmFormalParameter parameter = object.getDeclaredParam();
if (parameter != null) {
LightweightTypeReference parameterType = computeForLoopParameterType(object, state);
eachState = eachState.assignType(parameter, parameterType);
}
eachState.computeTypes(object.getEachExpression());
state.withNonVoidExpectation().computeTypes(object.getBefore());
state.withNonVoidExpectation().computeTypes(object.getSeparator());
state.withNonVoidExpectation().computeTypes(object.getAfter());
LightweightTypeReference primitiveVoid = getPrimitiveVoid(state);
state.acceptActualType(primitiveVoid);
state.acceptActualType(charSequence);
}
use of org.eclipse.xtext.xbase.typesystem.computation.ITypeComputationState in project xtext-xtend by eclipse.
the class ExtensionAwareClosureTypeComputer method createUnknownClosureTypeHelper.
@Override
protected UnknownClosureTypeHelper createUnknownClosureTypeHelper() {
return new UnknownClosureTypeHelper(getClosure(), getExpectation(), getState()) {
@Override
protected ITypeComputationState assignParameters(ITypeAssigner typeAssigner) {
ITypeComputationState result = super.assignParameters(typeAssigner);
addExtensions(result);
return result;
}
};
}
use of org.eclipse.xtext.xbase.typesystem.computation.ITypeComputationState in project xtext-xtend by eclipse.
the class ExtensionAwareClosureTypeComputer method createClosureWithExpectationHelper.
@Override
protected ClosureWithExpectationHelper createClosureWithExpectationHelper(JvmOperation operation) {
return new ClosureWithExpectationHelper(getClosure(), operation, getExpectation(), getState()) {
@Override
protected ITypeComputationState assignParameters(ITypeAssigner typeAssigner) {
ITypeComputationState result = super.assignParameters(typeAssigner);
addExtensions(result);
return result;
}
};
}
use of org.eclipse.xtext.xbase.typesystem.computation.ITypeComputationState in project xtext-xtend by eclipse.
the class ExtensionAwareClosureTypeComputer method createClosureWithoutExpectationHelper.
@Override
protected ClosureWithoutExpectationHelper createClosureWithoutExpectationHelper() {
return new ClosureWithoutExpectationHelper(getClosure(), getExpectation(), getState()) {
@Override
protected ITypeComputationState assignParameters(ITypeAssigner typeAssigner, FunctionTypeReference incompleteClosureType) {
ITypeComputationState result = super.assignParameters(typeAssigner, incompleteClosureType);
addExtensions(result);
return result;
}
};
}
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