Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ class KerMLValidator extends AbstractKerMLValidator {
val result = TypeUtil.getOwnedResultParameterOf(e)
if (type !== null && result !== null) {
val typeFeatures = type.feature.filter[f | f.owningMembership.visibility == VisibilityKind.PUBLIC]
val resultFeatures = result.ownedFeature.filter[p | FeatureUtil.isInputParameter(p)]
val resultFeatures = result.ownedFeature.filter[p | FeatureUtil.isInputDirected(p)]
e.checkInstantiationExpressionFeatures(typeFeatures, resultFeatures,
INVALID_CONSTRUCTOR_EXPRESSION_RESULT_FEATURE_REDEFINITION_MSG, INVALID_CONSTRUCTOR_EXPRESSION_RESULT_FEATURE_REDEFINITION,
INVALID_CONSTRUCTOR_EXPRESSION_NO_DUPLICATE_FEATURE_REDEFINITION_MSG, INVALID_CONSTRUCTOR_EXPRESSION_NO_DUPLICATE_FEATURE_REDEFINITION
Expand Down Expand Up @@ -1191,8 +1191,8 @@ class KerMLValidator extends AbstractKerMLValidator {

// validateInvocationExpressionParameterRedefinition
// validateInvocationExpressionNoDuplicateParameterRedefinition
val typeParams = type.feature.filter[p | FeatureUtil.isInputParameter(p)]
val exprParams = e.ownedFeature.filter[p | FeatureUtil.isInputParameter(p)]
val typeParams = type.input
val exprParams = e.ownedFeature.filter[p | FeatureUtil.isInputDirected(p)]
e.checkInstantiationExpressionFeatures(typeParams, exprParams,
INVALID_INVOCATION_EXPRESSION_PARAMETER_REDEFINITION_MSG, INVALID_INVOCATION_EXPRESSION_PARAMETER_REDEFINITION,
INVALID_INVOCATION_EXPRESSION_NO_DUPLICATE_PARAMETER_REDEFINITION_MSG, INVALID_INVOCATION_EXPRESSION_NO_DUPLICATE_PARAMETER_REDEFINITION
Expand Down
2 changes: 1 addition & 1 deletion org.omg.sysml.xpect.tests/library.systems/States.sysml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ standard library package States {
in transitionLinkSource[1]: StateAction :>>
TransitionAction::transitionLinkSource, StateTransitionPerformance::transitionLinkSource;

out payload[0..*];
inout payload[0..*];
in :>> receiver;

bind payload = accepter.payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ package ActionTest {
}
flow aa.target to snd1.receiver;
action snd1 send {
:>> payload = s;
in :>> payload = s;
}
action snd2 send via this to aa.target;
bind s = snd2.payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ package UseCaseTest {
part user : User;

use case uc2 {
subject;
actor :>> user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ package ViewTest {
part def S;

concern def C {
subject;
stakeholder s : S;
}

concern c : C {
subject;
stakeholder s1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ package 'Case Subjects and Objectives' {
// XPECT errors --> "Only one subject is allowed." at "subject s4;"
subject s4;

// XPECT errors --> "Only one objective is allowed." at "objective o3;"
objective o3;

// XPECT errors --> "Only one objective is allowed." at "objective o4;"
Expand All @@ -72,10 +73,18 @@ package 'Case Subjects and Objectives' {
// XPECT errors --> "Subject must be first parameter." at "subject s5;"
subject s5;

// XPECT errors --> "Only one objective is allowed." at "objective o5;"
objective o5;
}

case c1 : C1 {
//* XPECT errors ---
"Only one objective is allowed." at "case c1 : C1;"
"Subject must be first parameter." at "case c1 : C1;"
---
*/
case c1 : C1;

case c2 {
in y;

// XPECT errors --> "Subject must be first parameter." at "subject s6;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ package SemanticMetadata_valid {

requirement r1;
#g requirement r2 {
subject;
actor #B a;
assume #g constraint b;
require #g r1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import org.omg.sysml.lang.sysml.ConnectionUsage
import org.omg.sysml.lang.sysml.ConstraintUsage
import org.omg.sysml.lang.sysml.DataType
import org.omg.sysml.lang.sysml.Definition
import org.omg.sysml.lang.sysml.Element
import org.omg.sysml.lang.sysml.EnumerationDefinition
import org.omg.sysml.lang.sysml.EnumerationUsage
import org.omg.sysml.lang.sysml.Feature
Expand Down Expand Up @@ -135,6 +134,7 @@ import org.omg.sysml.lang.sysml.TriggerKind
import org.omg.sysml.util.TypeUtil
import org.omg.sysml.lang.sysml.FlowDefinition
import org.omg.sysml.lang.sysml.FlowUsage
import org.omg.sysml.lang.sysml.Relationship

/**
* This class contains custom validation rules.
Expand Down Expand Up @@ -932,9 +932,9 @@ class SysMLValidator extends KerMLValidator {

protected def checkStateSubactions(Type type) {
val errorId = type instanceof Definition? INVALID_STATE_DEFINITION_SUBACTION_KIND: INVALID_STATE_USAGE_SUBACTION_KIND
checkAtMostOneElement(UsageUtil.getStateSubactionMembershipsOf(type, StateSubactionKind.ENTRY), INVALID_STATE_SUBACTION_KIND_ENTRY_MSG, errorId);
checkAtMostOneElement(UsageUtil.getStateSubactionMembershipsOf(type, StateSubactionKind.DO), INVALID_STATE_SUBACTION_KIND_DO_MSG, errorId);
checkAtMostOneElement(UsageUtil.getStateSubactionMembershipsOf(type, StateSubactionKind.EXIT), INVALID_STATE_SUBACTION_KIND_EXIT_MSG, errorId);
checkAtMostOneRelationship(type, UsageUtil.getStateSubactionMembershipsOf(type, StateSubactionKind.ENTRY), INVALID_STATE_SUBACTION_KIND_ENTRY_MSG, errorId);
checkAtMostOneRelationship(type, UsageUtil.getStateSubactionMembershipsOf(type, StateSubactionKind.DO), INVALID_STATE_SUBACTION_KIND_DO_MSG, errorId);
checkAtMostOneRelationship(type, UsageUtil.getStateSubactionMembershipsOf(type, StateSubactionKind.EXIT), INVALID_STATE_SUBACTION_KIND_EXIT_MSG, errorId);
}

@Check
Expand Down Expand Up @@ -1079,7 +1079,7 @@ class SysMLValidator extends KerMLValidator {
checkAtMostOneFeature(defn, SubjectMembership, INVALID_REQUIREMENT_DEFINITION_ONLY_ONE_SUBJECT_MSG, INVALID_REQUIREMENT_DEFINITION_ONLY_ONE_SUBJECT)

// validateRequirementDefinitionSubjectParameterPosition
checkSubjectParameter(defn, defn.subjectParameter, defn.input, INVALID_REQUIREMENT_DEFINITION_SUBJECT_PARAMETER_POSITION_MSG, INVALID_REQUIREMENT_DEFINITION_SUBJECT_PARAMETER_POSITION)
checkSubjectParameter(defn, INVALID_REQUIREMENT_DEFINITION_SUBJECT_PARAMETER_POSITION_MSG, INVALID_REQUIREMENT_DEFINITION_SUBJECT_PARAMETER_POSITION)
}

@Check
Expand All @@ -1091,7 +1091,7 @@ class SysMLValidator extends KerMLValidator {
checkAtMostOneFeature(usg, SubjectMembership, INVALID_REQUIREMENT_USAGE_ONLY_ONE_SUBJECT_MSG, INVALID_REQUIREMENT_USAGE_ONLY_ONE_SUBJECT)

// validateRequirementUsageSubjectParameterPosition
checkSubjectParameter(usg, usg.subjectParameter, usg.input, INVALID_REQUIREMENT_USAGE_SUBJECT_PARAMETER_POSITION_MSG, INVALID_REQUIREMENT_USAGE_SUBJECT_PARAMETER_POSITION)
checkSubjectParameter(usg, INVALID_REQUIREMENT_USAGE_SUBJECT_PARAMETER_POSITION_MSG, INVALID_REQUIREMENT_USAGE_SUBJECT_PARAMETER_POSITION)
}

@Check
Expand Down Expand Up @@ -1129,7 +1129,7 @@ class SysMLValidator extends KerMLValidator {
checkAtMostOneFeature(defn, SubjectMembership, INVALID_CASE_DEFINITION_ONLY_ONE_SUBJECT_MSG, INVALID_CASE_DEFINITION_ONLY_ONE_SUBJECT)

// validateCaseDefinitionSubjectParameterPosition
checkSubjectParameter(defn, defn.subjectParameter, defn.input, INVALID_CASE_DEFINITION_SUBJECT_PARAMETER_POSITION_MSG, INVALID_CASE_DEFINITION_SUBJECT_PARAMETER_POSITION)
checkSubjectParameter(defn, INVALID_CASE_DEFINITION_SUBJECT_PARAMETER_POSITION_MSG, INVALID_CASE_DEFINITION_SUBJECT_PARAMETER_POSITION)
}

@Check
Expand All @@ -1145,7 +1145,7 @@ class SysMLValidator extends KerMLValidator {
checkAtMostOneFeature(usg, SubjectMembership, INVALID_CASE_USAGE_ONLY_ONE_SUBJECT_MSG, INVALID_CASE_USAGE_ONLY_ONE_SUBJECT)

// validateCaseUsageSubjectParameterPosition
checkSubjectParameter(usg, usg.subjectParameter, usg.input, INVALID_CASE_USAGE_SUBJECT_PARAMETER_POSITION_MSG, INVALID_CASE_USAGE_SUBJECT_PARAMETER_POSITION)
checkSubjectParameter(usg, INVALID_CASE_USAGE_SUBJECT_PARAMETER_POSITION_MSG, INVALID_CASE_USAGE_SUBJECT_PARAMETER_POSITION)
}

@Check
Expand Down Expand Up @@ -1321,17 +1321,26 @@ class SysMLValidator extends KerMLValidator {
return check
}

protected def boolean checkAtMostOneFeature(Type owningType, Class<? extends FeatureMembership> kind, String msg, String eId) {
var mems = owningType.ownedFeatureMembership.filter[m | kind.isInstance(m)]
checkAtMostOneElement(mems, msg, eId);
protected def boolean checkAtMostOneFeature(Type featuringType, Class<? extends FeatureMembership> kind, String msg, String eId) {
var mems = featuringType.featureMembership.filter[m | kind.isInstance(m)]
checkAtMostOneRelationship(featuringType, mems, msg, eId)
}

protected def boolean checkAtMostOneElement(Iterable<? extends Element> elements, String msg, String eId) {
if (elements.size <= 1) {
protected def boolean checkAtMostOneRelationship(Type type, Iterable<? extends Relationship> relationships, String msg, String eId) {
if (relationships.size <= 1) {
return true;
} else {
for (var i = 1; i < elements.size; i++) {
error(msg, elements.get(i), null, eId);
val ownedRelationships = relationships.filter[owningRelatedElement === type]
if (ownedRelationships.empty) {
error(msg, type, null, eId);
} else if (ownedRelationships.size == relationships.size) {
for (var i = 1; i < ownedRelationships.size; i++) {
error(msg, ownedRelationships.get(i), null, eId);
}
} else {
for (mem: ownedRelationships) {
error(msg, mem, null, eId);
}
}
return false;
}
Expand Down Expand Up @@ -1381,9 +1390,11 @@ class SysMLValidator extends KerMLValidator {
return true
}

protected def boolean checkSubjectParameter(Type type, Feature subjectParameter, Iterable<Feature> inputs, String msg, String eId) {
if (subjectParameter !== null && (inputs.empty || inputs.get(0) !== subjectParameter)) {
if (subjectParameter.owningType === type) {
protected def boolean checkSubjectParameter(Type type, String msg, String eId) {
val inputs = type.input
if (inputs.empty || !UsageUtil.isSubjectParameter(inputs.get(0))) {
val subjectParameter = UsageUtil.getOwnedSubjectParameterOf(type)
if (subjectParameter !== null) {
error(msg, subjectParameter, null, eId)
} else {
error(msg, type, null, eId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021, 2024 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2024, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -22,7 +22,6 @@
package org.omg.sysml.adapter;

import org.omg.sysml.lang.sysml.CaseDefinition;
import org.omg.sysml.util.UsageUtil;

public class CaseDefinitionAdapter extends CalculationDefinitionAdapter {

Expand All @@ -35,14 +34,4 @@ public CaseDefinition getTarget() {
return (CaseDefinition)super.getTarget();
}

// Transformation

@Override
public void addAdditionalMembers() {
CaseDefinition target = getTarget();
UsageUtil.addSubjectParameterTo(target);
UsageUtil.addObjectiveRequirementTo(target);
super.addAdditionalMembers();
}

}
11 changes: 0 additions & 11 deletions org.omg.sysml/src/org/omg/sysml/adapter/CaseUsageAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.omg.sysml.lang.sysml.CaseDefinition;
import org.omg.sysml.lang.sysml.CaseUsage;
import org.omg.sysml.lang.sysml.Type;
import org.omg.sysml.util.UsageUtil;

public class CaseUsageAdapter extends CalculationUsageAdapter {

Expand Down Expand Up @@ -63,14 +62,4 @@ public boolean isSubcase() {
(owningType instanceof CaseDefinition || owningType instanceof CaseUsage);
}

// Transformation

@Override
public void addAdditionalMembers() {
CaseUsage usage = getTarget();
UsageUtil.addSubjectParameterTo(usage);
UsageUtil.addObjectiveRequirementTo(usage);
super.addAdditionalMembers();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021, 2024 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2024, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -22,7 +22,6 @@
package org.omg.sysml.adapter;

import org.omg.sysml.lang.sysml.RequirementDefinition;
import org.omg.sysml.util.UsageUtil;

public class RequirementDefinitionAdapter extends ConstraintDefinitionAdapter {

Expand All @@ -34,12 +33,4 @@ public RequirementDefinition getTarget() {
return (RequirementDefinition)super.getTarget();
}

// Transformation

@Override
public void addAdditionalMembers() {
UsageUtil.addSubjectParameterTo(getTarget());
super.addAdditionalMembers();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021, 2023-2024 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2023-2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -82,16 +82,13 @@ public void addRequirementConstraintSubsetting() {
*/
@Override
protected List<? extends Feature> getRelevantFeatures(Type type, Element skip) {
RequirementUsage target = getTarget();
return UsageUtil.isObjective(getTarget())?
Collections.singletonList(UsageUtil.getObjectiveRequirementOf(type)):
Collections.singletonList(
type == target.getOwningType()?
UsageUtil.getOwnedObjectiveRequirementOf(type):
UsageUtil.getObjectiveRequirementOf(type)):
super.getRelevantFeatures(type, skip);
}

// Transformation

@Override
public void addAdditionalMembers() {
UsageUtil.addSubjectParameterTo(getTarget());
super.addAdditionalMembers();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2024 Model Driven Solutions, Inc.
* Copyright (c) 2024, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -32,8 +32,8 @@
import org.omg.sysml.lang.sysml.Conjugation;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.FeatureDirectionKind;
import org.omg.sysml.lang.sysml.Specialization;
import org.omg.sysml.lang.sysml.Type;
import org.omg.sysml.util.TypeUtil;

public class Type_directionOf_InvocationDelegate extends BasicInvocationDelegate {

Expand Down Expand Up @@ -65,8 +65,7 @@ protected static FeatureDirectionKind directionOf(Feature feature, Type type, Se
originalDirection;
}
} else {
for (Specialization specialization: type.getOwnedSpecialization()) {
Type general = specialization.getGeneral();
for (Type general: TypeUtil.getGeneralTypesOf(type)) {
if (general != null && !visited.contains(general)) {
FeatureDirectionKind direction = directionOf(feature, general, visited);
if (direction != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2022 Siemens AG
* Copyright (c) 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -25,9 +26,7 @@
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.lang.sysml.CaseDefinition;
import org.omg.sysml.lang.sysml.ObjectiveMembership;
import org.omg.sysml.lang.sysml.RequirementUsage;
import org.omg.sysml.util.TypeUtil;
import org.omg.sysml.util.UsageUtil;

public class CaseDefinition_objectiveRequirement_SettingDelegate extends BasicDerivedObjectSettingDelegate {

Expand All @@ -37,7 +36,7 @@ public CaseDefinition_objectiveRequirement_SettingDelegate(EStructuralFeature eS

@Override
protected EObject basicGet(InternalEObject owner) {
return (RequirementUsage)TypeUtil.getOwnedFeatureByMembershipIn((CaseDefinition)owner, ObjectiveMembership.class);
return UsageUtil.getObjectiveRequirementOf((CaseDefinition)owner);
}

}
Loading