From a60f1fc84eb2404bf1f5fe6f7a819b1b0bdd2762 Mon Sep 17 00:00:00 2001 From: Clement de La Bourdonnaye Date: Wed, 10 Apr 2024 11:16:37 +0200 Subject: [PATCH] MPS-37113: copy attributes on migrating closures --- .../languageAccessories/migration.mps | 69 ++++++++- .../mps/baseLanguage/collections/generated | 2 +- .../collections/migration/generated | 2 +- ...scardSmartClosureParameterDeclaration.java | 9 +- .../collections/migration/trace.info | 140 +++++++++--------- 5 files changed, 151 insertions(+), 71 deletions(-) diff --git a/languages/baseLanguage/collections/languageAccessories/migration.mps b/languages/baseLanguage/collections/languageAccessories/migration.mps index 6c608396c294..d91349112c99 100644 --- a/languages/baseLanguage/collections/languageAccessories/migration.mps +++ b/languages/baseLanguage/collections/languageAccessories/migration.mps @@ -191,6 +191,9 @@ + + + @@ -596,7 +599,71 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/generated b/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/generated index baa16c002ebc..cb1e3cf276ed 100644 --- a/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/generated +++ b/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/generated @@ -1,5 +1,5 @@ - + diff --git a/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/migration/generated b/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/migration/generated index acdbd4c20948..de468e7cfd62 100644 --- a/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/migration/generated +++ b/languages/baseLanguage/collections/source_gen.caches/jetbrains/mps/baseLanguage/collections/migration/generated @@ -1,5 +1,5 @@ - + diff --git a/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/DiscardSmartClosureParameterDeclaration.java b/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/DiscardSmartClosureParameterDeclaration.java index c759d00438f9..761714c47982 100644 --- a/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/DiscardSmartClosureParameterDeclaration.java +++ b/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/DiscardSmartClosureParameterDeclaration.java @@ -14,14 +14,15 @@ import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.internal.collections.runtime.ListSequence; +import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import org.jetbrains.mps.openapi.language.SAbstractConcept; -import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.lang.migration.runtime.base.Problem; import jetbrains.mps.lang.migration.runtime.base.NotMigratedNode; import jetbrains.mps.lang.migration.runtime.base.MigrationScriptReference; import org.jetbrains.mps.openapi.language.SConcept; import org.jetbrains.mps.openapi.language.SProperty; +import org.jetbrains.mps.openapi.language.SContainmentLink; import org.jetbrains.mps.openapi.language.SReferenceLink; public class DiscardSmartClosureParameterDeclaration extends MigrationScriptBase { @@ -47,6 +48,10 @@ public void doExecute(final SModule m) { SPropertyOperations.assign(newParam, PROPS.name$MnvL, SPropertyOperations.getString(it, PROPS.name$MnvL)); SPropertyOperations.assign(newParam, PROPS.isFinal$gvTP, SPropertyOperations.getBoolean(it, PROPS.isFinal$gvTP)); + // Copy not needed: being replaced + ListSequence.fromList(SLinkOperations.getChildren(newParam, LINKS.smodelAttribute$KJ43)).addSequence(ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.smodelAttribute$KJ43))); + ListSequence.fromList(SLinkOperations.getChildren(newParam, LINKS.annotation$K49I)).addSequence(ListSequence.fromList(SLinkOperations.getChildren(it, LINKS.annotation$K49I))); + // Update references ListSequence.fromList(SNodeOperations.getNodeDescendants(SNodeOperations.as(SNodeOperations.getParent(it), CONCEPTS.ClosureLiteral$rp), CONCEPTS.VariableReference$TC, false, new SAbstractConcept[]{})).where((desc) -> SLinkOperations.getTarget(desc, LINKS.variableDeclaration$N1XG) == it).visitAll((desc) -> SLinkOperations.setTarget(desc, LINKS.variableDeclaration$N1XG, newParam)); @@ -87,6 +92,8 @@ private static final class PROPS { } private static final class LINKS { + /*package*/ static final SContainmentLink smodelAttribute$KJ43 = MetaAdapterFactory.getContainmentLink(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute"); + /*package*/ static final SContainmentLink annotation$K49I = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x114a6be947aL, 0x114a6beb0bdL, "annotation"); /*package*/ static final SReferenceLink variableDeclaration$N1XG = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration"); } } diff --git a/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/trace.info b/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/trace.info index 8455183908ec..7e86cc535412 100644 --- a/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/trace.info +++ b/languages/baseLanguage/collections/source_gen/jetbrains/mps/baseLanguage/collections/migration/trace.info @@ -143,85 +143,91 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + - - + + + + + + + + - - - - - + + - - - - - + + + + +