Skip to content
Merged
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
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021-2022, 2025 Model Driven Solutions, Inc.
* Copyright (c) 2021-2022, 2025, 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -24,6 +24,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

Expand All @@ -36,6 +37,7 @@
import org.omg.sysml.lang.sysml.ActionUsage;
import org.omg.sysml.lang.sysml.AttributeUsage;
import org.omg.sysml.lang.sysml.Comment;
import org.omg.sysml.lang.sysml.ConnectionDefinition;
import org.omg.sysml.lang.sysml.Definition;
import org.omg.sysml.lang.sysml.Documentation;
import org.omg.sysml.lang.sysml.Element;
Expand Down Expand Up @@ -351,4 +353,35 @@ public void testLocale() throws Exception {
assertEquals("comment.locale", "en_US", comment.getLocale());
assertEquals("doc.locale", "en_US", doc.getLocale());
}

public final String crossFeatureTest =
"package Test {"
+ " part def A {"
+ " ref b : B;"
+ " }"
+ " part def B;"
+ " connection def C {"
+ " end [0..1] ref end1 : A;"
+ " end ref end2 : B crosses end1.b;"
+ " }"
+ "}";

@Test
public void testCrossFeature() throws Exception {
SysMLInteractive instance = getSysMLInteractiveInstance();
SysMLInteractiveResult result = instance.process(crossFeatureTest);
Element root = result.getRootElement();
Namespace test = (Namespace)((Namespace)root).getOwnedMember().get(0);
Definition a = (Definition)test.getOwnedMember().get(0);
Usage a_b = a.getOwnedUsage().get(0);
ConnectionDefinition c = (ConnectionDefinition)test.getOwnedMember().get(2);
List<Feature> ends = c.getAssociationEnd();
Usage end1 = (Usage)ends.get(0);
Usage end2 = (Usage)ends.get(1);
Feature ownedCrossFeature = end1.ownedCrossFeature();

assertNotNull("end1 owned cross feature", ownedCrossFeature);
assertEquals("end1 cross feature", end1.ownedCrossFeature(), end1.getCrossFeature());
assertEquals("end2 cross feature", a_b, end2.getCrossFeature().getFeatureTarget());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2024 Model Driven Solutions, Inc.
* Copyright (c) 2024, 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -21,13 +21,11 @@

package org.omg.sysml.delegate.setting;

import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.lang.sysml.CrossSubsetting;
import org.omg.sysml.lang.sysml.Feature;
import org.omg.sysml.util.FeatureUtil;

public class Feature_crossFeature_SettingDelegate extends BasicDerivedObjectSettingDelegate {

Expand All @@ -37,17 +35,7 @@ public Feature_crossFeature_SettingDelegate(EStructuralFeature eStructuralFeatur

@Override
protected EObject basicGet(InternalEObject owner) {
CrossSubsetting subsetting = ((Feature)owner).getOwnedCrossSubsetting();
if (subsetting != null) {
Feature crossedFeature = subsetting.getCrossedFeature();
if (crossedFeature != null) {
List<Feature> chainingFeatures = crossedFeature.getChainingFeature();
if (chainingFeatures.size() >=2) {
return chainingFeatures.get(1);
}
}
}
return null;
return FeatureUtil.getCrossFeatureOf((Feature)owner);
}

}
Loading