Skip to content

Commit 5ecb5c5

Browse files
authored
Merge pull request #612 from Systems-Modeling/ST6RI-812
ST6RI-812 Additional issue resolutions from SysML v2 FTF2 Ballot #6 (SYSML2_-89, SYSML2_-265)
2 parents 6349b97 + 6c6df3b commit 5ecb5c5

12 files changed

Lines changed: 389 additions & 30 deletions

File tree

org.omg.sysml.interactive.tests/resources/org/omg/sysml/semantics/tests/sysml-simple-specializations.csv

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ true,checkPartUsageStakeholderSpecialization,PartUsage,Requirements::Requirement
3939
true,checkPartUsageActorSpecialization,PartUsage,Cases::Case::actors,CaseDefinition,ActorMembership
4040
true,checkPartUsageActorSpecialization,PartUsage,Cases::Case::actors,CaseUsage,ActorMembership
4141
true,checkPortUsageSpecialization,PortUsage,Ports::ports,Package,OwningMembership
42-
true,checkPortSubportSpecialization,PortUsage,Ports::Port::subports,PortUsage,FeatureMembership
43-
true,checkPortSubportSpecialization,PortUsage,Ports::Port::subports,PortDefinition,FeatureMembership
42+
true,checkPortUsageSubportSpecialization,PortUsage,Ports::Port::subports,PortUsage,FeatureMembership
43+
true,checkPortUsageSubportSpecialization,PortUsage,Ports::Port::subports,PortDefinition,FeatureMembership
44+
true,checkPortUsageOwnedPortSpecialization,PortUsage,Parts::Part::ownedPorts,PartUsage,FeatureMembership
45+
true,checkPortUsageOwnedPortSpecialization,PortUsage,Parts::Part::ownedPorts,PartDefinition,FeatureMembership
4446
true,checkConnectionUsageSpecialization,ConnectionUsage,Connections::connections,Package,OwningMembership
4547
true,checkFlowConnectionUsageSpecialization,FlowConnectionUsage,FlowConnections::messageConnections,Package,OwningMembership
4648
true,checkSuccessionFlowConnectionUsageSpecialization,SuccessionFlowConnectionUsage,FlowConnections::successionFlowConnections,Package,OwningMembership
@@ -64,9 +66,11 @@ true,checkPerformActionUsageSpecialization,PerformActionUsage,Parts::Part::perfo
6466
true,checkPerformActionUsageSpecialization,PerformActionUsage,Parts::Part::performedActions,PartDefinition,FeatureMembership
6567
true,checkStateUsageSpecialization,StateUsage,States::stateActions,Package,OwningMembership
6668
true,checkStateUsageExclusiveStateSpecialization,StateUsage,States::StateAction::exclusiveStates,StateUsage,FeatureMembership
69+
true,checkStateUsageOwnedStateSpecialization,StateUsage,Parts::Part::ownedStates,PartUsage,FeatureMembership
70+
true,checkStateUsageOwnedStateSpecialization,StateUsage,Parts::Part::ownedStates,PartDefinition,FeatureMembership
6771
true,checkTransitionUsageSpecialization,TransitionUsage,Actions::transitionActions,Package,OwningMembership
68-
true,checkTransitionUsageStateSpecialization,TransitionUsage,States::StateAction::stateTransitions,StateDefinition,FeatureMembership
69-
true,checkTransitionUsageStateSpecialization,TransitionUsage,States::StateAction::stateTransitions,StateUsage,FeatureMembership
72+
false,checkTransitionUsageStateSpecialization,TransitionUsage,States::StateAction::stateTransitions,StateDefinition,FeatureMembership
73+
false,checkTransitionUsageStateSpecialization,TransitionUsage,States::StateAction::stateTransitions,StateUsage,FeatureMembership
7074
true,checkTransitionUsageActionSpecialization,TransitionUsage,Actions::Action::decisionTransitions,ActionUsage,FeatureMembership
7175
true,checkTransitionUsageActionSpecialization,TransitionUsage,Actions::Action::decisionTransitions,ActionDefinition,FeatureMembership
7276
true,checkCalculationUsageSpecialization,CalculationUsage,Calculations::calculations,Package,OwningMembership

org.omg.sysml.interactive.tests/src/org/omg/sysml/semantics/tests/SysMLSpecializationSpecialTest.java

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* SysML 2 Pilot Implementation
3-
* Copyright (C) 2024 Model Driven Solutions, Inc.
3+
* Copyright (C) 2024-2025 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 GNU Lesser General Public License as published by
@@ -19,11 +19,26 @@
1919
*
2020
* Contributors:
2121
* Laszlo Gati, MDS
22+
* Ed Seidewitz, MDS
2223
*/
2324
package org.omg.sysml.semantics.tests;
2425

