Skip to content

Commit 0b84200

Browse files
committed
ST6RI-830 Updated to use a specific global scope symbol marker string.
1 parent 8367828 commit 0b84200

4 files changed

Lines changed: 26 additions & 9 deletions

File tree

org.omg.kerml.xtext/src/org/omg/kerml/xtext/naming/QualifiedNamesUtil.java renamed to org.omg.kerml.xtext/src/org/omg/kerml/xtext/naming/QualifiedNameUtil.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
*
2020
* Contributors:
2121
* Laszlo Gati, MDS
22+
* Ed Seidewitz. MDS
2223
*/
2324
package org.omg.kerml.xtext.naming;
2425

2526
import org.eclipse.xtext.naming.QualifiedName;
27+
import org.omg.sysml.util.ElementUtil;
2628

27-
public class QualifiedNamesUtil {
28-
29-
public static final String GLOBAL_CLASSIFIER_SYMBOL = "$";
29+
public class QualifiedNameUtil {
3030

3131
public static boolean isGlobalNameQualification(QualifiedName qualifiedName) {
3232
return qualifiedName != null &&
3333
qualifiedName.getSegmentCount() > 0 &&
34-
GLOBAL_CLASSIFIER_SYMBOL.equals(qualifiedName.getFirstSegment());
34+
ElementUtil.isGlobalScopeSymbol(qualifiedName.getFirstSegment());
3535
}
36+
3637
}

org.omg.kerml.xtext/src/org/omg/kerml/xtext/scoping/KerMLGlobalScope.xtend

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import org.eclipse.xtext.scoping.impl.AbstractScope
3838
import org.omg.sysml.lang.sysml.Namespace
3939
import org.omg.sysml.lang.sysml.SysMLPackage
4040
import org.omg.sysml.lang.sysml.Element
41-
import org.omg.kerml.xtext.naming.QualifiedNamesUtil
41+
import org.omg.kerml.xtext.naming.QualifiedNameUtil
4242

4343
class KerMLGlobalScope extends AbstractScope {
4444

@@ -79,7 +79,7 @@ class KerMLGlobalScope extends AbstractScope {
7979
}
8080

8181
override getSingleElement(QualifiedName name) {
82-
val isGlobalQualification = QualifiedNamesUtil.isGlobalNameQualification(name)
82+
val isGlobalQualification = QualifiedNameUtil.isGlobalNameQualification(name)
8383
val qualifiedName = isGlobalQualification? name.skipFirst(1) : name
8484

8585
var IEObjectDescription result = null

org.omg.kerml.xtext/src/org/omg/kerml/xtext/scoping/KerMLScope.xtend

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import com.google.inject.Inject
5656
import org.eclipse.xtext.naming.IQualifiedNameConverter
5757
import org.eclipse.emf.ecore.util.EcoreUtil
5858
import org.omg.sysml.util.NamespaceUtil
59-
import org.omg.kerml.xtext.naming.QualifiedNamesUtil
59+
import org.omg.kerml.xtext.naming.QualifiedNameUtil
6060

6161
class KerMLScope extends AbstractScope implements ISysMLScope {
6262

@@ -168,7 +168,7 @@ class KerMLScope extends AbstractScope implements ISysMLScope {
168168
}
169169

170170
override getSingleElement(QualifiedName name) {
171-
if (QualifiedNamesUtil.isGlobalNameQualification(name)){
171+
if (QualifiedNameUtil.isGlobalNameQualification(name)){
172172
parent.getSingleElement(name)
173173
} else {
174174
val result = resolveInScope(name, true);

org.omg.sysml/src/org/omg/sysml/util/ElementUtil.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2019, 2020, 2022, 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2019, 2020, 2022, 2024, 2025 Model Driven Solutions, Inc.
44
* Copyright (c) 2023 Mgnite Inc.
55
*
66
* This program is free software: you can redistribute it and/or modify
@@ -122,13 +122,29 @@ public static boolean isIdentifier(String name) {
122122
return name.matches("[a-zA-Z_]\\w*");
123123
}
124124

125+
// Specific string used to identify a segment as a global scope qualifier
126+
public static final String GLOBAL_SCOPE_SYMBOL = "$";
127+
128+
public static boolean isGlobalScopeSymbol(String segment) {
129+
return segment == GLOBAL_SCOPE_SYMBOL;
130+
}
131+
125132
public static List<String> parseQualifiedName(String qualifiedNameText) {
126133
List<String> segments = new ArrayList<>();
127134
int i = 0;
128135
int j = 0;
129136
int n = qualifiedNameText.length();
130137
boolean isDelimitable = true;
131138

139+
140+
if (qualifiedNameText.startsWith(GLOBAL_SCOPE_SYMBOL)) {
141+
// Add the specific GLOBAL_SCOPE_SYMBOL string to identify
142+
// a global scope qualifier segment.
143+
segments.add(GLOBAL_SCOPE_SYMBOL);
144+
i = 3;
145+
j = 3;
146+
}
147+
132148
while (j < n) {
133149
char c = qualifiedNameText.charAt(j);
134150
int delim = "\'\\:".indexOf(c);

0 commit comments

Comments
 (0)