Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.aadlbin-gen/
/instances/
18 changes: 18 additions & 0 deletions emv2/org.osate.aadl2.errormodel.tests/models/issue2743/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>issue2743</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.osate.core.aadlnature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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<AadlPackage> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,11 @@ private ErrorType sameRoot(Collection<ErrorType> matchTypes, ErrorType et) {
private void checkTypeTokenSingleTypeSet(TypeToken ts) {
EList<ErrorTypes> 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);
}
}
}
}
Expand Down