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
Expand Up @@ -506,8 +506,14 @@ private static boolean isAbstractFeature(final ConnectionInstanceEnd end) {
}

private static Classifier getConnectionEndClassifier(final ConnectionInstanceEnd end) {
return end instanceof ComponentInstance ? ((ComponentInstance) end).getClassifier()
: ((FeatureInstance) end).getFeature().getClassifier();
if (end instanceof ComponentInstance ci) {
return ci.getClassifier();
}
if (end instanceof FeatureInstance fi) {
var ci = fi.getType();
return ci == null ? null : ci.getClassifier();
}
return null;
}

// XXX How can I avoid duplicating this method for the instance and the declarative models?
Expand Down
2 changes: 2 additions & 0 deletions core/org.osate.core.tests/models/issue2915/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.aadlbin-gen/
/instances/
18 changes: 18 additions & 0 deletions core/org.osate.core.tests/models/issue2915/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Issue2915</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>
27 changes: 27 additions & 0 deletions core/org.osate.core.tests/models/issue2915/Issue2915.aadl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package Issue2915
public

system S
end S;

system implementation S.i
subcomponents
d: data D.i;
a: system A (dp => data D.i);
connections
da: data access d <-> a.da;
end S.i;

data D
end D;

data implementation D.i
end D.i;

system A
prototypes
dp: data D;
features
da: requires data access dp;
end A;
end Issue2915;
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright (c) 2004-2024 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 such Third Party
* Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici-
* aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li-
* censes only apply to the Third Party Software and not any other portion of this program or this program as a whole.
*/
package org.osate.core.tests.issues;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.XtextRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.SystemImplementation;
import org.osate.aadl2.instance.SystemInstance;
import org.osate.aadl2.instantiation.InstantiateModel;
import org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager;
import org.osate.aadl2.modelsupport.errorreporting.QueuingAnalysisErrorReporter;
import org.osate.aadl2.modelsupport.errorreporting.QueuingAnalysisErrorReporter.Message;
import org.osate.testsupport.Aadl2InjectorProvider;
import org.osate.testsupport.TestHelper;

import com.google.inject.Inject;
import com.itemis.xtext.testing.XtextTest;

@RunWith(XtextRunner.class)
@InjectWith(Aadl2InjectorProvider.class)
public class Issue2915Test extends XtextTest {

private static final String PATH = "org.osate.core.tests/models/issue2915/";

@Inject
TestHelper<AadlPackage> testHelper;

@Test
public void test1() throws Exception {
AadlPackage pkg = testHelper.parseFile(PATH + "Issue2915.aadl");
SystemImplementation s_i = (SystemImplementation) pkg.getPublicSection()
.getOwnedClassifiers()
.stream()
.filter(c -> c.getName().equals("S.i"))
.findFirst()
.get();

AnalysisErrorReporterManager errorManager = new AnalysisErrorReporterManager(
QueuingAnalysisErrorReporter.factory);
SystemInstance instance = InstantiateModel.instantiate(s_i, errorManager);
assertEquals("S_i_Instance", instance.getName());

List<Message> messages = ((QueuingAnalysisErrorReporter) errorManager.getReporter(instance.eResource()))
.getErrors();
assertTrue(messages.size() == 0);
}

}