Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.omg.sysml.lang.sysml.FeatureMembership;
import org.omg.sysml.lang.sysml.ItemUsage;
import org.omg.sysml.lang.sysml.Membership;
import org.omg.sysml.lang.sysml.MetadataUsage;
import org.omg.sysml.lang.sysml.Namespace;
import org.omg.sysml.lang.sysml.Relationship;
import org.omg.sysml.lang.sysml.TriggerInvocationExpression;
Expand Down Expand Up @@ -488,4 +489,42 @@ public void testNamespaceResolve() throws Exception {
assertSame("Test.resolve(Test::C::g)", g.getOwningMembership(), Test.resolve("Test::C::g"));
}

public final String ownedMetadataTest =
"package Test {\n"
+ " part def P {\n"
+ " @M1; @M2;\n"
+ " part p : P {\n"
+ " @M1; @M2;\n"
+ " }\n"
+ " }\n"
+ " metadata def M1;\n"
+ " metadata def M2;\n"
+ "}";

@Test
public void testOwnedMetadataAndNestedMetadata() throws Exception {
SysMLInteractive instance = createSysMLInteractiveInstance();
SysMLInteractiveResult result = instance.process(ownedMetadataTest);
Element root = result.getRootElement();
List<Element> elements = ((Namespace)root).getOwnedMember();
Namespace Test = (Namespace)elements.get(0);
List<Element> ownedMembers = Test.getOwnedMember();
Definition P = (Definition)ownedMembers.get(0);
List<Element> P_ownedMembers = P.getOwnedMember();
Usage P_M1 = (Usage)P_ownedMembers.get(0);
Usage P_M2 = (Usage)P_ownedMembers.get(1);
Usage p = (Usage)P_ownedMembers.get(2);
List<Element> p_ownedMembers = p.getOwnedMember();
Usage p_M1 = (Usage)p_ownedMembers.get(0);
Usage p_M2 = (Usage)p_ownedMembers.get(1);

List<MetadataUsage> ownedMetadata = P.getOwnedMetadata();
assertTrue("P_M1", ownedMetadata.contains(P_M1));
assertTrue("P_M2", ownedMetadata.contains(P_M2));

List<MetadataUsage> nestedMetadata = p.getNestedMetadata();
assertTrue("p_M1", nestedMetadata.contains(p_M1));
assertTrue("p_M2", nestedMetadata.contains(p_M2));
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021-2022 Model Driven Solutions, Inc.
* Copyright (c) 2021-2022, 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ protected String getDefaultSupertype() {
}

protected boolean isCheckedConstraint() {
/*
* TODO: Update checkConstraintUsageCheckedConstraintSpecialization
*
* OCL doesn't require composite
*
*/
ConstraintUsage target = getTarget();
Type owningType = target.getOwningType();
return target.isComposite() &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021, 2022, 2025 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2022, 2025, 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
Expand Down Expand Up @@ -38,11 +38,6 @@ public IncludeUseCaseUsage getTarget() {
return (IncludeUseCaseUsage)super.getTarget();
}

/**
* TODO: Rename checkIncludeUseCaseSpecialization
* See SYSML21-299
*/

/**
* @satisfies checkIncludeUseCaseUsageSpecialization
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2022 Siemens AG
* Copyright (c) 2023 Model Driven Solutions, Inc.
* Copyright (c) 2023, 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
Expand All @@ -28,6 +28,7 @@
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.FeatureMembership;
import org.omg.sysml.lang.sysml.Membership;
import org.omg.sysml.lang.sysml.MetadataFeature;

public class AssignmentActionUsage_referent_SettingDelegate extends BasicDerivedObjectSettingDelegate {

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
* the Eclipse Foundation, version 2 of the License.
*
* 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
* Eclipse Public License for more details.
*
* You should have received a copy of the Eclipse Public License
* along with this program. If not, see <https://www.eclipse.org/legal/epl-2.0/>.
*
* @license EPL-2.0 <http://spdx.org/licenses/EPL-2.0>
*
*******************************************************************************/

package org.omg.sysml.delegate.setting;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.lang.sysml.Definition;
import org.omg.sysml.lang.sysml.MetadataUsage;
import org.omg.sysml.util.NonNotifyingEObjectEList;

public class Definition_ownedMetadata_SettingDelegate extends BasicDerivedListSettingDelegate {

public Definition_ownedMetadata_SettingDelegate(EStructuralFeature eStructuralFeature) {
super(eStructuralFeature);
}

@Override
protected EList<MetadataUsage> basicGet(InternalEObject owner) {
EList<MetadataUsage> ownedMetadata = new NonNotifyingEObjectEList<>(MetadataUsage.class, owner, eStructuralFeature.getFeatureID());
((Definition)owner).getMember().stream().
filter(MetadataUsage.class::isInstance).
map(MetadataUsage.class::cast).
forEachOrdered(ownedMetadata::add);
return ownedMetadata;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
* the Eclipse Foundation, version 2 of the License.
*
* 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
* Eclipse Public License for more details.
*
* You should have received a copy of the Eclipse Public License
* along with this program. If not, see <https://www.eclipse.org/legal/epl-2.0/>.
*
* @license EPL-2.0 <http://spdx.org/licenses/EPL-2.0>
*
*******************************************************************************/

package org.omg.sysml.delegate.setting;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.lang.sysml.MetadataUsage;
import org.omg.sysml.lang.sysml.Usage;
import org.omg.sysml.util.NonNotifyingEObjectEList;

public class Usage_nestedMetadata_SettingDelegate extends BasicDerivedListSettingDelegate {

public Usage_nestedMetadata_SettingDelegate(EStructuralFeature eStructuralFeature) {
super(eStructuralFeature);
}

@Override
protected EList<MetadataUsage> basicGet(InternalEObject owner) {
EList<MetadataUsage> nestedMetadata = new NonNotifyingEObjectEList<>(MetadataUsage.class, owner, eStructuralFeature.getFeatureID());
((Usage)owner).getMember().stream().
filter(MetadataUsage.class::isInstance).
map(MetadataUsage.class::cast).
forEachOrdered(nestedMetadata::add);
return nestedMetadata;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,6 @@ protected ImplicitGeneralizationMap() {
//checkViewpointUsageViewpointSatisfactionSpecialization
put(ViewpointUsageImpl.class, "satisfied", "Views::View::viewpointSatisfactions");

/*
* TODO: Update checkViewpointDefinitionSpecialization and checkViewpointUsageSpecialization
*
* See SYSML21-301
*/

//checkWhileLoopActionUsageSpecialization
put(WhileLoopActionUsageImpl.class, "base", "Actions::whileLoopActions");
//checkWhileLoopActionUsageSubactionSpecialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ public static RequirementUsage getOwnedObjectiveRequirementOf(Type type) {
}

public static RequirementUsage getObjectiveRequirementOf(Type type) {
// TODO: Update checkRequirementUsageObjectiveRedefinition
// See SYSML21-309
if (type instanceof Feature) {
type = ((Feature)type).getFeatureTarget();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ package AssignmentActionUsage_invalid {
attribute a;
protected attribute b;
private attribute c;
action d;
}
action def A {
assign i.a := null;
// XPECT errors --> "Couldn't resolve reference to Element 'b'." at "b"
assign i.b := null;
// XPECT errors --> "Couldn't resolve reference to Element 'c'." at "c"
assign i.c := null;
// XPECT errors --> "Referent must be time varying." at "d"
assign i.d := null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ import org.omg.sysml.lang.sysml.WhileLoopActionUsage
import org.omg.sysml.util.SysMLLibraryUtil
import org.omg.sysml.util.FeatureUtil
import org.omg.sysml.util.UsageUtil
import org.omg.sysml.lang.sysml.MetadataFeature

/**
* This class contains custom validation rules.
Expand Down Expand Up @@ -262,6 +263,8 @@ class SysMLValidator extends KerMLValidator {
public static val INVALID_ASSIGNMENT_ACTION_USAGE_ARGUMENTS_MSG = "An assignment must have two arguments."
public static val INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT = "validateAssignmentActionUsageReferent"
public static val INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_MSG = "An assignment must have a referent."
public static val INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_IS_TIME_VARYING = "validateAssignmentActionUsageReferentIsTimeVarying"
public static val INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_IS_TIME_VARYING_MSG = "Referent must be time varying."

public static val INVALID_TRIGGER_INVOCATION_EXPRESSION_AFTER_ARGUMENT = "validateTriggerInvocationActionAfterArgument"
public static val INVALID_TRIGGER_INVOCATION_EXPRESSION_AFTER_ARGUMENT_MSG = "An after expression must be a DurationValue."
Expand Down Expand Up @@ -778,10 +781,16 @@ class SysMLValidator extends KerMLValidator {
@Check
def checkAssignmentActionUsage(AssignmentActionUsage usg) {
// validateAssignmentActionUsageReferent
if (!usg.ownedMembership.exists[m | !(m instanceof FeatureMembership) && m.memberElement instanceof Feature]) {
error(INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_MSG, usg, null, INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT)
if (!usg.ownedMembership.exists[m |
!(m instanceof FeatureMembership) && m.memberElement instanceof Feature && !(m.memberElement instanceof MetadataFeature)]) {
error(INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_MSG, usg.ownedRelationship.get(1), null, INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT)
}

// validateAssignmentActionUsageReferentIsTimeVarying
val referent = usg.referent
if (referent !== null && !referent.eIsProxy && !referent.featureTarget.isVariable) {
error(INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_IS_TIME_VARYING_MSG, usg.ownedRelationship.get(1), null, INVALID_ASSIGNMENT_ACTION_USAGE_REFERENT_IS_TIME_VARYING)
}
}

@Check
Expand Down Expand Up @@ -899,7 +908,7 @@ class SysMLValidator extends KerMLValidator {
warning(INVALID_SEND_ACTION_USAGE_RECEIVER_MSG, receiverArgument, null, INVALID_SEND_ACTION_USAGE_RECEIVER)
}

// validateSendActionPayloadArgument
// validateSendActionUsagePayloadArgument
val featureMembership = usg.featureMembership
if ((featureMembership instanceof StateSubactionMembership ||
featureMembership instanceof TransitionFeatureMembership) &&
Expand Down
Loading