use of org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult in project statecharts by Yakindu.
the class SGenJavaValidator method checkParameterValueType.
@Check
public void checkParameterValueType(final FeatureParameterValue parameterValue) {
if (parameterValue == null || parameterValue.getExpression() == null)
return;
InferenceResult valueResult = inferrer.infer(parameterValue.getExpression());
ParameterTypes parameterType = parameterValue.getParameter().getParameterType();
typeValidator.assertAssignable(InferenceResult.from(mapType(parameterType)), valueResult, null, this);
}
use of org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult in project statecharts by Yakindu.
the class SGenJavaValidator method checkInitialValue.
@Check(CheckType.FAST)
public void checkInitialValue(PropertyDefinition property) {
if (property.getType() == null || property.getType().eIsProxy())
return;
InferenceResult expressionResult = inferrer.infer(property.getInitialValue(), this);
typeValidator.assertAssignable(InferenceResult.from(property.getType()), expressionResult, null, this);
}
use of org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult in project statecharts by Yakindu.
the class STextScopeProvider method scope_FeatureCall_feature.
public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
Expression owner = context.getOwner();
EObject element = null;
if (owner instanceof ElementReferenceExpression) {
element = ((ElementReferenceExpression) owner).getReference();
} else if (owner instanceof FeatureCall) {
element = ((FeatureCall) owner).getFeature();
} else {
return getDelegate().getScope(context, reference);
}
IScope scope = IScope.NULLSCOPE;
InferenceResult result = typeInferrer.infer(owner);
Type ownerType = result != null ? result.getType() : null;
if (element instanceof Scope) {
scope = Scopes.scopeFor(((Scope) element).getDeclarations());
return new FilteringScope(scope, predicate);
} else if (ownerType != null) {
scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
}
if (ownerType instanceof ComplexType) {
return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
}
if (ownerType instanceof EnumerationType) {
return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
}
return scope;
}
use of org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult in project statecharts by Yakindu.
the class TypeValidator method assertTypeBindingsSame.
public void assertTypeBindingsSame(InferenceResult result1, InferenceResult result2, String msg, IValidationIssueAcceptor acceptor) {
List<InferenceResult> bindings1 = result1.getBindings();
List<InferenceResult> bindings2 = result2.getBindings();
msg = msg != null ? msg : String.format(ASSERT_COMPATIBLE, result1, result2);
if (bindings1.size() != bindings2.size()) {
acceptor.accept(new ValidationIssue(Severity.ERROR, msg, NOT_COMPATIBLE_CODE));
return;
}
for (int i = 0; i < bindings1.size(); i++) {
assertSame(bindings1.get(i), bindings2.get(i), msg, acceptor);
}
}
use of org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult in project statecharts by Yakindu.
the class TypeValidator method assertNotType.
public void assertNotType(InferenceResult currentResult, String msg, IValidationIssueAcceptor acceptor, InferenceResult... candidates) {
if (currentResult == null)
return;
for (InferenceResult type : candidates) {
if (registry.isSame(currentResult.getType(), type.getType())) {
msg = msg != null ? msg : String.format(ASSERT_NOT_TYPE, currentResult);
acceptor.accept(new ValidationIssue(Severity.ERROR, msg, NOT_TYPE_CODE));
}
}
}
Aggregations