Skip to content
Open
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
@@ -1,24 +1,34 @@
package org.omg.kerml.xpect.tests;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.omg.kerml.xpect.tests.imports.global.KerMLImportGlobalTest;
import org.omg.kerml.xpect.tests.imports.local.KerMLImportLocalTest;
import org.omg.kerml.xpect.tests.imports.recursive.KerMLImportRecursiveTest;
import org.omg.kerml.xpect.tests.indexing.KerMLIndexerTest;
import org.omg.kerml.xpect.tests.linking.KerMLLinkingTest;
import org.omg.kerml.xpect.tests.parsing.KerMLParsingTest;
import org.omg.kerml.xpect.tests.scoping.KerMLScopingTest;
import org.omg.kerml.xpect.tests.testsuite.KerMLXtextTest;
import org.omg.kerml.xpect.tests.validation.KerMLValidationTest;
import org.omg.kerml.xpect.tests.visibility.KerMLVisibilityTest;

@SuiteClasses({
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.xpect.tests;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.omg.kerml.xpect.tests.imports.global.KerMLImportGlobalTest;
import org.omg.kerml.xpect.tests.imports.local.KerMLImportLocalTest;
import org.omg.kerml.xpect.tests.imports.recursive.KerMLImportRecursiveTest;
import org.omg.kerml.xpect.tests.indexing.KerMLIndexerTest;
import org.omg.kerml.xpect.tests.linking.KerMLLinkingTest;
import org.omg.kerml.xpect.tests.parsing.KerMLParsingTest;
import org.omg.kerml.xpect.tests.scoping.KerMLScopingTest;
import org.omg.kerml.xpect.tests.testsuite.KerMLXtextTest;
import org.omg.kerml.xpect.tests.validation.KerMLValidationTest;
import org.omg.kerml.xpect.tests.visibility.KerMLVisibilityTest;

@SuiteClasses({
KerMLImportGlobalTest.class, //
KerMLImportLocalTest.class, //
KerMLImportRecursiveTest.class, //
KerMLLinkingTest.class,//
KerMLLinkingTest.class,//
KerMLParsingTest.class, //
KerMLScopingTest.class, //
KerMLXtextTest.class, //
Expand Down
1 change: 1 addition & 0 deletions org.omg.kerml.xtext/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.xtext.common.types,
org.objectweb.asm;bundle-version="9.3.0";resolution:=optional
Export-Package: org.omg.kerml.xtext,
org.omg.kerml.xtext.adapter,
org.omg.kerml.xtext.conversion,
org.omg.kerml.xtext.generator,
org.omg.kerml.xtext.library,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.omg.sysml.lang.sysml.AnnotatingElement;
import org.omg.sysml.lang.sysml.Annotation;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.SysMLPackage;

public class AnnotationParserAdapter extends ElementParserAdapter {

public AnnotationParserAdapter(Annotation element) {
super(element);
}

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

@Override
public void postProcess() {
Annotation obj = getTarget();

// If the Annotation is not owned by an AnnotatingElement, then the annotatedElement is the owningRelatedElement.
Object annotatedElement = obj.eGet(SysMLPackage.Literals.ANNOTATION__ANNOTATED_ELEMENT, false);
if (annotatedElement == null) {
Element owningRelatedElement = obj.getOwningRelatedElement();
if (!(owningRelatedElement instanceof AnnotatingElement)) {
obj.setAnnotatedElement(owningRelatedElement);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.omg.sysml.lang.sysml.Comment;
import org.omg.sysml.util.ElementUtil;

public class CommentParserAdapter extends ElementParserAdapter {

public CommentParserAdapter(Comment element) {
super(element);
}

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

@Override
public void postProcess() {
super.postProcess();
Comment target = getTarget();
target.setLocale(ElementUtil.unescapeString(target.getLocale()));
target.setBody(ElementUtil.processCommentBody(target.getBody()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.lang.sysml.Conjugation;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.SysMLPackage;
import org.omg.sysml.lang.sysml.Type;

public class ConjugationParserAdapter extends ElementParserAdapter {

public ConjugationParserAdapter(Conjugation element) {
super(element);
}

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

@Override
public void postProcess() {
Conjugation obj = getTarget();

// If the conjugatedType is not set, then set it to the owningRelatedElement, if this is a Type,
// otherwise set it to the first ownedRelatedElement.
Object conjugatedType = obj.eGet(SysMLPackage.Literals.CONJUGATION__CONJUGATED_TYPE, false);
if (conjugatedType == null) {
Element owner = obj.getOwningRelatedElement();
if (owner instanceof Type) {
obj.setConjugatedType((Type)owner);
} else {
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
if (!ownedRelatedElements.isEmpty()) {
obj.setConjugatedType((Type)ownedRelatedElements.get(0));
}
}
}

// If the originalType is not set, set it to the last ownedRelatedElement.
Object originalType = obj.eGet(SysMLPackage.Literals.CONJUGATION__ORIGINAL_TYPE, false);
if (originalType == null) {
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
if (!ownedRelatedElements.isEmpty()) {
obj.setOriginalType((Type)ownedRelatedElements.get(ownedRelatedElements.size() - 1));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.omg.sysml.lang.sysml.Dependency;
import org.omg.sysml.lang.sysml.Element;

public class DependencyParserAdapter extends ElementParserAdapter {

public DependencyParserAdapter(Dependency element) {
super(element);
}

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

@Override
public void postProcess() {
Dependency target = getTarget();

// Add all ownedRelatedElements to supplier.
EObjectResolvingEList<Element> suppliers = (EObjectResolvingEList<Element>)target.getSupplier();
EList<Element> ownedRelatedElements = target.getOwnedRelatedElement();
ownedRelatedElements.stream().forEachOrdered(suppliers::addUnique);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.lang.sysml.Differencing;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.SysMLPackage;

public class DifferencingParserAdapter extends ElementParserAdapter {

public DifferencingParserAdapter(Differencing element) {
super(element);
}

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

@Override
public void postProcess() {
Differencing obj = getTarget();

// If a Differencing is parsed targeting a Feature chain, then the differencingType will be empty,
// but the Differencing will own the differencingType. So, in this case, the differencingType should
// be set to the (last) ownedRelatedelement.
Object differencingType = obj.eGet(SysMLPackage.Literals.DIFFERENCING__DIFFERENCING_TYPE, false);
if (differencingType == null) {
// Handle a differencingType that is a Feature chain.
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
if (!ownedRelatedElements.isEmpty()) {
obj.setDifferencingType((Feature)ownedRelatedElements.get(ownedRelatedElements.size() - 1));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.lang.sysml.Disjoining;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.SysMLPackage;
import org.omg.sysml.lang.sysml.Type;

public class DisjoiningParserAdapter extends ElementParserAdapter {

public DisjoiningParserAdapter(Disjoining element) {
super(element);
}

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

@Override
public void postProcess() {
Disjoining obj = getTarget();

// If a Disjoining is parsed targeting a Feature chain, then the disjoiningType will be empty,
// but the Disjoining will own the disjoiningType. So, in this case, the disjoiningType should
// be set to the (last) ownedRelatedelement.
Object disjoiningType = obj.eGet(SysMLPackage.Literals.DISJOINING__DISJOINING_TYPE, false);
if (disjoiningType == null) {
// Handle a disjoiningType that is a Feature chain.
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
if (!ownedRelatedElements.isEmpty()) {
obj.setDisjoiningType((Feature)ownedRelatedElements.get(ownedRelatedElements.size() - 1));
}
}

// If the typedDisjoined (source) is empty, set it to the owningRelatedElement, if it is a Type.
// Otherwise, set it to the first ownedRelatedElement, to the first ownedRelatedElement,
// which will be a Feature chain.
Object typeDisjoined = obj.eGet(SysMLPackage.Literals.DISJOINING__TYPE_DISJOINED, false);
if (typeDisjoined == null) {
Element owner = obj.getOwningRelatedElement();
if (owner instanceof Type) {
// Handle a Disjoining owned by the typeDisjoined.
obj.setTypeDisjoined((Type)owner);
} else {
// Handle a typeDisjoined that is a Feature chain.
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
if (!ownedRelatedElements.isEmpty()) {
obj.setTypeDisjoined((Feature)ownedRelatedElements.get(0));
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* 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.adapter;

import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.util.ElementUtil;

public class ElementParserAdapter extends AdapterImpl {

protected Class<?> kind;

public ElementParserAdapter(Element element) {
super();
kind = element.getClass();
}

public Element getTarget() {
return (Element)super.getTarget();
}

@Override
public boolean isAdapterForType(Object object) {
return kind.isInstance(object);
}

public void postProcess() {
Element target = getTarget();
target.setDeclaredName(ElementUtil.unescapeString(target.getDeclaredName()));
target.setDeclaredShortName(ElementUtil.unescapeString(target.getDeclaredShortName()));
}
}
Loading
Loading