-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from Systems-Modeling/ST6RI-752
ST6RI-752 Reimplement Xtext workarounds using Xtext parse postprocessing
- Loading branch information
Showing
46 changed files
with
1,283 additions
and
703 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
org.omg.sysml/src/org/omg/sysml/adapter/AnnotationAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/******************************************************************************* | ||
* SysML 2 Pilot Implementation | ||
* Copyright (c) 2024 Model Driven Solutions, Inc. | ||
* Copyright (c) 2024 Budapest University of Technology and Economics | ||
* | ||
* 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 theGNU 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.sysml.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 AnnotationAdapter extends RelationshipAdapter { | ||
|
||
public AnnotationAdapter(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); | ||
} | ||
} | ||
|
||
// If there is no annotatingElement set, then set the AnnotatingElement to the owningRelatedElement, | ||
// if it is an AnnotatingElement, otherwise set it to the first ownedRelatedElement that is an | ||
// AnnotatingElement (if any). | ||
Object annotatingElement = obj.eGet(SysMLPackage.Literals.ANNOTATION__ANNOTATING_ELEMENT, false); | ||
if (annotatingElement == null) { | ||
Element owner = obj.getOwningRelatedElement(); | ||
obj.setAnnotatingElement((AnnotatingElement) | ||
(owner instanceof AnnotatingElement? owner: | ||
obj.getOwnedRelatedElement().stream(). | ||
filter(AnnotatingElement.class::isInstance). | ||
findFirst().orElse(null))); | ||
} | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
org.omg.sysml/src/org/omg/sysml/adapter/ConjugationAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/******************************************************************************* | ||
* SysML 2 Pilot Implementation | ||
* Copyright (c) 2024 Model Driven Solutions, Inc. | ||
* Copyright (c) 2024 Budapest University of Technology and Economics | ||
* | ||
* 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 theGNU 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.sysml.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 ConjugationAdapter extends RelationshipAdapter { | ||
|
||
public ConjugationAdapter(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)); | ||
} | ||
} | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
org.omg.sysml/src/org/omg/sysml/adapter/DependencyAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* SysML 2 Pilot Implementation | ||
* Copyright (c) 2024 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.sysml.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 DependencyAdapter extends RelationshipAdapter { | ||
|
||
public DependencyAdapter(Dependency element) { | ||
super(element); | ||
} | ||
|
||
public Dependency getTarget() { | ||
return (Dependency)super.getTarget(); | ||
} | ||
|
||
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); | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
org.omg.sysml/src/org/omg/sysml/adapter/DifferencingAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* SysML 2 Pilot Implementation | ||
* Copyright (c) 2024 Model Driven Solutions, Inc. | ||
* Copyright (c) 2024 Budapest University of Technology and Economics | ||
* | ||
* 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 theGNU 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.sysml.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 DifferencingAdapter extends RelationshipAdapter { | ||
|
||
public DifferencingAdapter(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)); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.