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,36 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Model Driven Solutions, Inc.
* Copyright (c) 2026 Obeo
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package org.omg.kerml.xtext.postprocessing;

import org.omg.sysml.lang.sysml.FeatureChainExpression;
import org.omg.sysml.util.ExpressionUtil;

/** Prepares the owned source-target feature of a feature-chain expression. */
public class FeatureChainExpressionParserPostProcessor extends InvocationExpressionParserPostProcessor {

public FeatureChainExpressionParserPostProcessor(FeatureChainExpression element) {
super(element);
}

@Override
public FeatureChainExpression getTarget() {
return (FeatureChainExpression)super.getTarget();
}

@Override
public void postProcess() {
super.postProcess();
ExpressionUtil.prepareSourceTargetFeature(getTarget());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/

package org.omg.kerml.xtext.postprocessing;

import org.omg.sysml.lang.sysml.InvocationExpression;

public class InvocationExpressionParserPostProcessor extends InstantiationExpressionParserPostProcessor {

public InvocationExpressionParserPostProcessor(InvocationExpression element) {
super(element);
}

@Override
public InvocationExpression getTarget() {
return (InvocationExpression)super.getTarget();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public ElementParserPostProcessor caseFeature(Feature element) {
return new FeatureParserPostProcessor(element);
}

@Override
public ElementParserPostProcessor caseFeatureChainExpression(FeatureChainExpression element) {
return new FeatureChainExpressionParserPostProcessor(element);
}

@Override
public ElementParserPostProcessor caseFeatureMembership(FeatureMembership element) {
return new FeatureMembershipParserPostProcessor(element);
Expand Down Expand Up @@ -123,6 +128,11 @@ public ElementParserPostProcessor caseIntersecting(Intersecting element) {
return new IntersectingParserPostProcessor(element);
}

@Override
public ElementParserPostProcessor caseInvocationExpression(InvocationExpression element) {
return new InvocationExpressionParserPostProcessor(element);
}

@Override
public ElementParserPostProcessor caseLiteralExpression(LiteralExpression element) {
return new LiteralExpressionParserPostProcessor(element);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Obeo
* Copyright (c) 2026 Model Driven Solutions, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -19,8 +20,6 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand All @@ -29,11 +28,7 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.xtext.EcoreUtil2;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.omg.sysml.interactive.SysMLInteractive;
import org.omg.sysml.interactive.SysMLInteractiveResult;
import org.omg.sysml.lang.sysml.ConstructorExpression;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.Expression;
Expand All @@ -54,42 +49,7 @@
import org.omg.sysml.xtext.postprocessing.SysMLParserPostProcessorFactory;

/** Tests the semantic contract of expression results across consultation and explicit transformation. */
public class ExpressionResultConsultationTest {

protected static SysMLInteractive interactive;

/** Loads and resolves the standard library once for the textual scenarios. */
@BeforeClass
public static void loadLibraries() {
interactive = SysMLInteractive.createInstance();
interactive.setVerbose(false);
interactive.loadLibrary(Path.of(System.getProperty("libraryPath")).toAbsolutePath().toString());
}

/** Removes each test model while retaining the shared resolved libraries. */
@After
public void removeModels() {
interactive.removeResource();
}

private Resource parse(String name, String text) throws Exception {
interactive.setResource(name);
interactive.parse(text);
Element rootElement = interactive.getRootElement();
SysMLInteractiveResult result = new SysMLInteractiveResult(rootElement, Collections.emptyList());
assertTrue("'" + text + "':\n" + result.formatIssues(), result.getIssues().isEmpty());
return interactive.getResource();
}

private static <T extends Type> T findByName(Resource resource, String name, Class<T> kind) {
for (var contents = resource.getAllContents(); contents.hasNext();) {
var object = contents.next();
if (kind.isInstance(object) && name.equals(kind.cast(object).getDeclaredName())) {
return kind.cast(object);
}
}
throw new AssertionError("Missing " + name);
}
public class ExpressionResultConsultationTest extends SysMLInteractiveTest {

private static <T> T findSingle(Resource resource, Class<T> kind) {
T found = null;
Expand Down
Loading