|
45 | 45 | import org.eclipse.syson.sysml.OwningMembership; |
46 | 46 | import org.eclipse.syson.sysml.Redefinition; |
47 | 47 | import org.eclipse.syson.sysml.ReferenceSubsetting; |
| 48 | +import org.eclipse.syson.sysml.Specialization; |
48 | 49 | import org.eclipse.syson.sysml.Subsetting; |
| 50 | +import org.eclipse.syson.sysml.SysmlFactory; |
49 | 51 | import org.eclipse.syson.sysml.SysmlPackage; |
50 | 52 | import org.eclipse.syson.sysml.Type; |
51 | 53 | import org.eclipse.syson.sysml.TypeFeaturing; |
| 54 | +import org.eclipse.syson.sysml.util.ILibraryNamespaceProvider; |
| 55 | +import org.eclipse.syson.sysml.util.LibraryNamespaceProvider; |
52 | 56 |
|
53 | 57 | /** |
54 | 58 | * <!-- begin-user-doc --> An implementation of the model object '<em><b>Feature</b></em>'. <!-- end-user-doc --> |
@@ -462,6 +466,13 @@ public EList<Type> getFeaturingType() { |
462 | 466 | if (!chainingFeature.isEmpty()) { |
463 | 467 | featuringTypes.addAll(chainingFeature.get(0).getFeaturingType()); |
464 | 468 | } |
| 469 | + |
| 470 | + // Add implicit featuring type |
| 471 | + Type implicitType = this.computeImplicitFeaturingType(); |
| 472 | + if (implicitType != null) { |
| 473 | + featuringTypes.add(implicitType); |
| 474 | + } |
| 475 | + |
465 | 476 | return new EcoreEList.UnmodifiableEList<>(this, SysmlPackage.eINSTANCE.getFeature_FeaturingType(), featuringTypes.size(), featuringTypes.toArray()); |
466 | 477 | } |
467 | 478 |
|
@@ -1539,4 +1550,59 @@ private Collection<Feature> collectTypingFeatures() { |
1539 | 1550 | } |
1540 | 1551 | return featureCollector; |
1541 | 1552 | } |
| 1553 | + |
| 1554 | + /** |
| 1555 | + * @generated NOT |
| 1556 | + */ |
| 1557 | + private Type computeImplicitFeaturingType() { |
| 1558 | + Type owningType = this.getOwningType(); |
| 1559 | + Type implicitType = null; |
| 1560 | + if (owningType != null) { |
| 1561 | + |
| 1562 | + if (!this.isIsVariable()) { |
| 1563 | + // 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.” |
| 1564 | + // SysML 8.3.3.1.6 FeatureMembership - If the ownedMemberFeature has isVariable = false, then the FeatureMembership implies that the owningType is also a featuringType of the |
| 1565 | + // ownedMemberFeature. |
| 1566 | + implicitType = owningType; |
| 1567 | + } else { |
| 1568 | + // KerML 8.4.4.3 |
| 1569 | + // Class (or any Type that directly or indirectly specializes Occurrence) may have ownedFeatures with |
| 1570 | + // isVariable = true. The checkFeatureFeatureMembershipTypeFeaturing constraint requires that such |
| 1571 | + // variable Features are featured by the snapshots of their owningType. |
| 1572 | + TypeFeaturing typeFeaturing = SysmlFactory.eINSTANCE.createTypeFeaturing(); |
| 1573 | + typeFeaturing.setIsImplied(true); |
| 1574 | + |
| 1575 | + // Table 9. Core Semantics Implied Relationships Supporting Kernel Semantics - Note 1 |
| 1576 | + // For the checkFeatureFeatureMembershipTypeFeaturing constraint, if the Feature has |
| 1577 | + //isVariable = false, then the target Type is the owningType of the Feature. If the Feature has |
| 1578 | + //isVariable = true and the owningType is the base Class Occurrences::Occurrence, then the |
| 1579 | + //target is Occurrences::Occurrence::snapshots (see 9.2.4.2.13 ). Otherwise, the target Type shall |
| 1580 | + //be constructed so as to satisfy the constraint and shall be owned as an ownedRelatedElement of the |
| 1581 | + //implied TypeFeaturing relationship. For further details, see 8.4.4.3 . |
| 1582 | + ILibraryNamespaceProvider nsProvider = LibraryNamespaceProvider.getFrom(this); |
| 1583 | + if (nsProvider == null) { |
| 1584 | + nsProvider = new LibraryNamespaceProvider(this); |
| 1585 | + } |
| 1586 | + Type snapshot = nsProvider.getNamespaceFromLibrary("Occurrences::Occurrence::snapshot", Type.class); |
| 1587 | + if (owningType == nsProvider.getNamespaceFromLibrary("Occurrences::Occurrence")) { |
| 1588 | + implicitType = snapshot; |
| 1589 | + } else { |
| 1590 | + implicitType = SysmlFactory.eINSTANCE.createFeature(); |
| 1591 | + typeFeaturing.getOwnedRelatedElement().add(implicitType); |
| 1592 | + |
| 1593 | + Specialization specialization = SysmlFactory.eINSTANCE.createSpecialization(); |
| 1594 | + implicitType.getOwnedRelationship().add(specialization); |
| 1595 | + specialization.setSpecific(implicitType); |
| 1596 | + specialization.setGeneral(snapshot); |
| 1597 | + } |
| 1598 | + |
| 1599 | + typeFeaturing.setFeaturingType(owningType); |
| 1600 | + typeFeaturing.setFeatureOfType((Feature) implicitType); |
| 1601 | + implicitType.getOwnedRelationship().add(typeFeaturing); |
| 1602 | + |
| 1603 | + } |
| 1604 | + |
| 1605 | + } |
| 1606 | + return implicitType; |
| 1607 | + } |
1542 | 1608 | } // FeatureImpl |
0 commit comments