Skip to content

Commit b9f3388

Browse files
committed
ST6RI-811 Gave a deterministic ordering to implicit general types.
1 parent 27cfe6b commit b9f3388

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

org.omg.sysml.interactive/.launch/SysML Interactive Library Index Generator.launch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="&quot;${workspace_loc:/SysML-v2-Pilot-Implementation/sysml.library}&quot;"/>
1818
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.omg.sysml.interactive"/>
1919
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
20-
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="C:\Users\GatiL\Documents\git\SysML-v2-Pilot-Implementation\org.omg.sysml.interactive\.launch"/>
20+
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:sysml.library}"/>
2121
</launchConfiguration>

org.omg.sysml/src/org/omg/sysml/adapter/TypeAdapter.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.ArrayList;
2525
import java.util.Collection;
2626
import java.util.Collections;
27+
import java.util.Comparator;
2728
import java.util.HashMap;
2829
import java.util.HashSet;
2930
import java.util.List;
@@ -188,7 +189,16 @@ public boolean isImplicitGeneralTypesEmpty() {
188189
}
189190

190191
public Collection<EClass> getImplicitGeneralTypeKinds() {
191-
return implicitGeneralTypes.keySet();
192+
// Sort keys, to ensure a deterministic ordering of implied specializations
193+
// for implicit general types.
194+
List<EClass> keyList = new ArrayList<>(implicitGeneralTypes.keySet());
195+
Collections.sort(keyList, new Comparator<EClass>() {
196+
@Override
197+
public int compare(EClass c1, EClass c2) {
198+
return Integer.compare(c1.getClassifierID(), c2.getClassifierID());
199+
}
200+
});
201+
return keyList;
192202
}
193203

194204
public void forEachImplicitBindingConnector(Consumer<BindingConnector> consumer) {
@@ -211,13 +221,15 @@ public void forEachImplicitBindingConnector(BiConsumer<BindingConnector, EClass>
211221

212222
public List<Type> getImplicitGeneralTypes() {
213223
computeImplicitGeneralTypes();
214-
return implicitGeneralTypes.values().stream().
224+
225+
return getImplicitGeneralTypeKinds().stream().
226+
map(implicitGeneralTypes::get).
215227
flatMap(Collection::stream).
216228
collect(Collectors.toList());
217229
}
218230

219231
public List<Type> getImplicitGeneralTypes(EClass eClass) {
220-
return implicitGeneralTypes.keySet().stream().
232+
return getImplicitGeneralTypeKinds().stream().
221233
filter(eClass::isSuperTypeOf).
222234
flatMap(keyClass->getImplicitGeneralTypesOnly(keyClass).stream()).
223235
collect(Collectors.toList());
@@ -258,7 +270,7 @@ public void removeImplicitGeneralType(EClass eClass) {
258270
}
259271

260272
public void forEachImplicitGeneralType(BiConsumer<EClass, Type> action) {
261-
for (EClass eClass : implicitGeneralTypes.keySet()) {
273+
for (EClass eClass : getImplicitGeneralTypeKinds()) {
262274
for (Type supertype : implicitGeneralTypes.get(eClass)) {
263275
action.accept(eClass, supertype);
264276
}

sysml.library/.index.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92131,13 +92131,15 @@
9213192131
"dispatchScope",
9213292132
"done",
9213392133
"enactedPerformances",
92134+
"endShot",
9213492135
"envelopingShapes",
9213592136
"immediatePredecessors",
9213692137
"immediateSuccessors",
9213792138
"incomingTransferSort",
9213892139
"incomingTransfers",
9213992140
"incomingTransfersToSelf",
9214092141
"innerSpaceDimension",
92142+
"innerSpaceOccurrences",
9214192143
"intersectionsOf",
9214292144
"involvingPerformances",
9214392145
"isClosed",
@@ -92167,6 +92169,7 @@
9216792169
"shorterOccurrence",
9216892170
"snapshotOf",
9216992171
"snapshots",
92172+
"spaceBoundary",
9217092173
"spaceBoundaryOf",
9217192174
"spaceEnclosedOccurrences",
9217292175
"spaceInterior",
@@ -92179,6 +92182,7 @@
9217992182
"spaceTimeEnclosedOccurrences",
9218092183
"spaceTimeEnclosedPoints",
9218192184
"start",
92185+
"startShot",
9218292186
"structuredSpaceBoundary",
9218392187
"subitems",
9218492188
"subobjects",
@@ -92284,13 +92288,15 @@
9228492288
"dispatchScope",
9228592289
"done",
9228692290
"enactedPerformances",
92291+
"endShot",
9228792292
"envelopingShapes",
9228892293
"immediatePredecessors",
9228992294
"immediateSuccessors",
9229092295
"incomingTransferSort",
9229192296
"incomingTransfers",
9229292297
"incomingTransfersToSelf",
9229392298
"innerSpaceDimension",
92299+
"innerSpaceOccurrences",
9229492300
"intersectionsOf",
9229592301
"involvingPerformances",
9229692302
"isClosed",
@@ -92320,6 +92326,7 @@
9232092326
"shorterOccurrence",
9232192327
"snapshotOf",
9232292328
"snapshots",
92329+
"spaceBoundary",
9232392330
"spaceBoundaryOf",
9232492331
"spaceEnclosedOccurrences",
9232592332
"spaceInterior",
@@ -92332,6 +92339,7 @@
9233292339
"spaceTimeEnclosedOccurrences",
9233392340
"spaceTimeEnclosedPoints",
9233492341
"start",
92342+
"startShot",
9233592343
"structuredSpaceBoundary",
9233692344
"subitems",
9233792345
"subobjects",
@@ -278567,5 +278575,5 @@
278567278575
"withoutOccurrences"
278568278576
]
278569278577
},
278570-
"checksum": "62c9b321ce3252a9f3a94985874041a1be697db73cd6d2fea730ac97bd03d2e1"
278578+
"checksum": "18da3df101a78979cf8b437b6260a48eae8cbfee0c54460bb70e59dead06a524"
278571278579
}

0 commit comments

Comments
 (0)