Skip to content

Commit

Permalink
MPS-37113: copy attributes on migrating closures
Browse files Browse the repository at this point in the history
  • Loading branch information
cdelabou committed Apr 19, 2024
1 parent 1539c81 commit a60f1fc
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@
<concept id="1138056143562" name="jetbrains.mps.lang.smodel.structure.SLinkAccess" flags="nn" index="3TrEf2">
<reference id="1138056516764" name="link" index="3Tt5mk" />
</concept>
<concept id="1138056282393" name="jetbrains.mps.lang.smodel.structure.SLinkListAccess" flags="nn" index="3Tsc0h">
<reference id="1138056546658" name="link" index="3TtcxE" />
</concept>
</language>
<language id="ceab5195-25ea-4f22-9b92-103b95ca8c0c" name="jetbrains.mps.lang.core">
<concept id="1133920641626" name="jetbrains.mps.lang.core.structure.BaseConcept" flags="ng" index="2VYdi">
Expand Down Expand Up @@ -596,7 +599,71 @@
</node>
</node>
</node>
<node concept="3clFbH" id="2OQsvxQCDYW" role="3cqZAp" />
<node concept="3clFbH" id="6_W72Wf_OSH" role="3cqZAp" />
<node concept="3SKdUt" id="6_W72Wf_OYN" role="3cqZAp">
<node concept="1PaTwC" id="6_W72Wf_OYO" role="1aUNEU">
<node concept="3oM_SD" id="6_W72Wf_PlI" role="1PaTwD">
<property role="3oM_SC" value="Copy" />
</node>
<node concept="3oM_SD" id="6_W72Wf_PmY" role="1PaTwD">
<property role="3oM_SC" value="not" />
</node>
<node concept="3oM_SD" id="6_W72Wf_PEK" role="1PaTwD">
<property role="3oM_SC" value="needed:" />
</node>
<node concept="3oM_SD" id="6_W72Wf_QbQ" role="1PaTwD">
<property role="3oM_SC" value="being" />
</node>
<node concept="3oM_SD" id="6_W72Wf_QwP" role="1PaTwD">
<property role="3oM_SC" value="replaced" />
</node>
</node>
</node>
<node concept="3clFbF" id="6_W72Wf_ebb" role="3cqZAp">
<node concept="2OqwBi" id="6_W72Wf_rVd" role="3clFbG">
<node concept="2OqwBi" id="6_W72Wf_ePN" role="2Oq$k0">
<node concept="37vLTw" id="6_W72Wf_eb9" role="2Oq$k0">
<ref role="3cqZAo" node="2OQsvxQLcOd" resolve="newParam" />
</node>
<node concept="3Tsc0h" id="6_W72Wf_fNB" role="2OqNvi">
<ref role="3TtcxE" to="tpck:4uZwTti3__2" resolve="smodelAttribute" />
</node>
</node>
<node concept="X8dFx" id="6_W72Wf_w0K" role="2OqNvi">
<node concept="2OqwBi" id="6_W72Wf_k6e" role="25WWJ7">
<node concept="37vLTw" id="6_W72Wf_j2Y" role="2Oq$k0">
<ref role="3cqZAo" node="6QWJOWBDarl" resolve="it" />
</node>
<node concept="3Tsc0h" id="6_W72Wf_kYl" role="2OqNvi">
<ref role="3TtcxE" to="tpck:4uZwTti3__2" resolve="smodelAttribute" />
</node>
</node>
</node>
</node>
</node>
<node concept="3clFbF" id="6_W72Wf__xd" role="3cqZAp">
<node concept="2OqwBi" id="6_W72Wf_EPd" role="3clFbG">
<node concept="2OqwBi" id="6_W72Wf_Ady" role="2Oq$k0">
<node concept="37vLTw" id="6_W72Wf__xb" role="2Oq$k0">
<ref role="3cqZAo" node="2OQsvxQLcOd" resolve="newParam" />
</node>
<node concept="3Tsc0h" id="6_W72Wf_BrO" role="2OqNvi">
<ref role="3TtcxE" to="tpee:hiAJF2X" resolve="annotation" />
</node>
</node>
<node concept="X8dFx" id="6_W72Wf_IBX" role="2OqNvi">
<node concept="2OqwBi" id="6_W72Wf_Kpp" role="25WWJ7">
<node concept="37vLTw" id="6_W72Wf_Ja1" role="2Oq$k0">
<ref role="3cqZAo" node="6QWJOWBDarl" resolve="it" />
</node>
<node concept="3Tsc0h" id="6_W72Wf_LNr" role="2OqNvi">
<ref role="3TtcxE" to="tpee:hiAJF2X" resolve="annotation" />
</node>
</node>
</node>
</node>
</node>
<node concept="3clFbH" id="6_W72Wf_rxr" role="3cqZAp" />
<node concept="3SKdUt" id="2OQsvxQCFfR" role="3cqZAp">
<node concept="1PaTwC" id="2OQsvxQCFfS" role="1aUNEU">
<node concept="3oM_SD" id="2OQsvxQCFxK" role="1PaTwD">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-5tap1pckzar8o3mh25a4ouxzlkyjzsn">
<product version="3" modelHash="6n5fwue42i9yukqlv889pjz5g3cnu5e">
<files names="Language.java" />
</product>

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<product version="3" modelHash="-9gk86eup9tr3qylcdohkwtjhsjge5q9">
<product version="3" modelHash="ai2jiltau4x8xjltizmfiyyvwx68cus">
<files names="ConvertDeprecatedCollectionsOperations.java:DiscardSmartClosureParameterDeclaration.java:MigrationDescriptor.java" />
</product>

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));

Expand Down Expand Up @@ -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");
}
}
Loading

0 comments on commit a60f1fc

Please sign in to comment.