From cc36acc6a7002049eec6381b190202b393174493 Mon Sep 17 00:00:00 2001 From: Jan Wittler Date: Thu, 3 Nov 2022 14:18:06 +0100 Subject: [PATCH] cleanup ChangeRecorder --- .../composite/recording/ChangeRecorder.xtend | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/bundles/tools.vitruv.change.composite/src/tools/vitruv/change/composite/recording/ChangeRecorder.xtend b/bundles/tools.vitruv.change.composite/src/tools/vitruv/change/composite/recording/ChangeRecorder.xtend index b5a77631..d86c1e92 100644 --- a/bundles/tools.vitruv.change.composite/src/tools/vitruv/change/composite/recording/ChangeRecorder.xtend +++ b/bundles/tools.vitruv.change.composite/src/tools/vitruv/change/composite/recording/ChangeRecorder.xtend @@ -16,7 +16,6 @@ import tools.vitruv.change.atomic.EChange import tools.vitruv.change.atomic.EChangeIdManager import tools.vitruv.change.atomic.eobject.EObjectAddedEChange import tools.vitruv.change.atomic.eobject.EObjectSubtractedEChange -import tools.vitruv.change.atomic.feature.reference.UpdateReferenceEChange import tools.vitruv.change.atomic.uuid.UuidResolver import tools.vitruv.change.composite.description.TransactionalChange import tools.vitruv.change.composite.description.VitruviusChangeFactory @@ -55,7 +54,6 @@ class ChangeRecorder implements AutoCloseable { val NotificationToEChangeConverter converter val UuidResolver uuidResolver val EChangeIdManager eChangeIdManager - val Set existingObjects = new HashSet val Set toDesinfect = new HashSet val ResourceSet resourceSet @@ -72,13 +70,13 @@ class ChangeRecorder implements AutoCloseable { // We do not check the containment of the reference, because an element may be inserted into a non-containment // reference before inserting it into a containment reference so that the create change has to be added // for the insertion into the non-containment reference - var create = addedObject !== null && !existingObjects.contains(addedObject) + var create = addedObject !== null && !uuidResolver.hasUuid(addedObject) // Look if the new value has no resource or if it is a reference change, if the resource of the affected // object is the same. Otherwise, the create has to be handled by an insertion/reference in that resource, as // it can be potentially a reference to a third party model, for which no create shall be instantiated create = create && (addedObject.eResource === null || affectedObject === null || addedObject.eResource == affectedObject.eResource) - if(create) existingObjects += addedObject + if (create) uuidResolver.registerEObject(addedObject) return create; } @@ -96,7 +94,7 @@ class ChangeRecorder implements AutoCloseable { if (rootObjects += notifier) { notifier.recursively [ - if(it instanceof EObject) existingObjects.add(it) + if (it instanceof EObject) checkState(uuidResolver.hasUuid(it), "Existing object %s must have a UUID when added to recording", it) addAdapter() ] } @@ -130,7 +128,6 @@ class ChangeRecorder implements AutoCloseable { resultChanges = null val rootCopy = Set.copyOf(rootObjects) rootObjects.clear() - existingObjects.clear() rootCopy.forEach[recursively [removeAdapter()]] } @@ -336,15 +333,6 @@ class ChangeRecorder implements AutoCloseable { } else { converter.convert(new NotificationInfo(notification)) } - if (!changes.isEmpty) { - // Register any added object as existing, even if we are not recording - changes.forEach [ - if (it instanceof EObjectAddedEChange) { - existingObjects += newValue - if(it instanceof UpdateReferenceEChange) existingObjects += affectedEObject - } - ] - } return changes } @@ -355,7 +343,6 @@ class ChangeRecorder implements AutoCloseable { private def void finishLoadingResource(Resource resource) { currentlyLoadingResources -= resource resource.recursively [ - if(it instanceof EObject) existingObjects.add(it) addAdapter() ] }