Skip to content
Draft
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 @@ -38,6 +38,8 @@

public class TransitionUsageAdapter extends ActionUsageAdapter {

private boolean isComputingTransitionLinkConnectors = false;

public TransitionUsageAdapter(TransitionUsage element) {
super(element);
}
Expand Down Expand Up @@ -103,24 +105,32 @@ protected void computeSource() {
*/
protected Feature computeTransitionLinkConnectors() {
TransitionUsage transition = getTarget();
Feature transitionLinkFeature = UsageUtil.getTransitionLinkFeatureOf(transition);
if (transitionLinkFeature == null) {
Succession succession = transition.getSuccession();
if (succession != null) {
transitionLinkFeature = SysMLFactory.eINSTANCE.createReferenceUsage();
TypeUtil.addOwnedFeatureTo(transition, transitionLinkFeature);
addBindingConnector(succession, transitionLinkFeature);
}

List<Feature> parameters = TypeUtil.getOwnedParametersOf(transition);
if (!parameters.isEmpty()) {
Feature source = transition.getSource();
if (source != null) {
addBindingConnector(source, parameters.get(0));
if (this.isComputingTransitionLinkConnectors) {
return UsageUtil.getTransitionLinkFeatureOf(transition);
}
this.isComputingTransitionLinkConnectors = true;
try {
Feature transitionLinkFeature = UsageUtil.getTransitionLinkFeatureOf(transition);
if (transitionLinkFeature == null) {
Succession succession = transition.getSuccession();
if (succession != null) {
transitionLinkFeature = SysMLFactory.eINSTANCE.createReferenceUsage();
TypeUtil.addOwnedFeatureTo(transition, transitionLinkFeature);
addBindingConnector(succession, transitionLinkFeature);
}

List<Feature> parameters = TypeUtil.getOwnedParametersOf(transition);
if (!parameters.isEmpty()) {
Feature source = transition.getSource();
if (source != null) {
addBindingConnector(source, parameters.get(0));
}
}
}
return transitionLinkFeature;
} finally {
this.isComputingTransitionLinkConnectors = false;
}
return transitionLinkFeature;
}

@Override
Expand All @@ -130,7 +140,7 @@ public void addAdditionalMembers() {
computeSource();
// Note: Needs to come before clearing and recomputation of inheritance cache.
//checkTransitionUsageSuccessionBindingConnector
computeTransitionLinkConnectors();
computeTransitionLinkConnectors();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2026 Obeo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
* the Eclipse Foundation, version 2 of the License.
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Eclipse Public License for more details.
*
* You should have received a copy of theEclipse Public License
* along with this program. If not, see <https://www.eclipse.org/legal/epl-2.0/>.
*
* @license EPL-2.0 <http://spdx.org/licenses/EPL-2.0>
*
*******************************************************************************/

package org.omg.sysml.logic;

import static org.junit.Assert.assertNull;

import org.junit.Test;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.lang.sysml.FeatureDirectionKind;
import org.omg.sysml.lang.sysml.ParameterMembership;
import org.omg.sysml.lang.sysml.SysMLFactory;
import org.omg.sysml.lang.sysml.SysMLPackage;
import org.omg.sysml.lang.sysml.TransitionUsage;

/**
* Tests transition derived-property computations.
*/
public class TransitionUsageAdapterTest {
/**
* The source derivation asks transition adapters to add implicit members.
* A transition with parameters but no source and no succession must not
* recursively recompute transition link connectors while its source is being
* derived.
*/
@Test
public void transitionSourceDerivationIsReentrantSafeWithoutSuccession() {
SysMLLogicStandaloneSetup.doSetup();
SysMLPackage.eINSTANCE.eClass();
SysMLFactory factory = SysMLFactory.eINSTANCE;
TransitionUsage transition = factory.createTransitionUsage();
Feature parameter = factory.createFeature();
parameter.setDirection(FeatureDirectionKind.IN);
ParameterMembership parameterMembership = factory.createParameterMembership();
parameterMembership.setOwnedMemberParameter(parameter);
transition.getOwnedRelationship().add(parameterMembership);
assertNull(transition.getSource());
}
}
Loading