Skip to content

Commit 840a9f7

Browse files
authored
Merge pull request #762 from Systems-Modeling/ST6RI-932
ST6RI-932 SysML 2.1 Ballot #2 - Abstract Syntax
2 parents b608c9a + 6159d56 commit 840a9f7

11 files changed

Lines changed: 151 additions & 25 deletions

File tree

org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/DerivedPropertyAndOperationTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.omg.sysml.lang.sysml.FeatureMembership;
4949
import org.omg.sysml.lang.sysml.ItemUsage;
5050
import org.omg.sysml.lang.sysml.Membership;
51+
import org.omg.sysml.lang.sysml.MetadataUsage;
5152
import org.omg.sysml.lang.sysml.Namespace;
5253
import org.omg.sysml.lang.sysml.Relationship;
5354
import org.omg.sysml.lang.sysml.TriggerInvocationExpression;
@@ -488,4 +489,42 @@ public void testNamespaceResolve() throws Exception {
488489
assertSame("Test.resolve(Test::C::g)", g.getOwningMembership(), Test.resolve("Test::C::g"));
489490
}
490491

492+
public final String ownedMetadataTest =
493+
"package Test {\n"
494+
+ " part def P {\n"
495+
+ " @M1; @M2;\n"
496+
+ " part p : P {\n"
497+
+ " @M1; @M2;\n"
498+
+ " }\n"
499+
+ " }\n"
500+
+ " metadata def M1;\n"
501+
+ " metadata def M2;\n"
502+
+ "}";
503+
504+
@Test
505+
public void testOwnedMetadataAndNestedMetadata() throws Exception {
506+
SysMLInteractive instance = createSysMLInteractiveInstance();
507+
SysMLInteractiveResult result = instance.process(ownedMetadataTest);
508+
Element root = result.getRootElement();
509+
List<Element> elements = ((Namespace)root).getOwnedMember();
510+
Namespace Test = (Namespace)elements.get(0);
511+
List<Element> ownedMembers = Test.getOwnedMember();
512+
Definition P = (Definition)ownedMembers.get(0);
513+
List<Element> P_ownedMembers = P.getOwnedMember();
514+
Usage P_M1 = (Usage)P_ownedMembers.get(0);
515+
Usage P_M2 = (Usage)P_ownedMembers.get(1);
516+
Usage p = (Usage)P_ownedMembers.get(2);
517+
List<Element> p_ownedMembers = p.getOwnedMember();
518+
Usage p_M1 = (Usage)p_ownedMembers.get(0);
519+
Usage p_M2 = (Usage)p_ownedMembers.get(1);
520+
521+
List<MetadataUsage> ownedMetadata = P.getOwnedMetadata();
522+
assertTrue("P_M1", ownedMetadata.contains(P_M1));
523+
assertTrue("P_M2", ownedMetadata.contains(P_M2));
524+
525+
List<MetadataUsage> nestedMetadata = p.getNestedMetadata();
526+
assertTrue("p_M1", nestedMetadata.contains(p_M1));
527+
assertTrue("p_M2", nestedMetadata.contains(p_M2));
528+
}
529+
491530
}

org.omg.sysml.interactive.tests/src/org/omg/sysml/interactive/tests/SysMLInteractiveTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021-2022 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021-2022, 2026 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the Eclipse Public License as published by

org.omg.sysml.logic/src/main/java/org/omg/sysml/adapter/ConstraintUsageAdapter.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ protected String getDefaultSupertype() {
8484
}
8585

