Restore model validation not to fail on diagnostic errors for rules and scripts (#5351)

* Restore model validation not to fail on diagnostic errors

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
jimtng
2026-02-14 13:28:52 +01:00
committed by GitHub
parent 50aea478ca
commit f9776bcb7f
2 changed files with 25 additions and 1 deletions
@@ -331,10 +331,12 @@ public class ModelRepositoryImpl implements ModelRepository {
// Check for validation errors, but log them only
try {
String modelType = resource.getURI().fileExtension();
final org.eclipse.emf.common.util.Diagnostic diagnostic = safeEmf
.call(() -> Diagnostician.INSTANCE.validate(resource.getContents().getFirst()));
for (org.eclipse.emf.common.util.Diagnostic d : diagnostic.getChildren()) {
if (d.getSeverity() == org.eclipse.emf.common.util.Diagnostic.ERROR) {
if (d.getSeverity() == org.eclipse.emf.common.util.Diagnostic.ERROR
&& !"rules".equalsIgnoreCase(modelType) && !"script".equalsIgnoreCase(modelType)) {
errors.add(d.getMessage());
} else {
warnings.add(d.getMessage());
@@ -268,4 +268,26 @@ public class DSLRuleProviderTest extends JavaOSGiTest {
Object x = context.getValue(QualifiedName.create("x"));
assertThat(x, is(15));
}
@Test
public void testRuleWithUntypedLambdaArgsDoesNotFailToLoad() {
Collection<Rule> rules = dslRuleProvider.getAll();
assertThat(rules.size(), is(0));
String model = """
var lambdaWithUntypedArgs = [ foo | foo ]
rule "RuleWithUntypedLambdaArgs"
when
System started
then
logInfo('Test', 'Test')
end
""";
modelRepository.addOrRefreshModel(TESTMODEL_NAME,
new ByteArrayInputStream(model.getBytes(StandardCharsets.UTF_8)));
Collection<Rule> actualRules = dslRuleProvider.getAll();
assertThat(actualRules.size(), is(1));
}
}