Skip to content

Commit 05b77b2

Browse files
authored
Merge pull request #734 from Systems-Modeling/ST6RI-897
ST6RI-897 Remove as much non-generated code as possible from EMF Impl classes
2 parents 05b4193 + dd984ec commit 05b77b2

407 files changed

Lines changed: 41502 additions & 39345 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.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//*
2+
XPECT_SETUP org.omg.kerml.xpect.tests.validation.KerMLValidationTest
3+
ResourceSet {
4+
ThisFile {}
5+
File {from ="/library/Base.kerml"}
6+
}
7+
Workspace {
8+
JavaProject {
9+
SrcFolder {
10+
ThisFile {}
11+
File {from ="/library/Base.kerml"}
12+
}
13+
}
14+
}
15+
END_SETUP
16+
*/
17+
package Feature_nonunique_invalid {
18+
classifier A {
19+
feature x; // "unique" by default
20+
}
21+
classifier B specializes A {
22+
// XPECT errors --> "Subsetting/redefining feature cannot be nonunique if subsetted/redefined feature is unique" at "x"
23+
feature x1 nonunique subsets x;
24+
}
25+
classifier C specializes A {
26+
// XPECT errors --> "Subsetting/redefining feature cannot be nonunique if subsetted/redefined feature is unique" at "x"
27+
feature x2 nonunique redefines x;
28+
}
29+
}

