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
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The property `SysONTestsProperties#ELASTICSEARCH` has been removed, tests that r
For example `ViewUsage` elements are no longer rendered in _parts_ compartments.
- https://github.com/eclipse-syson/syson/issues/1981[#1981] [export] Fix an error during textual export where `Expose` elements with apostrophes in their name were not properly escaped.
- https://github.com/eclipse-syson/syson/issues/1983[#1983] [metamodel] `reqId` and `declaredShortName` properties of `RequirementDefinition` and `RequirementUsage` are now synchronized, as required by the SysMLv2 specification.
- https://github.com/eclipse-syson/syson/issues/1998[#1998] Missing implicit TypeFeaturing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing category (please add one each time, you regularly forget to add one)


=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.eclipse.syson.sysml.Redefinition;
import org.eclipse.syson.sysml.ReferenceSubsetting;
import org.eclipse.syson.sysml.Subsetting;
import org.eclipse.syson.sysml.SysmlFactory;
import org.eclipse.syson.sysml.SysmlPackage;
import org.eclipse.syson.sysml.Type;
import org.eclipse.syson.sysml.TypeFeaturing;
Expand Down Expand Up @@ -462,6 +463,13 @@ public EList<Type> getFeaturingType() {
if (!chainingFeature.isEmpty()) {
featuringTypes.addAll(chainingFeature.get(0).getFeaturingType());
}

// Add implicit featuring type
Type implicitType = this.computeImplicitFeaturingType();
if (implicitType != null) {
featuringTypes.add(implicitType);
}

return new EcoreEList.UnmodifiableEList<>(this, SysmlPackage.eINSTANCE.getFeature_FeaturingType(), featuringTypes.size(), featuringTypes.toArray());
}

Expand Down Expand Up @@ -1539,4 +1547,35 @@ private Collection<Feature> collectTypingFeatures() {
}
return featureCollector;
}

/**
* @generated NOT
*/
private Type computeImplicitFeaturingType() {
Type owningType = this.getOwningType();
Type implicitType = null;
if (owningType != null) {

if (!this.isIsVariable()) {
// KerML 7.3.2.6 “Feature Membership” – “A feature that is declared within the body of a type … automatically has that type as a featuring type.”
implicitType = owningType;
} else {
// KerML 8.4.4.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems not related with the code below.

// Class (or any Type that directly or indirectly specializes Occurrence) may have ownedFeatures with
// isVariable = true. The checkFeatureFeatureMembershipTypeFeaturing constraint requires that such
// variable Features are featured by the snapshots of their owningType.
implicitType = SysmlFactory.eINSTANCE.createFeature();
implicitType.setDeclaredName(owningType.getDeclaredName() + "-SNAPSHOT");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "-SNAPSHOT" arbitrary suffix? If it is, could you please just mention it?


// This virtual type should at some point redefine Occurrences::Occurrence::snapshots
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And where it is done? (note @gcoutable is working on an issue that is related to Occurrences::Occurrence::snapshots)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless empty line

TypeFeaturing typeFeaturing = SysmlFactory.eINSTANCE.createTypeFeaturing();
typeFeaturing.setFeaturingType(owningType);
typeFeaturing.setFeatureOfType((Feature) implicitType);
implicitType.getOwnedRelationship().add(typeFeaturing);
}

}
return implicitType;
}
} // FeatureImpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* Copyright (c) 2024, 2026 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,12 +12,16 @@
*******************************************************************************/
package org.eclipse.syson.sysml.impl;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.eclipse.syson.sysml.Feature;
import org.eclipse.syson.sysml.ItemDefinition;
import org.eclipse.syson.sysml.ItemUsage;
import org.eclipse.syson.sysml.util.ModelBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -59,4 +63,21 @@ public void testNames() {
assertEquals("f", f2.effectiveShortName());
}


@Test
@DisplayName("GIVEN a non variable feature in a Type, WHEN computing it's featuring types, THEN the owning type is returned")
public void checkImplicitFeaturingTypeNoVariableFeature() {
var itemDef = this.builder.createWithName(ItemDefinition.class, "ItemDef");
ItemUsage itemUsage = this.builder.createInWithName(ItemUsage.class, itemDef, "ItemUsage");
assertThat(itemUsage.getFeaturingType()).hasSize(1).allMatch(type -> type == itemDef);
}

@Test
@DisplayName("GIVEN a variable feature in a Type, WHEN computing it's featuring types, THEN the owning type is returned")
public void checkImplicitFeaturingTypeVariableFeature() {
var itemDef = this.builder.createWithName(ItemDefinition.class, "ItemDef");
ItemUsage itemUsage = this.builder.createInWithName(ItemUsage.class, itemDef, "ItemUsage");
itemUsage.setIsVariable(true);
assertThat(itemUsage.getFeaturingType()).hasSize(1).allMatch(type -> "ItemDef-SNAPSHOT".equals(type.getName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ part system {

** `Req Id` and `Declared Short Name` properties of `RequirementDefinition` and `RequirementUsage` are now synchronized, as required by the SysMLv2 specification.

* In _Validation_ view:

** Improve the computation to _featuringType_ on `Feature` to avoid getting the following validation error:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

computation to => computation of

+
```
If a Feature is owned via a FeatureMembership, then it must have a featuringType for which the operation isFeaturingType returns true. (checkFeatureFeatureMembershipTypeFeaturing constraint on Feature is not respected for Test::MyItemDef::myFeature)
````

== Improvements

* In diagrams:
Expand Down
Loading