Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SysML 2 Pilot Implementation
* Copyright (c) 2018-2025 Model Driven Solutions, Inc.
* Copyright (c) 2018 IncQuery Labs Ltd.
* Copyright (c) 2019 Maplesoft (Waterloo Maple, Inc.)
* Copyright (c) 2019 Mgnite Inc.
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -23,7 +22,7 @@
* Ed Seidewitz, MDS
* Zoltan Kiss, IncQuery
* Balazs Grill, IncQuery
* Hisashi Miyashita, Maplesoft/Mgnite
* Hisashi Miyashita, Mgnite
*
*****************************************************************************/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ XPECT_SETUP org.omg.kerml.xpect.tests.validation.KerMLValidationTest
ResourceSet {
ThisFile {}
File {from ="/library/Base.kerml"}
File {from ="/library/Links.kerml"}
File {from ="/library/Occurrences.kerml"}
File {from ="/library/Objects.kerml"}
File {from ="/library/Performances.kerml"}
Expand All @@ -12,6 +13,7 @@ XPECT_SETUP org.omg.kerml.xpect.tests.validation.KerMLValidationTest
SrcFolder {
ThisFile {}
File {from ="/library/Base.kerml"}
File {from ="/library/Links.kerml"}
File {from ="/library/Occurrences.kerml"}
File {from ="/library/Objects.kerml"}
File {from ="/library/Performances.kerml"}
Expand All @@ -26,8 +28,27 @@ package RedefinitionEnd {
}

classifier B :> A {
// XPECT errors ---> "Redefining feature must be an end feature" at "e"
feature :>> e;
}

assoc R {
end a : A;
end b : B;
}

abstract connector r : R {
end a;
end b;
}

abstract assoc R1 :> R {
// XPECT errors ---> "Redefining feature must be an end feature" at "a"
feature a1 :>> a;
}

abstract connector r1 :> r {
// XPECT errors ---> "Redefining feature must be an end feature" at "a"
feature a1 :>> a;
}

}
3 changes: 1 addition & 2 deletions org.omg.kerml.xtext/src/org/omg/kerml/xtext/KerML.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SysML 2 Pilot Implementation
* Copyright (c) 2018-2025 Model Driven Solutions, Inc.
* Copyright (c) 2018 IncQuery Labs Ltd.
* Copyright (c) 2019 Maplesoft (Waterloo Maple, Inc.)
* Copyright (c) 2019 Mgnite Inc.
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -23,7 +22,7 @@
* Ed Seidewitz, MDS
* Zoltan Kiss, IncQuery
* Balazs Grill, IncQuery
* Hisashi Miyashita, Maplesoft/Mgnite
* Hisashi Miyashita, Mgnite
*
*****************************************************************************/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,8 @@ class KerMLValidator extends AbstractKerMLValidator {
}

// validateFeatureMultiplicityDomain
// TODO: Update OCL for owned cross feature multiplicity featuring type.
val m = f.multiplicity;
val featuringTypes = f.featuringType
var mFeaturingTypes =
if (FeatureUtil.isOwnedCrossFeature(f)) (f.owningNamespace as Feature).featuringType
else featuringTypes
if (m !== null && mFeaturingTypes.toSet != m.featuringType.toSet) {
if (m !== null && f.featuringType.toSet != m.featuringType.toSet) {
error(INVALID_FEATURE_MULTIPLICITY_DOMAIN_MSG, f, SysMLPackage.eINSTANCE.type_Multiplicity, INVALID_FEATURE_MULTIPLICITY_DOMAIN)
}

Expand Down Expand Up @@ -730,10 +725,13 @@ class KerMLValidator extends AbstractKerMLValidator {
}
}

// validatRedefinitionEndConformance
// validateRedefinitionEndConformance
if (redefinedFeature.isEnd && !redefiningFeature.isEnd) {
error(INVALID_REDEFINITION_END_CONFORMANCE_MSG, redef,
SysMLPackage.eINSTANCE.redefinition_RedefinedFeature, INVALID_REDEFINITION_END_CONFORMANCE)
val redefiningOwner = redefiningFeature.owningType
if (redefiningOwner instanceof Association || redefiningOwner instanceof Connector) {
error(INVALID_REDEFINITION_END_CONFORMANCE_MSG, redef,
SysMLPackage.eINSTANCE.redefinition_RedefinedFeature, INVALID_REDEFINITION_END_CONFORMANCE)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
import org.omg.sysml.lang.sysml.Expression;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.FeatureValue;
import org.omg.sysml.lang.sysml.Multiplicity;
import org.omg.sysml.lang.sysml.MultiplicityRange;
import org.omg.sysml.lang.sysml.Namespace;
import org.omg.sysml.lang.sysml.Type;
import org.omg.sysml.util.ExpressionUtil;
import org.omg.sysml.util.FeatureUtil;
import org.omg.sysml.util.ImplicitGeneralizationMap;

public class ExpressionAdapter extends StepAdapter {
Expand Down Expand Up @@ -99,20 +101,40 @@ protected List<Type> getGeneralTypes(Type type, Element skip) {
}

// Transformation

/**
* @satisfies checkExpressionTypeFeaturing
* @satisfies checkExpressionResultBindingConnector
* @satisfies checkMultiplicityRangeExpressionTypeFeaturing
*/
@Override
protected void addImplicitFeaturingTypesIfNecessary() {
Expression expression = getTarget();
Comment thread
AxelRICHARD marked this conversation as resolved.
Namespace owner = expression.getOwningNamespace();
if (owner instanceof MultiplicityRange multiplicity &&
multiplicity.getBound().contains(expression)) {
owner = multiplicity.getOwningNamespace();
if (owner instanceof Feature ownerFeature) {
if (FeatureUtil.isOwnedCrossFeature(ownerFeature) &&
isImplicitFeaturingTypesEmpty()) {
Feature owningEnd = (Feature) ownerFeature.getOwningNamespace();
addFeaturingTypes(owningEnd.getFeaturingType());
} else {
super.addImplicitFeaturingTypesIfNecessary();
}
}
} else if (expression.getOwningMembership() instanceof FeatureValue) {
super.addImplicitFeaturingTypesIfNecessary();
}
}

/**
* @satisfies checkExpressionResultBindingConnector
*/
@Override
public void doTransform() {
Expression expression = getTarget();
super.doTransform();
if (expression.getOwningNamespace() instanceof Multiplicity ||
expression.getOwningMembership() instanceof FeatureValue) {
addImplicitFeaturingTypesIfNecessary();
}
addImplicitFeaturingTypesIfNecessary();
createResultConnector(expression.getResult());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ protected void addResultTyping() {
ElementUtil.transform(seqArgument);
Feature seqResult = seqArgument.getResult();
Type collectionType = getLibraryType(COLLECTIONS_TYPE);
/*
* TODO: Update checkIndexExpressionResultSpecialization
*
* OCL currently only checks for Array type, not any Collection type.
* See KERML11-69
*/
if (!TypeUtil.specializes(seqResult, collectionType)) {
Feature resultFeature = target.getResult();
if (resultFeature != null && seqResult != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021, 2024, 2025 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2024-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 @@ -27,9 +27,7 @@
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.Multiplicity;
import org.omg.sysml.lang.sysml.Namespace;
import org.omg.sysml.lang.sysml.Type;
import org.omg.sysml.util.FeatureUtil;

public class MultiplicityAdapter extends FeatureAdapter {

Expand Down Expand Up @@ -64,21 +62,6 @@ protected List<Multiplicity> getRelevantFeatures(Type type) {
/**
* @satisfies checkMultiplicityTypeFeaturing
*/
@Override
protected void addImplicitFeaturingTypesIfNecessary() {
Feature feature = getTarget();
Namespace owner = feature.getOwningNamespace();
if (owner instanceof Feature) {
Namespace owningEnd = owner.getOwningNamespace();
if (FeatureUtil.isOwnedCrossFeature((Feature)owner) &&
isImplicitFeaturingTypesEmpty()) {
addFeaturingTypes(((Feature)owningEnd).getFeaturingType());
} else {
super.addImplicitFeaturingTypesIfNecessary();
}
}
}

@Override
public void doTransform() {
super.doTransform();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.adapter.FeatureAdapter;
import org.omg.sysml.lang.sysml.Behavior;
import org.omg.sysml.lang.sysml.BindingConnector;
import org.omg.sysml.lang.sysml.CrossSubsetting;
import org.omg.sysml.lang.sysml.Expression;
import org.omg.sysml.lang.sysml.Feature;
Expand Down Expand Up @@ -233,14 +234,19 @@ public static Feature getCrossFeatureOf(Feature feature) {
}

public static Feature getOwnedCrossFeatureOf(Namespace namespace) {
return !(namespace instanceof Feature) || !((Feature)namespace).isEnd()? null:
(Feature)namespace.getOwnedMember().stream().
filter(element->element instanceof Feature &&
!(element instanceof Multiplicity) &&
!(element instanceof MetadataFeature) &&
!(element.getOwningMembership() instanceof FeatureMembership)&&
!(element.getOwningMembership() instanceof FeatureValue)).
findFirst().orElse(null);
if (!(namespace instanceof Feature feature) ||
!feature.isEnd() || feature.getOwningType() == null) {
return null;
} else {
return (Feature)namespace.getOwnedMember().stream().
filter(element->element instanceof Feature &&
!(element instanceof Multiplicity) &&
!(element instanceof MetadataFeature) &&
!(element instanceof BindingConnector) &&
!(element.getOwningMembership() instanceof FeatureMembership) &&
!(element.getOwningMembership() instanceof FeatureValue)).
findFirst().orElse(null);
}
}

public static boolean isOwnedCrossFeature(Feature feature) {
Expand Down
Loading
Loading