Skip to content

Commit aa410d3

Browse files
authored
Merge pull request #718 from Systems-Modeling/ST6RI-884
ST6RI-884 Model-level evaluation conformance
2 parents 9012208 + 8d28ffc commit aa410d3

63 files changed

Lines changed: 520 additions & 164 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.xtext/src/org/omg/kerml/xtext/validation/KerMLValidator.xtend

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,21 @@ import org.omg.sysml.lang.sysml.VisibilityKind
8888
import org.omg.sysml.lang.sysml.Structure
8989
import org.omg.sysml.lang.sysml.CrossSubsetting
9090
import org.omg.sysml.lang.sysml.Annotation
91+
import org.omg.sysml.lang.sysml.InstantiationExpression
92+
import org.omg.sysml.lang.sysml.ConstructorExpression
9193

9294
import org.omg.sysml.util.TypeUtil
9395
import org.omg.sysml.util.ElementUtil
96+
import org.omg.sysml.util.EvaluationUtil
9497
import org.omg.sysml.util.ExpressionUtil
9598
import org.omg.sysml.util.FeatureUtil
9699
import org.omg.sysml.util.NamespaceUtil
97100
import org.omg.sysml.util.ImplicitGeneralizationMap
98101

99-
import org.omg.sysml.expressions.util.EvaluationUtil
100102
import java.util.Collections
101103
import java.util.HashMap
102104
import java.util.Set
103105
import java.util.Map
104-
import org.omg.sysml.lang.sysml.InstantiationExpression
105-
import org.omg.sysml.lang.sysml.ConstructorExpression
106106

107107
/**
108108
* This class contains custom validation rules.

org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/ExpressionEvaluator.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2022-2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 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
@@ -23,7 +23,7 @@
2323

2424
import org.eclipse.emf.common.util.EList;
2525
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
26-
import org.omg.sysml.expressions.util.EvaluationUtil;
26+
import org.omg.sysml.expressions.functions.LibraryFunction;
2727
import org.omg.sysml.lang.sysml.Element;
2828
import org.omg.sysml.lang.sysml.Expression;
2929
import org.omg.sysml.lang.sysml.Feature;
@@ -35,31 +35,28 @@
3535
import org.omg.sysml.lang.sysml.SysMLFactory;
3636
import org.omg.sysml.lang.sysml.Type;
3737
import org.omg.sysml.util.ElementUtil;
38-
import org.omg.sysml.util.ExpressionUtil;
38+
import org.omg.sysml.util.EvaluationUtil;
3939
import org.omg.sysml.util.FeatureUtil;
4040
import org.omg.sysml.util.TypeUtil;
4141

4242
public class ExpressionEvaluator extends ModelLevelExpressionEvaluator {
4343

4444
public static final ExpressionEvaluator INSTANCE = new ExpressionEvaluator();
4545

46+
public ExpressionEvaluator() {
47+
super();
48+
setLibraryFunctionFactory(new LibraryFunctionFactory());
49+
}
50+
4651
@Override
4752
public EList<Element> evaluateInvocation(InvocationExpression expression, Element target) {
4853
Function function = expression.getFunction();
49-
if (function != null && function.isModelLevelEvaluable()) {
50-
return super.evaluateInvocation(expression, target);
54+
LibraryFunction libraryFunction = libraryFunctionFactory.getLibraryFunction(function);
55+
if (libraryFunction != null) {
56+
return libraryFunction.invoke(expression, target, this);
5157
} else {
5258
Type type = expression.instantiatedType();
53-
Expression resultExpression = null;
54-
if (type != null) {
55-
resultExpression = ExpressionUtil.getResultExpressionOf(type);
56-
if (resultExpression == null) {
57-
Feature resultParameter = TypeUtil.getResultParameterOf(type);
58-
if (resultParameter != null) {
59-
resultExpression = FeatureUtil.getValueExpressionFor(resultParameter);
60-
}
61-
}
62-
}
59+
Expression resultExpression = EvaluationUtil.getResultExpressionFor(type);
6360
if (resultExpression == null) {
6461
return EvaluationUtil.singletonList(expression);
6562
} else {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions;
23+
24+
import org.omg.sysml.execution.expressions.functions.*;
25+
26+
public class LibraryFunctionFactory extends org.omg.sysml.expressions.ModelLevelLibraryFunctionFactory {
27+
28+
public static final LibraryFunctionFactory INSTANCE = new LibraryFunctionFactory();
29+
30+
@Override
31+
protected void initializeFunctionMap() {
32+
super.initializeFunctionMap();
33+
34+
put(new SizeFunction());
35+
put(new IsEmptyFunction());
36+
put(new NotEmptyFunction());
37+
put(new IncludesFunction());
38+
put(new ExcludesFunction());
39+
40+
put(new SumFunction());
41+
put(new ProdFunction());
42+
43+
put(new StringLengthFunction());
44+
put(new StringSubstringFunction());
45+
}
46+
47+
}

org.omg.sysml/src/org/omg/sysml/expressions/functions/ExcludesFunction.java renamed to org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/functions/ExcludesFunction.java

Lines changed: 3 additions & 3 deletions
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) 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
@@ -18,13 +18,13 @@
1818
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
1919
*
2020
*******************************************************************************/
21-
package org.omg.sysml.expressions.functions;
21+
package org.omg.sysml.execution.expressions.functions;
2222

