11/*******************************************************************************
22 * SysML 2 Pilot Implementation
3- * Copyright (c) 2021, 2022 Model Driven Solutions, Inc.
3+ * Copyright (c) 2021, 2022, 2025 Model Driven Solutions, Inc.
44 *
55 * This program is free software: you can redistribute it and/or modify
66 * it under the terms of the GNU Lesser General Public License as published by
2121
2222package org .omg .sysml .adapter ;
2323
24- import java .util .List ;
25-
26- import org .omg .sysml .lang .sysml .Element ;
2724import org .omg .sysml .lang .sysml .Feature ;
2825import org .omg .sysml .lang .sysml .FeatureChainExpression ;
2926import org .omg .sysml .lang .sysml .SysMLFactory ;
3027import org .omg .sysml .lang .sysml .SysMLPackage ;
28+ import org .omg .sysml .util .FeatureUtil ;
3129import org .omg .sysml .util .ImplicitGeneralizationMap ;
3230import org .omg .sysml .util .TypeUtil ;
3331
@@ -46,26 +44,36 @@ public FeatureChainExpression getTarget() {
4644 protected void addResultTyping () {
4745 FeatureChainExpression target = getTarget ();
4846 Feature result = target .getResult ();
49- Element targetFeature = target .getTargetFeature ();
50- if (result != null ) {
47+ Feature sourceTarget = target .sourceTargetFeature ();
48+ if (result != null && sourceTarget != null ) {
49+ Feature sourceParameter = TypeUtil .getOwnedParameterOf (target , 0 , Feature .class );
5150 TypeUtil .addImplicitGeneralTypeTo (result ,
52- SysMLPackage .eINSTANCE .getSubsetting (), (Feature )targetFeature );
51+ SysMLPackage .eINSTANCE .getSubsetting (),
52+ FeatureUtil .chainFeatures (sourceParameter , sourceTarget ));
5353 }
5454 }
5555
56- protected void addTargetRedefinition () {
56+ @ Override
57+ public void addAdditionalMembers () {
58+ super .addAdditionalMembers ();
59+
60+ // Add sourceTarget feature.
5761 FeatureChainExpression target = getTarget ();
5862 Feature sourceParameter = TypeUtil .getOwnedParameterOf (target , 0 , Feature .class );
5963 if (sourceParameter != null ) {
60- Feature sourceTarget = null ;
61- List <Feature > sourceFeatures = sourceParameter .getOwnedFeature ();
62- if (!sourceFeatures .isEmpty ()) {
63- sourceTarget = sourceFeatures .get (0 );
64- } else {
65- sourceTarget = SysMLFactory .eINSTANCE .createFeature ();
64+ if (sourceParameter .getOwnedFeature ().isEmpty ()) {
65+ Feature sourceTarget = SysMLFactory .eINSTANCE .createFeature ();
6666 sourceTarget .setDeclaredName ("" ); // To avoid effective naming.
6767 TypeUtil .addOwnedFeatureTo (sourceParameter , sourceTarget );
6868 }
69+ }
70+ }
71+
72+ protected void addTargetRedefinition () {
73+ FeatureChainExpression target = getTarget ();
74+ Feature sourceParameter = TypeUtil .getOwnedParameterOf (target , 0 , Feature .class );
75+ if (sourceParameter != null ) {
76+ Feature sourceTarget = target .sourceTargetFeature ();
6977 TypeUtil .addImplicitGeneralTypeTo (sourceTarget ,
7078 SysMLPackage .eINSTANCE .getRedefinition (),
7179 getLibraryType (ImplicitGeneralizationMap .getDefaultSupertypeFor (target .getClass (), "target" )));
0 commit comments