1- /*
2- * generated by Xtext 2.18.0.M3
3- */
1+ /* ****************************************************************************
2+ * SysML 2 Pilot Implementation
3+ * Copyright (c) 2025 Model Driven Solutions, Inc.
4+ *
5+ * This program is free software: you can redistribute it and/or modify
6+ * it under the terms of the GNU Lesser General Public License as published by
7+ * the Free Software Foundation, either version 3 of the License, or
8+ * (at your option) any later version.
9+ *
10+ * This program is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU Lesser General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU Lesser General Public License
16+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17+ *
18+ * @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+ *
20+ * Contributors:
21+ * Ed Seidewitz, MDS
22+ *
23+ *****************************************************************************/
424package org.omg.sysml.xtext.scoping
525
626import org.omg.kerml.xtext.scoping.KerMLScopeProvider
27+ import org.eclipse.emf.ecore.EObject
28+ import org.eclipse.emf.ecore.EReference
29+ import org.omg.sysml.lang.sysml.Membership
30+ import org.omg.sysml.lang.sysml.TransitionUsage
31+ import org.omg.sysml.lang.sysml.FeatureMembership
32+ import org.omg.sysml.lang.sysml.ReferenceSubsetting
33+ import org.omg.sysml.lang.sysml.SuccessionAsUsage
34+ import org.omg.sysml.lang.sysml.FeatureChaining
735
836/**
937 * This class contains custom scoping description.
@@ -12,4 +40,41 @@ import org.omg.kerml.xtext.scoping.KerMLScopeProvider
1240 * on how and when to use it.
1341 */
1442class SysMLScopeProvider extends KerMLScopeProvider {
43+
44+ def EObject featureRelationship (EObject context ) {
45+ if (context instanceof FeatureChaining ) {
46+ var featureChained = context. featureChained
47+ val ownedFeatureChainings = featureChained. ownedFeatureChaining
48+ val i = ownedFeatureChainings. indexOf(context)
49+ if ( i <= 0 ) {
50+ return featureChained. owningRelationship
51+ }
52+ }
53+ return context
54+ }
55+
56+ override getScope (EObject context , EReference reference ) {
57+ var relationship = context. featureRelationship
58+
59+ // Scope a TransitionUsage source to the owningNamespace of the TransitionUsage
60+ if (relationship instanceof Membership ) {
61+ val owningNamespace = relationship. membershipOwningNamespace;
62+ if (owningNamespace instanceof TransitionUsage &&
63+ relationship == owningNamespace. ownedMembership. filter[mem | ! (mem instanceof FeatureMembership )]. head) {
64+ return owningNamespace. scope_owningNamespace(context, reference)
65+ }
66+
67+ // Scope a TransitionUsage target to the owningNamespace of the TransitionUsage
68+ } else if (relationship instanceof ReferenceSubsetting ) {
69+ val owningFeature = relationship. owningFeature
70+ val owningType = owningFeature. owningType
71+ if (owningType instanceof SuccessionAsUsage && owningType. ownedEndFeature. indexOf(owningFeature) == 1 ) {
72+ val outerNamespace = owningType. owningNamespace
73+ if (outerNamespace instanceof TransitionUsage && owningType == = (outerNamespace as TransitionUsage ). succession) {
74+ return outerNamespace. scope_owningNamespace(context, reference)
75+ }
76+ }
77+ }
78+ return super . getScope(context, reference)
79+ }
1580}
0 commit comments