use of org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssue in project statecharts by Yakindu.
the class TypeValidator method assertCompatible.
public void assertCompatible(InferenceResult result1, InferenceResult result2, String msg, IValidationIssueAcceptor acceptor) {
if (result1 == null || result2 == null || isNullOnComplexType(result1, result2) || isNullOnComplexType(result2, result1)) {
return;
}
if (!registry.haveCommonType(result1.getType(), result2.getType())) {
msg = msg != null ? msg : String.format(ASSERT_COMPATIBLE, result1, result2);
acceptor.accept(new ValidationIssue(Severity.ERROR, msg, NOT_COMPATIBLE_CODE));
return;
}
assertTypeBindingsSame(result1, result2, msg, acceptor);
}
use of org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssue in project statecharts by Yakindu.
the class TypeValidator method assertAssignable.
public void assertAssignable(InferenceResult varResult, InferenceResult valueResult, String msg, IValidationIssueAcceptor acceptor) {
if (varResult == null || valueResult == null || isNullOnComplexType(varResult, valueResult)) {
return;
}
if (!registry.isSuperType(valueResult.getType(), varResult.getType())) {
msg = msg != null ? msg : String.format(ASSERT_COMPATIBLE, varResult, valueResult);
acceptor.accept(new ValidationIssue(Severity.ERROR, msg, NOT_COMPATIBLE_CODE));
return;
}
assertTypeBindingsSame(varResult, valueResult, msg, acceptor);
}
use of org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssue 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.validation.IValidationIssueAcceptor.ValidationIssue in project statecharts by Yakindu.
the class TypeValidator method assertSame.
public void assertSame(InferenceResult result1, InferenceResult result2, String msg, IValidationIssueAcceptor acceptor) {
if (result1 == null || result2 == null)
return;
if (!registry.isSame(result1.getType(), result2.getType())) {
msg = msg != null ? msg : String.format(ASSERT_SAME, result1, result2);
acceptor.accept(new ValidationIssue(Severity.ERROR, msg, NOT_SAME_CODE));
return;
}
assertTypeBindingsSame(result1, result2, msg, acceptor);
}
use of org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssue 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