From a0ed70afc79c12524e75c7810b36230bbc35a636 Mon Sep 17 00:00:00 2001 From: Lutz Wrage Date: Fri, 18 Sep 2026 12:14:18 -0400 Subject: [PATCH 1/2] Add regression test for issue #2743 Exercise type sets in the first, middle, and last positions of EMV2 type products, including multiple references and a qualified alias. Require one error on each reference with its type set name. Validate the supporting type library and legal products and standalone type sets separately. The invalid fixture reproduces the defect with only two diagnostics instead of seven. --- .../models/issue2743/.gitignore | 2 + .../models/issue2743/.project | 18 ++++ .../models/issue2743/ErrorTypes.aadl | 14 +++ .../models/issue2743/Issue2743.aadl | 21 +++++ .../models/issue2743/ValidTypeProducts.aadl | 21 +++++ .../tests/issues/Issue2743Test.java | 89 +++++++++++++++++++ 6 files changed, 165 insertions(+) create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.gitignore create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.project create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ErrorTypes.aadl create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2743/Issue2743.aadl create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ValidTypeProducts.aadl create mode 100644 emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2743Test.java diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.gitignore b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.gitignore new file mode 100644 index 00000000000..afce51184c6 --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.gitignore @@ -0,0 +1,2 @@ +/.aadlbin-gen/ +/instances/ diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.project b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.project new file mode 100644 index 00000000000..d9498e9c01e --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.project @@ -0,0 +1,18 @@ + + + issue2743 + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.osate.core.aadlnature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ErrorTypes.aadl b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ErrorTypes.aadl new file mode 100644 index 00000000000..5f18607dc28 --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ErrorTypes.aadl @@ -0,0 +1,14 @@ +package ErrorTypes +public + annex EMV2 {** + error types + ServiceError: type; + TimingError: type; + ValueError: type; + ServiceSet: type set {ServiceError}; + TimingSet: type set {TimingError}; + ValueSet: type set {ValueError}; + TimingAlias renames type set TimingSet; + end types; + **}; +end ErrorTypes; diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/Issue2743.aadl b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/Issue2743.aadl new file mode 100644 index 00000000000..8935f0bb92a --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/Issue2743.aadl @@ -0,0 +1,21 @@ +package Issue2743 +public + system s + features + first: out feature; + middle: out feature; + last: out feature; + multiple: out feature; + qualified: out feature; + annex EMV2 {** + use types ErrorTypes; + error propagations + first: out propagation {ServiceSet * TimingError}; + middle: out propagation {ServiceError * TimingSet * ValueError}; + last: out propagation {ServiceError * TimingError * ValueSet}; + multiple: out propagation {ServiceSet * TimingSet * ValueSet}; + qualified: out propagation {ServiceError * ErrorTypes::TimingAlias}; + end propagations; + **}; + end s; +end Issue2743; diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ValidTypeProducts.aadl b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ValidTypeProducts.aadl new file mode 100644 index 00000000000..a087c26ce2b --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2743/ValidTypeProducts.aadl @@ -0,0 +1,21 @@ +package ValidTypeProducts +public + system s + features + product: out feature; + single_type: out feature; + single_set: out feature; + alias_set: out feature; + union_sets: out feature; + annex EMV2 {** + use types ErrorTypes; + error propagations + product: out propagation {ServiceError * TimingError * ValueError}; + single_type: out propagation {ServiceError}; + single_set: out propagation {ServiceSet}; + alias_set: out propagation {ErrorTypes::TimingAlias}; + union_sets: out propagation {ServiceSet, TimingSet, ValueSet}; + end propagations; + **}; + end s; +end ValidTypeProducts; diff --git a/emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2743Test.java b/emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2743Test.java new file mode 100644 index 00000000000..63c1f5670cc --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2743Test.java @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2004-2026 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with this program. The + * parties who own the Third Party Software ("Third Party Licensors") are intended third party beneficiaries to this + * license with respect to the terms applicable to their Third Party Software. Third Party Software licenses only apply + * to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.aadl2.errormodel.tests.issues; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Comparator; +import java.util.List; + +import org.eclipse.xtext.diagnostics.Severity; +import org.eclipse.xtext.nodemodel.util.NodeModelUtils; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.validation.ValidationTestHelper; +import org.eclipse.xtext.validation.Issue; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.osate.aadl2.AadlPackage; +import org.osate.aadl2.errormodel.tests.ErrorModelInjectorProvider; +import org.osate.testsupport.TestHelper; + +import com.google.inject.Inject; +import com.itemis.xtext.testing.XtextTest; + +@RunWith(XtextRunner.class) +@InjectWith(ErrorModelInjectorProvider.class) +public class Issue2743Test extends XtextTest { + private static final String PROJECT_LOCATION = "org.osate.aadl2.errormodel.tests/models/issue2743/"; + + @Inject + private TestHelper testHelper; + + @Inject + private ValidationTestHelper validation; + + @Test + public void reportsEveryTypeSetReferenceInTypeProducts() { + var library = testHelper.parseFile(PROJECT_LOCATION + "ErrorTypes.aadl"); + validation.assertNoIssues(library); + var pkg = testHelper.parseFile(PROJECT_LOCATION + "Issue2743.aadl", PROJECT_LOCATION + "ErrorTypes.aadl"); + assertTrue(pkg.eResource().getErrors().toString(), pkg.eResource().getErrors().isEmpty()); + var diagnostics = validation.validate(pkg).stream().sorted(Comparator.comparing(Issue::getOffset)).toList(); + assertEquals(diagnostics.toString(), 7, diagnostics.size()); + + var source = NodeModelUtils.getNode(pkg).getRootNode().getText(); + var references = List.of("ServiceSet", "TimingSet", "ValueSet", "ServiceSet", "TimingSet", "ValueSet", + "ErrorTypes::TimingAlias"); + for (int i = 0; i < references.size(); i++) { + var diagnostic = diagnostics.get(i); + var reference = references.get(i); + assertEquals(Severity.ERROR, diagnostic.getSeverity()); + assertEquals(reference, source.substring(diagnostic.getOffset(), + diagnostic.getOffset() + diagnostic.getLength())); + var name = reference.substring(reference.lastIndexOf(':') + 1); + assertEquals("Type product contains type set " + name, diagnostic.getMessage()); + } + } + + @Test + public void acceptsErrorTypeProductsAndStandaloneTypeSets() { + var library = testHelper.parseFile(PROJECT_LOCATION + "ErrorTypes.aadl"); + validation.assertNoIssues(library); + var pkg = testHelper.parseFile(PROJECT_LOCATION + "ValidTypeProducts.aadl", + PROJECT_LOCATION + "ErrorTypes.aadl"); + validation.assertNoIssues(pkg); + } +} From 6ec8856235a24e9d874d69874b8ce7395903da2f Mon Sep 17 00:00:00 2001 From: Lutz Wrage Date: Fri, 18 Sep 2026 12:15:27 -0400 Subject: [PATCH 2/2] Validate every type set reference in type products Check each element of an EMV2 type product and report type set errors against the indexed TypeToken.type reference. This catches non-leading type sets and limits each diagnostic to the offending reference while preserving the existing named message and valid standalone type sets. The issue #2743 regression now passes both tests, including all seven expected reference diagnostics. --- .../aadl2/errormodel/validation/ErrorModelValidator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java b/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java index 821454b3d5c..e94e3f8ed43 100644 --- a/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java +++ b/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java @@ -716,9 +716,11 @@ private ErrorType sameRoot(Collection matchTypes, ErrorType et) { private void checkTypeTokenSingleTypeSet(TypeToken ts) { EList ets = ts.getType(); if (ets.size() > 1) { - ErrorTypes first = ets.get(0); - if (first instanceof TypeSet) { - error(ts, "Type product contains type set " + first.getName()); + for (int i = 0; i < ets.size(); i++) { + if (ets.get(i) instanceof TypeSet typeSet) { + error("Type product contains type set " + typeSet.getName(), ts, + ErrorModelPackage.Literals.TYPE_TOKEN__TYPE, i, null); + } } } }