2323
import org.eclipse.emf.common.util.EList;
2424
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
25-
import org.omg.sysml.expressions.util.EvaluationUtil;
2625
import org.omg.sysml.lang.sysml.Element;
2726
import org.omg.sysml.lang.sysml.InvocationExpression;
27+
import org.omg.sysml.util.EvaluationUtil;
2828

2929
public class ExcludesFunction extends SequenceFunction {
3030

org.omg.sysml/src/org/omg/sysml/expressions/functions/IncludesFunction.java renamed to org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/functions/IncludesFunction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021 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
@@ -18,13 +18,13 @@
1818
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
1919
*
2020
*******************************************************************************/
21-
package org.omg.sysml.expressions.functions;
21+
package org.omg.sysml.execution.expressions.functions;
2222

2323
import org.eclipse.emf.common.util.EList;
2424
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
25-
import org.omg.sysml.expressions.util.EvaluationUtil;
2625
import org.omg.sysml.lang.sysml.Element;
2726
import org.omg.sysml.lang.sysml.InvocationExpression;
27+
import org.omg.sysml.util.EvaluationUtil;
2828

2929
public class IncludesFunction extends SequenceFunction {
3030

org.omg.sysml/src/org/omg/sysml/expressions/functions/IsEmptyFunction.java renamed to org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/functions/IsEmptyFunction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021 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
@@ -18,13 +18,13 @@
1818
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
1919
*
2020
*******************************************************************************/
21-
package org.omg.sysml.expressions.functions;
21+
package org.omg.sysml.execution.expressions.functions;
2222

2323
import org.eclipse.emf.common.util.EList;
2424
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
25-
import org.omg.sysml.expressions.util.EvaluationUtil;
2625
import org.omg.sysml.lang.sysml.Element;
2726
import org.omg.sysml.lang.sysml.InvocationExpression;
27+
import org.omg.sysml.util.EvaluationUtil;
2828

2929
public class IsEmptyFunction extends SequenceFunction {
3030

org.omg.sysml/src/org/omg/sysml/expressions/functions/NotEmptyFunction.java renamed to org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/functions/NotEmptyFunction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2021 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
@@ -18,13 +18,13 @@
1818
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
1919
*
2020
*******************************************************************************/
21-
package org.omg.sysml.expressions.functions;
21+
package org.omg.sysml.execution.expressions.functions;
2222

2323
import org.eclipse.emf.common.util.EList;
2424
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
25-
import org.omg.sysml.expressions.util.EvaluationUtil;
2625
import org.omg.sysml.lang.sysml.Element;
2726
import org.omg.sysml.lang.sysml.InvocationExpression;
27+
import org.omg.sysml.util.EvaluationUtil;
2828

2929
public class NotEmptyFunction extends SequenceFunction {
3030

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 theGNU 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.sysml.execution.expressions.functions;
23+
24+
import org.omg.sysml.expressions.functions.LibraryFunction;
25+
26+
public abstract class NumericalFunction implements LibraryFunction {
27+
28+
@Override
29+
public String getPackageName() {
30+
return "NumericalFunctions";
31+
}
32+
33+
}

org.omg.sysml/src/org/omg/sysml/expressions/functions/ProdFunction.java renamed to org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/functions/ProdFunction.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2022 Model Driven Solutions, Inc.
3+
* Copyright (c) 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
@@ -19,23 +19,18 @@
1919
*
2020
*******************************************************************************/
2121

22-
package org.omg.sysml.expressions.functions;
22+
package org.omg.sysml.execution.expressions.functions;
2323

2424
import org.eclipse.emf.common.util.EList;
2525
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
26-
import org.omg.sysml.expressions.util.EvaluationUtil;
2726
import org.omg.sysml.lang.sysml.Element;
2827
import org.omg.sysml.lang.sysml.InvocationExpression;
2928
import org.omg.sysml.lang.sysml.LiteralInteger;
3029
import org.omg.sysml.lang.sysml.LiteralRational;
30+
import org.omg.sysml.util.EvaluationUtil;
3131

32-
public class ProdFunction implements LibraryFunction {
32+
public class ProdFunction extends NumericalFunction {
3333

34-
@Override
35-
public String getPackageName() {
36-
return "NumericalFunctions";
37-
}
38-
3934
@Override
4035
public String getOperatorName() {
4136
return "product";

org.omg.sysml/src/org/omg/sysml/expressions/functions/SequenceFunction.java renamed to org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/functions/SequenceFunction.java

Lines changed: 4 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 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
@@ -19,7 +19,9 @@
1919
*
2020
*******************************************************************************/
2121

22-
package org.omg.sysml.expressions.functions;
22+
package org.omg.sysml.execution.expressions.functions;
23+
24+
import org.omg.sysml.expressions.functions.LibraryFunction;
2325

2426
public abstract class SequenceFunction implements LibraryFunction {
2527

0 commit comments

Comments
 (0)