org.omg.kerml.xtext/src/org/omg/kerml/xtext/scoping/KerMLLinker.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2020-2021, 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2020-2021, 2024, 2026 Model Driven Solutions, Inc.
44
* Copyright (c) 2024 Budapest University of Technology and Economics
55
*
66
* This program is free software: you can redistribute it and/or modify
@@ -47,14 +47,6 @@ public class KerMLLinker extends LazyLinker {
4747
@Inject
4848
private OnChangeEvictingCache cache;
4949

50-
@Override
51-
protected void clearReferences(EObject obj) {
52-
super.clearReferences(obj);
53-
if (obj instanceof Element) {
54-
ElementUtil.clean((Element)obj);
55-
}
56-
}
57-
5850
@Override
5951
protected void clearReference(EObject obj, EReference ref) {
6052
if (
@@ -72,10 +64,10 @@ protected void clearReference(EObject obj, EReference ref) {
7264
@Override
7365
protected void doLinkModel(EObject model, IDiagnosticConsumer consumer) {
7466
super.doLinkModel(model, consumer);
75-
postProcessAllCrossReferences(model);
67+
postProcessAll(model);
7668
}
7769

78-
protected void postProcessAllCrossReferences(EObject model) {
70+
protected void postProcessAll(EObject model) {
7971
cache.execWithoutCacheClear(model.eResource(), new IUnitOfWork.Void<Resource>() {
8072
@Override
8173
public void process(Resource state) throws Exception {

org.omg.kerml.xtext/src/org/omg/kerml/xtext/validation/KerMLValidator.xtend

Lines changed: 67 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
33
* Copyright (c) 2018 IncQuery Labs Ltd.
4-
* Copyright (c) 2018-2025 Model Driven Solutions, Inc.
4+
* Copyright (c) 2018-2026 Model Driven Solutions, Inc.
55
* Copyright (c) 2020 California Institute of Technology/Jet Propulsion Laboratory
66
*
77
* This program is free software: you can redistribute it and/or modify
@@ -103,6 +103,10 @@ import java.util.Collections
103103
import java.util.HashMap
104104
import java.util.Set
105105
import java.util.Map
106+
import org.omg.sysml.lang.sysml.EndFeatureMembership
107+
import org.omg.sysml.lang.sysml.CollectExpression
108+
import org.omg.sysml.lang.sysml.SelectExpression
109+
import org.omg.sysml.lang.sysml.IndexExpression
106110

107111
/**
108112
* This class contains custom validation rules.
@@ -160,6 +164,9 @@ class KerMLValidator extends AbstractKerMLValidator {
160164

161165
public static val INVALID_CLASSIFIER_MULTIPLICITY_DOMAIN = "validateClassifierMultiplicityDomain"
162166
public static val INVALID_CLASSIFIER_MULTIPLICITY_DOMAIN_MSG = "Multiplicity must not have a featuring type"
167+
168+
public static val INVALID_END_FEATURE_MEMBERSHIP_IS_END = "validateEndFeatureMembershpIsEnd"
169+
public static val INVALID_END_FEATURE_MEMBERSHIP_IS_END_MSG = "Must be an end feature"
163170

164171
// Note: validateFeatureHasType is not in the spec, but it is implied by semantic constraints on features.
165172
public static val INVALID_FEATURE_HAS_TYPE = 'validateFeatureHasType_'
@@ -264,6 +271,8 @@ class KerMLValidator extends AbstractKerMLValidator {
264271
public static val INVALID_BEHAVIOR_SPECIALIZATION = "validateBehaviorSpecialization"
265272
public static val INVALID_BEHAVIOR_SPECIALIZATION_MSG = "Cannot specialize structure"
266273

274+
public static val INVALID_PARAMETER_MEMBERSHIP_DIRECTION = "validateParameterMembershipDirection"
275+
public static val INVALID_PARAMETER_MEMBERSHIP_DIRECTION_MSG = "Must have direction '{direction}'"
267276
public static val INVALID_PARAMETER_MEMBERSHIP_OWNING_TYPE = "validateParameterMembershipOwningType"
268277
public static val INVALID_PARAMETER_MEMBERSHIP_OWNING_TYPE_MSG = "Parameter membership not allowed"
269278

@@ -319,9 +328,23 @@ class KerMLValidator extends AbstractKerMLValidator {
319328
public static val INVALID_OPERATOR_EXPRESSION_BRACKET_OPERATOR = "validateOperatorExpressionBracketOperator_"
320329
public static val INVALID_OPERATOR_EXPRESSION_BRACKET_OPERATOR_MSG = "Use #(...) for indexing"
321330

331+
public static val INVALID_COLLECT_EXPRESSION_OPERATOR = "validateCollectExpressionOperator"
332+
public static val INVALID_COLLECT_EXPRESSION_OPERATOR_MSG = "Operator must be 'collect'"
333+
334+
public static val INVALID_FEATURE_CHAIN_EXPRESSION_OPERATOR = "validateFeatureChainExpressionOperator"
335+
public static val INVALID_FEATURE_CHAIN_EXPRESSION_OPERATOR_MSG = "Operator must be '.'"
336+
337+
public static val INVALID_INDEX_EXPRESSION_OPERATOR = "validateIndexExpressionOperator"
338+
public static val INVALID_INDEX_EXPRESSION_OPERATOR_MSG = "Operator must be '#'"
339+
340+
public static val INVALID_SELECT_EXPRESSION_OPERATOR = "validateSelectExpressionOperator"
341+
public static val INVALID_SELECT_EXPRESSION_OPERATOR_MSG = "Operator must be 'select'"
342+
322343
public static val INVALID_FLOW_ITEM_FEATURE = "validateFlowItemFeature"
323344
public static val INVALID_FLOW_ITEM_FEATURE_MSG = "Only one item feature is allowed"
324345

346+
public static val INVALID_FLOW_END_IS_END = "validateFlowEndIsEnd"
347+
public static val INVALID_FLOW_END_IS_END_MSG = "Must be an end feature"
325348
public static val INVALID_FLOW_END_OWNING_TYPE = "validateFlowEndOwningType"
326349
public static val INVALID_FLOW_END_OWNING_TYPE_MSG = "Flow end not allowed"
327350
public static val INVALID_FLOW_END_NESTED_FEATURE = "validateFlowEndNestedFeature"
@@ -555,10 +578,14 @@ class KerMLValidator extends AbstractKerMLValidator {
555578
}
556579
}
557580

558-
// @Check
559-
// def checkEndFeatureMembership(EndFeatureMembership m) {
560-
// // validateEndFeatureMembershipIsEnd is automatically satisfied
561-
// }
581+
@Check
582+
def checkEndFeatureMembership(EndFeatureMembership m) {
583+
// validateEndFeatureMembershipIsEnd
584+
var ownedMemberFeature = m.ownedMemberFeature
585+
if (ownedMemberFeature !== null && !ownedMemberFeature.isEnd) {
586+
error(INVALID_END_FEATURE_MEMBERSHIP_IS_END_MSG, ownedMemberFeature, null, INVALID_END_FEATURE_MEMBERSHIP_IS_END)
587+
}
588+
}
562589

563590
@Check
564591
def checkFeature(Feature f){
@@ -1026,9 +1053,12 @@ class KerMLValidator extends AbstractKerMLValidator {
10261053
ExpressionUtil.isConstructorResult(owningType))) {
10271054
error(INVALID_PARAMETER_MEMBERSHIP_OWNING_TYPE_MSG, m, SysMLPackage.eINSTANCE.parameterMembership_OwnedMemberParameter, INVALID_PARAMETER_MEMBERSHIP_OWNING_TYPE)
10281055
}
1029-
1030-
// validateParameterMembershipParameterHasDirection is automatically satisfied
10311056
}
1057+
// validateParameterMembershipParameterDirection
1058+
var ownedMemberParameter = m.ownedMemberParameter
1059+
if (ownedMemberParameter !== null && ownedMemberParameter.direction != m.parameterDirection) {
1060+
error(INVALID_PARAMETER_MEMBERSHIP_DIRECTION_MSG.replace("{direction}", m.parameterDirection.toString.toLowerCase), ownedMemberParameter, null, INVALID_PARAMETER_MEMBERSHIP_DIRECTION)
1061+
}
10321062
}
10331063

10341064
@Check
@@ -1074,8 +1104,6 @@ class KerMLValidator extends AbstractKerMLValidator {
10741104
if (!(owningType instanceof Function || owningType instanceof Expression)) {
10751105
error(INVALID_RETURN_PARAMETER_MEMBERSHIP_OWNING_TYPE_MSG, m, SysMLPackage.eINSTANCE.parameterMembership_OwnedMemberParameter, INVALID_RETURN_PARAMETER_MEMBERSHIP_OWNING_TYPE)
10761106
}
1077-
1078-
// validateReturnParameterMembershipParameterHasDirectionOut is automatically satisfied
10791107
}
10801108

10811109
@Check
@@ -1085,19 +1113,15 @@ class KerMLValidator extends AbstractKerMLValidator {
10851113
if (!(owningType instanceof Function || owningType instanceof Expression)) {
10861114
error(INVALID_RESULT_EXPRESSION_MEMBERSHIP_OWNING_TYPE_MSG, m, SysMLPackage.eINSTANCE.parameterMembership_OwnedMemberParameter, INVALID_RESULT_EXPRESSION_MEMBERSHIP_OWNING_TYPE)
10871115
}
1088-
1089-
// validateReturnParameterMembershipParameterHasDirectionOut is automatically satisfied
10901116
}
10911117

1092-
// @Check
1093-
// def checkReturnParameterMembership(ReturnParameterMembership m) {
1094-
// // validateReturnParameterMembershipParameterHasDirection is automatically satisfied
1095-
// }
1096-
1097-
// @Check
1098-
// def checkCollectExpression(CollectExpression e) {
1099-
// // validateCollectExpressionOperator is automatically satisfied
1100-
// }
1118+
@Check
1119+
def checkCollectExpression(CollectExpression e) {
1120+
// validateCollectExpressionOperator
1121+
if (e.operator != "collect") {
1122+
error(INVALID_COLLECT_EXPRESSION_OPERATOR_MSG, e, null, INVALID_COLLECT_EXPRESSION_OPERATOR);
1123+
}
1124+
}
11011125

11021126
@Check
11031127
def checkFeatureChainExpression(FeatureChainExpression e) {
@@ -1112,7 +1136,10 @@ class KerMLValidator extends AbstractKerMLValidator {
11121136
error(INVALID_FEATURE_CHAIN_EXPRESSION_FEATURE_CONFORMANCE_MSG, e.ownedMembership.get(1), SysMLPackage.eINSTANCE.membership_MemberElement, INVALID_FEATURE_CHAIN_EXPRESSION_FEATURE_CONFORMANCE)
11131137
}
11141138

1115-
// validateFeatureChainExpressionOperator is automatically satisfied
1139+
// validateFeatureChainExpressionOperator
1140+
if (e.operator != ".") {
1141+
error(INVALID_FEATURE_CHAIN_EXPRESSION_OPERATOR_MSG, e, null, INVALID_FEATURE_CHAIN_EXPRESSION_OPERATOR);
1142+
}
11161143
}
11171144

11181145
@Check
@@ -1235,15 +1262,21 @@ class KerMLValidator extends AbstractKerMLValidator {
12351262
}
12361263
}
12371264

1238-
// @Check
1239-
// def checkSelectExpression(SelectExpression e) {
1240-
// // validateSelectExpressionOperator is automatically satisfied
1241-
// }
1242-
1243-
// @Check
1244-
// def checkIndexExpression(IndexExpression e) {
1245-
// // validateIndexExpressionOperator is automatically satisfied
1246-
// }
1265+
@Check
1266+
def checkSelectExpression(SelectExpression e) {
1267+
// validateSelectExpressionOperator
1268+
if (e.operator != "select") {
1269+
error(INVALID_SELECT_EXPRESSION_OPERATOR_MSG, e, null, INVALID_SELECT_EXPRESSION_OPERATOR);
1270+
}
1271+
}
1272+
1273+
@Check
1274+
def checkIndexExpression(IndexExpression e) {
1275+
// validateIndexExpressionOperator
1276+
if (e.operator != "#") {
1277+
error(INVALID_INDEX_EXPRESSION_OPERATOR_MSG, e, null, INVALID_INDEX_EXPRESSION_OPERATOR);
1278+
}
1279+
}
12471280

12481281
@Check
12491282
def checkFlow(Flow flow) {
@@ -1254,7 +1287,10 @@ class KerMLValidator extends AbstractKerMLValidator {
12541287

12551288
@Check
12561289
def checkFlowEnd(FlowEnd flowEnd) {
1257-
// validateFlowEndIsEnd is automatically satisfied
1290+
// validateFlowEndIsEnd
1291+
if (!flowEnd.isEnd) {
1292+
error(INVALID_FLOW_END_IS_END_MSG, flowEnd, null, INVALID_FLOW_END_IS_END)
1293+
}
12581294

12591295
// validateFlowEndNestedFeature
12601296
if (flowEnd.ownedFeature.size != 1) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected Expression checkFilterExpression(SysMLInteractive instance, String tex
5757
assertFalse("'" + text + "': No filter conditions", filterConditions.isEmpty());
5858
Expression filterCondition = filterConditions.get(0);
5959
assertTrue("'" + text + "': Not operator expression", filterCondition instanceof OperatorExpression);
60-
List<Expression> operands = ((OperatorExpression)filterCondition).getOperand();
60+
List<Expression> operands = ((OperatorExpression)filterCondition).getArgument();
6161
assertFalse("'" + text + "': No operands", operands.isEmpty());
6262
return operands.get(0);
6363
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* SysML 2 Pilot Implementation
3-
* Copyright (C) 2024,2025 Model Driven Solutions, Inc.
3+
* Copyright (C) 2024-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 GNU Lesser General Public License as published by
@@ -132,7 +132,8 @@ public void checkSuccessionFlowUsageSpecialization() {
132132

133133
public static void addEndTo(Type type) {
134134
var end = SysMLFactory.eINSTANCE.createFeature();
135-
var endMembership = SysMLFactory.eINSTANCE.createEndFeatureMembership();
135+
end.setIsEnd(true);
136+
var endMembership = SysMLFactory.eINSTANCE.createFeatureMembership();
136137
endMembership.setOwnedMemberFeature(end);
137138
type.getOwnedRelationship().add(endMembership);
138139
}

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* SysML 2 Pilot Implementation
3-
* Copyright (C) 2024, 2025 Model Driven Solutions, Inc.
3+
* Copyright (C) 2024-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 GNU Lesser General Public License as published by
@@ -27,7 +27,6 @@
2727
import org.junit.Ignore;
2828
import org.junit.Test;
2929
import org.omg.sysml.lang.sysml.FeatureDirectionKind;
30-
import org.omg.sysml.lang.sysml.ParameterMembership;
3130
import org.omg.sysml.lang.sysml.StateSubactionKind;
3231
import org.omg.sysml.lang.sysml.SysMLFactory;
3332
import org.omg.sysml.util.ElementUtil;
@@ -104,10 +103,7 @@ public void checkAssignmentActionUsageAccessedFeatureRedefinition() {
104103

105104
var targetParam = SysMLFactory.eINSTANCE.createFeature();
106105
targetParam.setDirection(FeatureDirectionKind.IN);
107-
108-
ParameterMembership parameterMembership = SysMLFactory.eINSTANCE.createParameterMembership();
109-
assignment.getOwnedRelationship().add(parameterMembership);
110-
parameterMembership.setOwnedMemberParameter(targetParam);
106+
TypeUtil.addOwnedFeatureTo(assignment, targetParam);
111107

112108
var firstOfTarget = SysMLFactory.eINSTANCE.createFeature();
113109
TypeUtil.addOwnedFeatureTo(targetParam, firstOfTarget);
@@ -136,10 +132,7 @@ public void checkAssignmentActionUsageReferentRedefinition() {
136132

137133
var targetParam = SysMLFactory.eINSTANCE.createFeature();
138134
targetParam.setDirection(FeatureDirectionKind.IN);
139-
140-
ParameterMembership parameterMembership = SysMLFactory.eINSTANCE.createParameterMembership();
141-
assignment.getOwnedRelationship().add(parameterMembership);
142-
parameterMembership.setOwnedMemberParameter(targetParam);
135+
TypeUtil.addOwnedFeatureTo(assignment, targetParam);
143136

144137
var firstOfTarget = SysMLFactory.eINSTANCE.createFeature();
145138
TypeUtil.addOwnedFeatureTo(targetParam, firstOfTarget);
@@ -163,10 +156,7 @@ public void checkAssignmentActionUsageStartingAtRedefinition() {
163156

164157
var targetParam = SysMLFactory.eINSTANCE.createFeature();
165158
targetParam.setDirection(FeatureDirectionKind.IN);
166-
167-
ParameterMembership parameterMembership = SysMLFactory.eINSTANCE.createParameterMembership();
168-
assignment.getOwnedRelationship().add(parameterMembership);
169-
parameterMembership.setOwnedMemberParameter(targetParam);
159+
TypeUtil.addOwnedFeatureTo(assignment, targetParam);
170160

171161
var firstOfTarget = SysMLFactory.eINSTANCE.createFeature();
172162
TypeUtil.addOwnedFeatureTo(targetParam, firstOfTarget);

org.omg.sysml.plantuml/src/org/omg/sysml/plantuml/VPath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private class PCFeatureChainExpression extends PC {
170170
private final FeatureChainExpression fce;
171171

172172
private Expression getTargetExp() {
173-
List<Expression> ops = fce.getOperand();
173+
List<Expression> ops = fce.getArgument();
174174
if (ops.isEmpty()) {
175175
return null;
176176
} else {

org.omg.sysml.plantuml/src/org/omg/sysml/plantuml/VSequence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private static boolean isTarget(Feature f) {
110110
}
111111

112112
private Element next(FeatureChainExpression fce, boolean first) {
113-
List<Expression> ops = fce.getOperand();
113+
List<Expression> ops = fce.getArgument();
114114
int size = ops.size();
115115
if (size == 0) return null;
116116
Expression ex = ops.get(0);

0 commit comments

Comments
 (0)