26+
import static org.junit.Assert.assertTrue;
27+
28+
import org.eclipse.emf.ecore.EClass;
29+
import org.eclipse.emf.ecore.EClassifier;
2530
import org.junit.Ignore;
2631
import org.junit.Test;
32+
import org.omg.sysml.lang.sysml.Element;
33+
import org.omg.sysml.lang.sysml.StateUsage;
34+
import org.omg.sysml.lang.sysml.SysMLFactory;
35+
import org.omg.sysml.lang.sysml.SysMLPackage;
36+
import org.omg.sysml.lang.sysml.TransitionUsage;
37+
import org.omg.sysml.lang.sysml.Type;
38+
import org.omg.sysml.lang.sysml.util.SysMLLibraryUtil;
39+
import org.omg.sysml.util.ElementUtil;
40+
import org.omg.sysml.util.NamespaceUtil;
41+
import org.omg.sysml.util.TypeUtil;
2742

2843
/**
2944
* Semantic constraint tests for "Implied Definition Subclassification Relationships" and
@@ -33,6 +48,49 @@
3348
*/
3449
public class SysMLSpecializationSpecialTest extends SysMLSemanticTest {
3550

51+
protected void checkTransitionUsageStateSpecialization(String owningTypeName) {
52+
//create and add root package
53+
org.omg.sysml.lang.sysml.Package root = SysMLFactory.eINSTANCE.createPackage();
54+
getResource().getContents().add(root);
55+
56+
//check if library element exists
57+
Element libraryElement = SysMLLibraryUtil.getLibraryElement(root, "States::StateAction::stateTransitions");
58+
assertTrue(libraryElement instanceof Type);
59+
60+
//create owning type
61+
EClassifier ownerEClass = SysMLPackage.eINSTANCE.getEClassifier(owningTypeName);
62+
Type owner = (Type) SysMLFactory.eINSTANCE.create((EClass) ownerEClass);
63+
NamespaceUtil.addOwnedMemberTo(root, owner);
64+
65+
//create source state usage
66+
StateUsage state = SysMLFactory.eINSTANCE.createStateUsage();
67+
state.setIsReference(false);
68+
TypeUtil.addOwnedFeatureTo(owner, state);
69+
70+
//create transition usage
71+
TransitionUsage transition = SysMLFactory.eINSTANCE.createTransitionUsage();
72+
transition.setIsReference(false);
73+
TypeUtil.addOwnedFeatureTo(owner, transition);
74+
75+
//add source state usage to transition usage
76+
NamespaceUtil.addMemberTo(transition, state);
77+
78+
//run transformation, add implicit elements
79+
ElementUtil.transformAll(root, true);
80+
81+
assertTrue(String.format("TransitionUsage specializes stateTransitions instead of %s", getSpecifics(transition)), transition.specializes((Type)libraryElement));
82+
}
83+
84+
@Test
85+
public void checkTransitionUsageStateSpecialization_StateDefinition() {
86+
checkTransitionUsageStateSpecialization("StateDefinition");
87+
}
88+
89+
@Test
90+
public void checkTransitionUsageStateSpecialization_StateUsage() {
91+
checkTransitionUsageStateSpecialization("StateUsage");
92+
}
93+
3694
@Test
3795
@Ignore("TBD")
3896
public void checkLifeClassOccurrenceSpecialization() {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ package TransitionUsage_invalid {
4646
then S1_2;
4747
state S1_2;
4848
}
49+
50+
item def A;
4951

5052
state def S2 {
53+
entry action init;
54+
// XPECT errors ---> "A transition with an accepter must have a state as its source." at "accept A"
55+
transition init accept A then S2_1;
56+
5157
state S2_1;
5258
transition
5359
first S2_1
Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
1-
/*
2-
* generated by Xtext 2.18.0.M3
3-
*/
1+
/*****************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2025 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+
* Contributors:
21+
* Ed Seidewitz, MDS
22+
*
23+
*****************************************************************************/
424
package org.omg.sysml.xtext.scoping
525

626
import org.omg.kerml.xtext.scoping.KerMLScopeProvider
27+
import org.eclipse.emf.ecore.EObject
28+
import org.eclipse.emf.ecore.EReference
29+
import org.omg.sysml.lang.sysml.Membership
30+
import org.omg.sysml.lang.sysml.TransitionUsage
31+
import org.omg.sysml.lang.sysml.FeatureMembership
32+
import org.omg.sysml.lang.sysml.ReferenceSubsetting
33+
import org.omg.sysml.lang.sysml.SuccessionAsUsage
34+
import org.omg.sysml.lang.sysml.FeatureChaining
735

836
/**
937
* This class contains custom scoping description.
@@ -12,4 +40,41 @@ import org.omg.kerml.xtext.scoping.KerMLScopeProvider
1240
* on how and when to use it.
1341
*/
1442
class SysMLScopeProvider extends KerMLScopeProvider {
43+
44+
def EObject featureRelationship(EObject context) {
45+
if (context instanceof FeatureChaining) {
46+
var featureChained = context.featureChained
47+
val ownedFeatureChainings = featureChained.ownedFeatureChaining
48+
val i = ownedFeatureChainings.indexOf(context)
49+
if ( i <= 0) {
50+
return featureChained.owningRelationship
51+
}
52+
}
53+
return context
54+
}
55+
56+
override getScope(EObject context, EReference reference) {
57+
var relationship = context.featureRelationship
58+
59+
// Scope a TransitionUsage source to the owningNamespace of the TransitionUsage
60+
if (relationship instanceof Membership) {
61+
val owningNamespace = relationship.membershipOwningNamespace;
62+
if (owningNamespace instanceof TransitionUsage &&
63+
relationship == owningNamespace.ownedMembership.filter[mem | !(mem instanceof FeatureMembership)].head) {
64+
return owningNamespace.scope_owningNamespace(context, reference)
65+
}
66+
67+
// Scope a TransitionUsage target to the owningNamespace of the TransitionUsage
68+
} else if (relationship instanceof ReferenceSubsetting) {
69+
val owningFeature = relationship.owningFeature
70+
val owningType = owningFeature.owningType
71+
if (owningType instanceof SuccessionAsUsage && owningType.ownedEndFeature.indexOf(owningFeature) == 1) {
72+
val outerNamespace = owningType.owningNamespace
73+
if (outerNamespace instanceof TransitionUsage && owningType === (outerNamespace as TransitionUsage).succession) {
74+
return outerNamespace.scope_owningNamespace(context, reference)
75+
}
76+
}
77+
}
78+
return super.getScope(context, reference)
79+
}
1580
}

org.omg.sysml.xtext/src/org/omg/sysml/xtext/validation/SysMLValidator.xtend

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ class SysMLValidator extends KerMLValidator {
334334
public static val INVALID_TRANSITION_USAGE_PARAMETERS_MSG_2 = "Must have two input parameters."
335335
public static val INVALID_TRANSITION_USAGE_SUCCESSION = "validateTransitionUsageSuccession"
336336
public static val INVALID_TRANSITION_USAGE_SUCCESSION_MSG = "A transition must own a succession to its target."
337+
public static val INVALID_TRANSITION_USAGE_TRIGGER_ACTIONS = "validateTransitionUsageTriggerActions"
338+
public static val INVALID_TRANSITION_USAGE_TRIGGER_ACTIONS_MSG = "A transition with an accepter must have a state as its source."
337339

338340
public static val INVALID_CALCULATION_USAGE_TYPE = "validateCalculationUsageType_"
339341
public static val INVALID_CALCULATION_USAGE_TYPE_MSG = "A calculation must be typed by one calculation definition."
@@ -954,6 +956,14 @@ class SysMLValidator extends KerMLValidator {
954956
if (!(mem.transitionFeature instanceof AcceptActionUsage)) {
955957
error(INVALID_TRANSITION_FEATURE_MEMBERSHIP_TRIGGER_ACTION_MSG, mem, null, INVALID_TRANSITION_FEATURE_MEMBERSHIP_TRIGGER_ACTION)
956958
}
959+
// // validateTransitionUsageTriggerActions
960+
// val owningType = mem.owningType
961+
// if (owningType instanceof TransitionUsage) {
962+
// val source = owningType.source
963+
// if (source !== null && !(source instanceof StateUsage) && !owningType.triggerAction.empty) {
964+
// error(INVALID_TRANSITION_USAGE_TRIGGER_ACTIONS_MSG, mem, null, INVALID_TRANSITION_USAGE_TRIGGER_ACTIONS)
965+
// }
966+
// }
957967
}
958968

959969
// validateTransitionFeatureMembershipOwningType
@@ -976,7 +986,8 @@ class SysMLValidator extends KerMLValidator {
976986

977987
// validateTransitionUsageParameters
978988
val n = usg.inputParameters.size
979-
if (usg.triggerAction.isEmpty) {
989+
val triggerAction = usg.triggerAction
990+
if (triggerAction.isEmpty) {
980991
if (n < 1) {
981992
error(INVALID_TRANSITION_USAGE_PARAMETERS_MSG_1, usg, null, INVALID_TRANSITION_USAGE_PARAMETERS)
982993
}
@@ -991,6 +1002,13 @@ class SysMLValidator extends KerMLValidator {
9911002
if (successions.empty || !(successions.get(0) as Succession).targetFeature.forall[f | FeatureUtil.getBasicFeatureOf(f) instanceof ActionUsage]) {
9921003
error(INVALID_TRANSITION_USAGE_SUCCESSION_MSG, usg, null, INVALID_TRANSITION_USAGE_SUCCESSION)
9931004
}
1005+
1006+
// validateTransitionUsageTriggerActions
1007+
val source = usg.source
1008+
val mem = usg.ownedMembership.filter(TransitionFeatureMembership).filter[kind == TransitionFeatureKind.TRIGGER].head
1009+
if (source !== null && !(source instanceof StateUsage) && mem !== null) {
1010+
error(INVALID_TRANSITION_USAGE_TRIGGER_ACTIONS_MSG, mem, null, INVALID_TRANSITION_USAGE_TRIGGER_ACTIONS)
1011+
}
9941012
}
9951013

9961014
@Check

org.omg.sysml/src/org/omg/sysml/adapter/PortUsageAdapter.java

Lines changed: 2 additions & 2 deletions
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, 2025 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 GNU Lesser General Public License as published by
@@ -51,7 +51,7 @@ protected String getDefaultSupertype() {
5151
public boolean isOwnedPort() {
5252
PortUsage target = getTarget();
5353
Type owningType = target.getOwningType();
54-
return target.isComposite() && (owningType instanceof PartDefinition || owningType instanceof PartUsage);
54+
return owningType instanceof PartDefinition || owningType instanceof PartUsage;
5555
}
5656

5757
public boolean isSubport() {

org.omg.sysml/src/org/omg/sysml/adapter/TransitionUsageAdapter.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021, 2023, 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2021, 2023-2025 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 GNU Lesser General Public License as published by
@@ -57,18 +57,23 @@ protected String getDefaultSupertype() {
5757
getDefaultSupertype("base");
5858
}
5959

60+
61+
// checkTransitionUsageActionSpecialization
6062
protected boolean isActionTransition() {
6163
TransitionUsage target = getTarget();
6264
Type owningType = target.getOwningType();
6365
return target.isComposite() &&
64-
(owningType instanceof ActionDefinition || owningType instanceof ActionUsage);
66+
(owningType instanceof ActionDefinition || owningType instanceof ActionUsage) &&
67+
!(target.getSource() instanceof StateUsage);
6568
}
6669

70+
// checkTransitionUsageStateSpecialization
6771
protected boolean isStateTransition() {
6872
TransitionUsage target = getTarget();
6973
Type owningType = target.getOwningType();
7074
return target.isComposite() &&
71-
(owningType instanceof StateDefinition || owningType instanceof StateUsage);
75+
(owningType instanceof StateDefinition || owningType instanceof StateUsage) &&
76+
target.getSource() instanceof StateUsage;
7277
}
7378

7479
// Transformation
@@ -88,10 +93,13 @@ protected Feature computeTransitionLinkConnectors() {
8893
TransitionUsage transition = getTarget();
8994
Feature transitionLinkFeature = UsageUtil.getTransitionLinkFeatureOf(transition);
9095
if (transitionLinkFeature == null) {
96+
// checkTransitionUsageSuccessionBindingConnector
9197
transitionLinkFeature = SysMLFactory.eINSTANCE.createReferenceUsage();
9298
TypeUtil.addOwnedFeatureTo(transition, transitionLinkFeature);
9399
Succession succession = transition.getSuccession();
94-
addBindingConnector(succession, transitionLinkFeature);
100+
addBindingConnector(succession, transitionLinkFeature);
101+
102+
// checkTransitionUsageSourceBindingConnector
95103
List<Feature> parameters = TypeUtil.getOwnedParametersOf(transition);
96104
if (!parameters.isEmpty()) {
97105
Feature source = transition.getSource();

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

Lines changed: 2 additions & 2 deletions
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-2025 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 GNU Lesser General Public License as published by
@@ -286,7 +286,7 @@ protected ImplicitGeneralizationMap() {
286286

287287
put(PortDefinitionImpl.class, "base", "Ports::Port");
288288
put(PortUsageImpl.class, "base", "Ports::ports");
289-
put(PortUsageImpl.class, "ownedPort", "Parts::Part::ownedPort");
289+
put(PortUsageImpl.class, "ownedPort", "Parts::Part::ownedPorts");
290290
put(PortUsageImpl.class, "subport", "Ports::Port::subports");
291291

292292
put(RenderingDefinitionImpl.class, "base", "Views::Rendering");

0 commit comments

Comments
 (0)