Skip to content

Commit 378a870

Browse files
committed
Merge pull request #822 from Systems-Modeling/ST6RI-981
ST6RI-981 Move feature-chain source-target creation from derived queries to explicit model preparation
2 parents 3d912cd + 7438411 commit 378a870

12 files changed

Lines changed: 619 additions & 107 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
* Copyright (c) 2026 Obeo
5+
*
6+
* This program and the accompanying materials are made available under the
7+
* terms of the Eclipse Public License 2.0 which is available at
8+
* http://www.eclipse.org/legal/epl-2.0.
9+
*
10+
* SPDX-License-Identifier: EPL-2.0
11+
*******************************************************************************/
12+
13+
package org.omg.kerml.xtext.postprocessing;
14+
15+
import org.omg.sysml.lang.sysml.FeatureChainExpression;
16+
import org.omg.sysml.util.ExpressionUtil;
17+
18+
/** Prepares the owned source-target feature of a feature-chain expression. */
19+
public class FeatureChainExpressionParserPostProcessor extends InvocationExpressionParserPostProcessor {
20+
21+
public FeatureChainExpressionParserPostProcessor(FeatureChainExpression element) {
22+
super(element);
23+
}
24+
25+
@Override
26+
public FeatureChainExpression getTarget() {
27+
return (FeatureChainExpression)super.getTarget();
28+
}
29+
30+
@Override
31+
public void postProcess() {
32+
super.postProcess();
33+
ExpressionUtil.prepareSourceTargetFeature(getTarget());
34+
}
35+
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.kerml.xtext.postprocessing;
23+
24+
import org.omg.sysml.lang.sysml.InvocationExpression;
25+
26+
public class InvocationExpressionParserPostProcessor extends InstantiationExpressionParserPostProcessor {
27+
28+
public InvocationExpressionParserPostProcessor(InvocationExpression element) {
29+
super(element);
30+
}
31+
32+
@Override
33+
public InvocationExpression getTarget() {
34+
return (InvocationExpression)super.getTarget();
35+
}
36+
}

‎org.omg.kerml.xtext/src/org/omg/kerml/xtext/postprocessing/KerMLParserPostProcessorFactory.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public ElementParserPostProcessor caseFeature(Feature element) {
8888
return new FeatureParserPostProcessor(element);
8989
}
9090

91+
@Override
92+
public ElementParserPostProcessor caseFeatureChainExpression(FeatureChainExpression element) {
93+
return new FeatureChainExpressionParserPostProcessor(element);
94+
}
95+
9196
@Override
9297
public ElementParserPostProcessor caseFeatureMembership(FeatureMembership element) {
9398
return new FeatureMembershipParserPostProcessor(element);
@@ -123,6 +128,11 @@ public ElementParserPostProcessor caseIntersecting(Intersecting element) {
123128
return new IntersectingParserPostProcessor(element);
124129
}
125130

131+
@Override
132+
public ElementParserPostProcessor caseInvocationExpression(InvocationExpression element) {
133+
return new InvocationExpressionParserPostProcessor(element);
134+
}
135+
126136
@Override
127137
public ElementParserPostProcessor caseLiteralExpression(LiteralExpression element) {
128138
return new LiteralExpressionParserPostProcessor(element);

‎org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/ExpressionResultConsultationTest.java‎

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
33
* Copyright (c) 2026 Obeo
4+
* Copyright (c) 2026 Model Driven Solutions, Inc.
45
*
56
* This program and the accompanying materials are made available under the
67
* terms of the Eclipse Public License 2.0 which is available at
@@ -19,8 +20,6 @@
1920

2021
import java.io.ByteArrayInputStream;
2122
import java.io.ByteArrayOutputStream;
22-
import java.nio.file.Path;
23-
import java.util.Collections;
2423
import java.util.List;
2524
import java.util.Map;
2625

@@ -29,11 +28,7 @@
2928
import org.eclipse.emf.ecore.resource.Resource;
3029
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
3130
import org.eclipse.xtext.EcoreUtil2;
32-
import org.junit.After;
33-
import org.junit.BeforeClass;
3431
import org.junit.Test;
35-
import org.omg.sysml.interactive.SysMLInteractive;
36-
import org.omg.sysml.interactive.SysMLInteractiveResult;
3732
import org.omg.sysml.lang.sysml.ConstructorExpression;
3833
import org.omg.sysml.lang.sysml.Element;
3934
import org.omg.sysml.lang.sysml.Expression;
@@ -54,42 +49,7 @@
5449
import org.omg.sysml.xtext.postprocessing.SysMLParserPostProcessorFactory;
5550

5651
/** Tests the semantic contract of expression results across consultation and explicit transformation. */
57-
public class ExpressionResultConsultationTest {
58-
59-
protected static SysMLInteractive interactive;
60-
61-
/** Loads and resolves the standard library once for the textual scenarios. */
62-
@BeforeClass
63-
public static void loadLibraries() {
64-
interactive = SysMLInteractive.createInstance();
65-
interactive.setVerbose(false);
66-
interactive.loadLibrary(Path.of(System.getProperty("libraryPath")).toAbsolutePath().toString());
67-
}
68-
69-
/** Removes each test model while retaining the shared resolved libraries. */
70-
@After
71-
public void removeModels() {
72-
interactive.removeResource();
73-
}
74-
75-
private Resource parse(String name, String text) throws Exception {
76-
interactive.setResource(name);
77-
interactive.parse(text);
78-
Element rootElement = interactive.getRootElement();
79-
SysMLInteractiveResult result = new SysMLInteractiveResult(rootElement, Collections.emptyList());
80-
assertTrue("'" + text + "':\n" + result.formatIssues(), result.getIssues().isEmpty());
81-
return interactive.getResource();
82-
}
83-
84-
private static <T extends Type> T findByName(Resource resource, String name, Class<T> kind) {
85-
for (var contents = resource.getAllContents(); contents.hasNext();) {
86-
var object = contents.next();
87-
if (kind.isInstance(object) && name.equals(kind.cast(object).getDeclaredName())) {
88-
return kind.cast(object);
89-
}
90-
}
91-
throw new AssertionError("Missing " + name);
92-
}
52+
public class ExpressionResultConsultationTest extends SysMLInteractiveTest {
9353

9454
private static <T> T findSingle(Resource resource, Class<T> kind) {
9555
T found = null;

0 commit comments

Comments
 (0)