8686
protected boolean isCheckedConstraint() {
87-
/*
88-
* TODO: Update checkConstraintUsageCheckedConstraintSpecialization
89-
*
90-
* OCL doesn't require composite
91-
*
92-
*/
9387
ConstraintUsage target = getTarget();
9488
Type owningType = target.getOwningType();
9589
return target.isComposite() &&

org.omg.sysml.logic/src/main/java/org/omg/sysml/adapter/IncludeUseCaseUsageAdapter.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021, 2022, 2025 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021, 2022, 2025, 2026 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the Eclipse Public License as published by
@@ -38,11 +38,6 @@ public IncludeUseCaseUsage getTarget() {
3838
return (IncludeUseCaseUsage)super.getTarget();
3939
}
4040

41-
/**
42-
* TODO: Rename checkIncludeUseCaseSpecialization
43-
* See SYSML21-299
44-
*/
45-
4641
/**
4742
* @satisfies checkIncludeUseCaseUsageSpecialization
4843
*/

org.omg.sysml.logic/src/main/java/org/omg/sysml/delegate/setting/AssignmentActionUsage_referent_SettingDelegate.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
33
* Copyright (c) 2022 Siemens AG
4-
* Copyright (c) 2023 Model Driven Solutions, Inc.
4+
* Copyright (c) 2023, 2026 Model Driven Solutions, Inc.
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the Eclipse Public License as published by
@@ -28,6 +28,7 @@
2828
import org.omg.sysml.lang.sysml.Feature;
2929
import org.omg.sysml.lang.sysml.FeatureMembership;
3030
import org.omg.sysml.lang.sysml.Membership;
31+
import org.omg.sysml.lang.sysml.MetadataFeature;
3132

3233
public class AssignmentActionUsage_referent_SettingDelegate extends BasicDerivedObjectSettingDelegate {
3334

@@ -41,6 +42,7 @@ protected EObject basicGet(InternalEObject owner) {
4142
filter(m->!(m instanceof FeatureMembership)).
4243
map(Membership::getMemberElement).
4344
filter(Feature.class::isInstance).
45+
filter(f->!(f instanceof MetadataFeature)).
4446
findFirst().orElse(null);
4547
}
4648

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 Eclipse Public License as published by
7+
* the Eclipse Foundation, version 2 of the License.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* Eclipse Public License for more details.
13+
*
14+
* You should have received a copy of the Eclipse Public License
15+
* along with this program. If not, see <https://www.eclipse.org/legal/epl-2.0/>.
16+
*
17+
* @license EPL-2.0 <http://spdx.org/licenses/EPL-2.0>
18+
*
19+
*******************************************************************************/
20+
21+
package org.omg.sysml.delegate.setting;
22+
23+
import org.eclipse.emf.common.util.EList;
24+
import org.eclipse.emf.ecore.EStructuralFeature;
25+
import org.eclipse.emf.ecore.InternalEObject;
26+
import org.omg.sysml.lang.sysml.Definition;
27+
import org.omg.sysml.lang.sysml.MetadataUsage;
28+
import org.omg.sysml.util.NonNotifyingEObjectEList;
29+
30+
public class Definition_ownedMetadata_SettingDelegate extends BasicDerivedListSettingDelegate {
31+
32+
public Definition_ownedMetadata_SettingDelegate(EStructuralFeature eStructuralFeature) {
33+
super(eStructuralFeature);
34+
}
35+
36+
@Override
37+
protected EList<MetadataUsage> basicGet(InternalEObject owner) {
38+
EList<MetadataUsage> ownedMetadata = new NonNotifyingEObjectEList<>(MetadataUsage.class, owner, eStructuralFeature.getFeatureID());
39+
((Definition)owner).getMember().stream().
40+
filter(MetadataUsage.class::isInstance).
41+
map(MetadataUsage.class::cast).
42+
forEachOrdered(ownedMetadata::add);
43+
return ownedMetadata;
44+
}
45+
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 Eclipse Public License as published by
7+
* the Eclipse Foundation, version 2 of the License.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* Eclipse Public License for more details.
13+
*
14+
* You should have received a copy of the Eclipse Public License
15+
* along with this program. If not, see <https://www.eclipse.org/legal/epl-2.0/>.
16+
*
17+
* @license EPL-2.0 <http://spdx.org/licenses/EPL-2.0>
18+
*
19+
*******************************************************************************/
20+
21+
package org.omg.sysml.delegate.setting;
22+
23+
import org.eclipse.emf.common.util.EList;
24+
import org.eclipse.emf.ecore.EStructuralFeature;
25+
import org.eclipse.emf.ecore.InternalEObject;
26+
import org.omg.sysml.lang.sysml.MetadataUsage;
27+
import org.omg.sysml.lang.sysml.Usage;
28+
import org.omg.sysml.util.NonNotifyingEObjectEList;
29+
30+
public class Usage_nestedMetadata_SettingDelegate extends BasicDerivedListSettingDelegate {
31+
32+
public Usage_nestedMetadata_SettingDelegate(EStructuralFeature eStructuralFeature) {
33+
super(eStructuralFeature);
34+
}
35+
36+
@Override
37+
protected EList<MetadataUsage> basicGet(InternalEObject owner) {
38+
EList<MetadataUsage> nestedMetadata = new NonNotifyingEObjectEList<>(MetadataUsage.class, owner, eStructuralFeature.getFeatureID());
39+
((Usage)owner).getMember().stream().
40+
filter(MetadataUsage.class::isInstance).
41+
map(MetadataUsage.class::cast).
42+
forEachOrdered(nestedMetadata::add);
43+
return nestedMetadata;
44+
}
45+
46+
}

org.omg.sysml.logic/src/main/java/org/omg/sysml/util/ImplicitGeneralizationMap.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,6 @@ protected ImplicitGeneralizationMap() {
571571
//checkViewpointUsageViewpointSatisfactionSpecialization
572572
put(ViewpointUsageImpl.class, "satisfied", "Views::View::viewpointSatisfactions");
573573

574-
/*
575-
* TODO: Update checkViewpointDefinitionSpecialization and checkViewpointUsageSpecialization
576-
*
577-
* See SYSML21-301
578-
*/
579-
580574
//checkWhileLoopActionUsageSpecialization
581575
put(WhileLoopActionUsageImpl.class, "base", "Actions::whileLoopActions");
582576
//checkWhileLoopActionUsageSubactionSpecialization

org.omg.sysml.logic/src/main/java/org/omg/sysml/util/UsageUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ public static RequirementUsage getOwnedObjectiveRequirementOf(Type type) {
144144
}
145145

146146
public static RequirementUsage getObjectiveRequirementOf(Type type) {
147-
// TODO: Update checkRequirementUsageObjectiveRedefinition
148-
// See SYSML21-309
149147
if (type instanceof Feature) {
150148
type = ((Feature)type).getFeatureTarget();
151149
}

org.omg.sysml.xpect.tests/src/org/omg/sysml/xpect/tests/validation/invalid/AssignmentActionUsage_invalid.sysml.xt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ package AssignmentActionUsage_invalid {
3333
attribute a;
3434
protected attribute b;
3535
private attribute c;
36+
action d;
3637
}
3738
action def A {
3839
assign i.a := null;
3940
// XPECT errors --> "Couldn't resolve reference to Element 'b'." at "b"
4041
assign i.b := null;
4142
// XPECT errors --> "Couldn't resolve reference to Element 'c'." at "c"
4243
assign i.c := null;
44+
// XPECT errors --> "Referent must be time varying." at "d"
45+
assign i.d := null;
4346
}
4447
}

0 commit comments

Comments
 (0)