Skip to content

Commit 287bd59

Browse files
authored
Merge pull request #793 from Systems-Modeling/ST6RI-953
ST6RI-953 Extract parsing and linking completion concerns to Xtext modules
2 parents 13c32ea + 3beaefa commit 287bd59

93 files changed

Lines changed: 2596 additions & 759 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

org.omg.kerml.xpect.tests/src/org/omg/kerml/xpect/tests/AllKerMLXpectTests.java

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
package org.omg.kerml.xpect.tests;
2-
3-
import org.junit.runner.RunWith;
4-
import org.junit.runners.Suite;
5-
import org.junit.runners.Suite.SuiteClasses;
6-
import org.omg.kerml.xpect.tests.imports.global.KerMLImportGlobalTest;
7-
import org.omg.kerml.xpect.tests.imports.local.KerMLImportLocalTest;
8-
import org.omg.kerml.xpect.tests.imports.recursive.KerMLImportRecursiveTest;
9-
import org.omg.kerml.xpect.tests.indexing.KerMLIndexerTest;
10-
import org.omg.kerml.xpect.tests.linking.KerMLLinkingTest;
11-
import org.omg.kerml.xpect.tests.parsing.KerMLParsingTest;
12-
import org.omg.kerml.xpect.tests.scoping.KerMLScopingTest;
13-
import org.omg.kerml.xpect.tests.testsuite.KerMLXtextTest;
14-
import org.omg.kerml.xpect.tests.validation.KerMLValidationTest;
15-
import org.omg.kerml.xpect.tests.visibility.KerMLVisibilityTest;
16-
17-
@SuiteClasses({
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Obeo
4+
*
5+
* This program and the accompanying materials are made available under the
6+
* terms of the Eclipse Public License 2.0 which is available at
7+
* http://www.eclipse.org/legal/epl-2.0.
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
package org.omg.kerml.xpect.tests;
12+
13+
import org.junit.runner.RunWith;
14+
import org.junit.runners.Suite;
15+
import org.junit.runners.Suite.SuiteClasses;
16+
import org.omg.kerml.xpect.tests.imports.global.KerMLImportGlobalTest;
17+
import org.omg.kerml.xpect.tests.imports.local.KerMLImportLocalTest;
18+
import org.omg.kerml.xpect.tests.imports.recursive.KerMLImportRecursiveTest;
19+
import org.omg.kerml.xpect.tests.indexing.KerMLIndexerTest;
20+
import org.omg.kerml.xpect.tests.linking.KerMLLinkingTest;
21+
import org.omg.kerml.xpect.tests.parsing.KerMLParsingTest;
22+
import org.omg.kerml.xpect.tests.scoping.KerMLScopingTest;
23+
import org.omg.kerml.xpect.tests.testsuite.KerMLXtextTest;
24+
import org.omg.kerml.xpect.tests.validation.KerMLValidationTest;
25+
import org.omg.kerml.xpect.tests.visibility.KerMLVisibilityTest;
26+
27+
@SuiteClasses({
1828
KerMLImportGlobalTest.class, //
1929
KerMLImportLocalTest.class, //
2030
KerMLImportRecursiveTest.class, //
21-
KerMLLinkingTest.class,//
31+
KerMLLinkingTest.class,//
2232
KerMLParsingTest.class, //
2333
KerMLScopingTest.class, //
2434
KerMLXtextTest.class, //

org.omg.kerml.xtext/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Require-Bundle: org.eclipse.xtext,
2323
org.eclipse.xtext.common.types,
2424
org.objectweb.asm;bundle-version="9.3.0";resolution:=optional
2525
Export-Package: org.omg.kerml.xtext,
26+
org.omg.kerml.xtext.postprocessing,
2627
org.omg.kerml.xtext.conversion,
2728
org.omg.kerml.xtext.generator,
2829
org.omg.kerml.xtext.library,
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.AnnotatingElement;
25+
26+
public class AnnotatingElementParserPostProcessor extends ElementParserPostProcessor {
27+
28+
public AnnotatingElementParserPostProcessor(AnnotatingElement element) {
29+
super(element);
30+
}
31+
32+
public AnnotatingElement getTarget() {
33+
return (AnnotatingElement)super.getTarget();
34+
}
35+
36+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Obeo
4+
* Copyright (c) 2026 Model Driven Solutions, Inc.
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.AnnotatingElement;
16+
import org.omg.sysml.lang.sysml.Annotation;
17+
import org.omg.sysml.lang.sysml.Element;
18+
import org.omg.sysml.lang.sysml.SysMLPackage;
19+
20+
public class AnnotationParserPostProcessor extends RelationshipParserPostProcessor {
21+
22+
public AnnotationParserPostProcessor(Annotation element) {
23+
super(element);
24+
}
25+
26+
@Override
27+
public Annotation getTarget() {
28+
return (Annotation)super.getTarget();
29+
}
30+
31+
@Override
32+
public void postProcess() {
33+
super.postProcess();
34+
Annotation obj = getTarget();
35+
36+
// If the Annotation is not owned by an AnnotatingElement, then the annotatedElement is the owningRelatedElement.
37+
Object annotatedElement = obj.eGet(SysMLPackage.Literals.ANNOTATION__ANNOTATED_ELEMENT, false);
38+
if (annotatedElement == null) {
39+
Element owningRelatedElement = obj.getOwningRelatedElement();
40+
if (!(owningRelatedElement instanceof AnnotatingElement)) {
41+
obj.setAnnotatedElement(owningRelatedElement);
42+
}
43+
}
44+
}
45+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program and the accompanying materials are made available under the
6+
* terms of the Eclipse Public License 2.0 which is available at
7+
* http://www.eclipse.org/legal/epl-2.0.
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
12+
package org.omg.kerml.xtext.postprocessing;
13+
14+
import org.omg.sysml.lang.sysml.Classifier;
15+
16+
public class ClassifierParserPostProcessor extends TypeParserPostProcessor {
17+
18+
public ClassifierParserPostProcessor(Classifier element) {
19+
super(element);
20+
}
21+
22+
@Override
23+
public Classifier getTarget() {
24+
return (Classifier)super.getTarget();
25+
}
26+
27+
}
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 Obeo
4+
* Copyright (c) 2026 Model Driven Solutions, Inc.
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.Comment;
16+
import org.omg.sysml.util.ElementUtil;
17+
18+
public class CommentParserPostProcessor extends AnnotatingElementParserPostProcessor {
19+
20+
public CommentParserPostProcessor(Comment element) {
21+
super(element);
22+
}
23+
24+
@Override
25+
public Comment getTarget() {
26+
return (Comment)super.getTarget();
27+
}
28+
29+
@Override
30+
public void postProcess() {
31+
super.postProcess();
32+
Comment target = getTarget();
33+
target.setLocale(ElementUtil.unescapeString(target.getLocale()));
34+
target.setBody(ElementUtil.processCommentBody(target.getBody()));
35+
}
36+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Obeo
4+
* Copyright (c) 2026 Model Driven Solutions, Inc.
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.eclipse.emf.common.util.EList;
16+
import org.omg.sysml.lang.sysml.Conjugation;
17+
import org.omg.sysml.lang.sysml.Element;
18+
import org.omg.sysml.lang.sysml.SysMLPackage;
19+
import org.omg.sysml.lang.sysml.Type;
20+
21+
public class ConjugationParserPostProcessor extends RelationshipParserPostProcessor {
22+
23+
public ConjugationParserPostProcessor(Conjugation element) {
24+
super(element);
25+
}
26+
27+
@Override
28+
public Conjugation getTarget() {
29+
return (Conjugation)super.getTarget();
30+
}
31+
32+
@Override
33+
public void postProcess() {
34+
super.postProcess();
35+
Conjugation obj = getTarget();
36+
37+
// If the conjugatedType is not set, then set it to the owningRelatedElement, if this is a Type,
38+
// otherwise set it to the first ownedRelatedElement.
39+
Object conjugatedType = obj.eGet(SysMLPackage.Literals.CONJUGATION__CONJUGATED_TYPE, false);
40+
if (conjugatedType == null) {
41+
Element owner = obj.getOwningRelatedElement();
42+
if (owner instanceof Type) {
43+
obj.setConjugatedType((Type)owner);
44+
} else {
45+
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
46+
if (!ownedRelatedElements.isEmpty()) {
47+
obj.setConjugatedType((Type)ownedRelatedElements.get(0));
48+
}
49+
}
50+
}
51+
52+
// If the originalType is not set, set it to the last ownedRelatedElement.
53+
Object originalType = obj.eGet(SysMLPackage.Literals.CONJUGATION__ORIGINAL_TYPE, false);
54+
if (originalType == null) {
55+
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
56+
if (!ownedRelatedElements.isEmpty()) {
57+
obj.setOriginalType((Type)ownedRelatedElements.get(ownedRelatedElements.size() - 1));
58+
}
59+
}
60+
}
61+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Obeo
4+
* Copyright (c) 2026 Model Driven Solutions, Inc.
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.eclipse.emf.common.util.EList;
16+
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
17+
import org.omg.sysml.lang.sysml.Dependency;
18+
import org.omg.sysml.lang.sysml.Element;
19+
20+
public class DependencyParserPostProcessor extends RelationshipParserPostProcessor {
21+
22+
public DependencyParserPostProcessor(Dependency element) {
23+
super(element);
24+
}
25+
26+
@Override
27+
public Dependency getTarget() {
28+
return (Dependency)super.getTarget();
29+
}
30+
31+
@Override
32+
public void postProcess() {
33+
super.postProcess();
34+
Dependency target = getTarget();
35+
36+
// Add all ownedRelatedElements to supplier.
37+
EObjectResolvingEList<Element> suppliers = (EObjectResolvingEList<Element>)target.getSupplier();
38+
EList<Element> ownedRelatedElements = target.getOwnedRelatedElement();
39+
ownedRelatedElements.stream().forEachOrdered(suppliers::addUnique);
40+
}
41+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Obeo
4+
* Copyright (c) 2026 Model Driven Solutions, Inc.
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.eclipse.emf.common.util.EList;
16+
import org.omg.sysml.lang.sysml.Differencing;
17+
import org.omg.sysml.lang.sysml.Element;
18+
import org.omg.sysml.lang.sysml.Feature;
19+
import org.omg.sysml.lang.sysml.SysMLPackage;
20+
21+
public class DifferencingParserPostProcessor extends RelationshipParserPostProcessor {
22+
23+
public DifferencingParserPostProcessor(Differencing element) {
24+
super(element);
25+
}
26+
27+
@Override
28+
public Differencing getTarget() {
29+
return (Differencing)super.getTarget();
30+
}
31+
32+
@Override
33+
public void postProcess() {
34+
super.postProcess();
35+
Differencing obj = getTarget();
36+
37+
// If a Differencing is parsed targeting a Feature chain, then the differencingType will be empty,
38+
// but the Differencing will own the differencingType. So, in this case, the differencingType should
39+
// be set to the (last) ownedRelatedelement.
40+
Object differencingType = obj.eGet(SysMLPackage.Literals.DIFFERENCING__DIFFERENCING_TYPE, false);
41+
if (differencingType == null) {
42+
// Handle a differencingType that is a Feature chain.
43+
EList<Element> ownedRelatedElements = obj.getOwnedRelatedElement();
44+
if (!ownedRelatedElements.isEmpty()) {
45+
obj.setDifferencingType((Feature)ownedRelatedElements.get(ownedRelatedElements.size() - 1));
46+
}
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)