-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bulk-model-sync): workaround removed and outdated resolveInfo af…
…ter import into MPS In projects, loading all libraries and plugins can significant time. This workaround enables to sync projects better that do not want to load all libraries and plugins. With this workaround, the `name` or `resolveInfo` property of a target is used as the `resoleInfo` property on a reference even if the concept of the target could not be fully loaded.
- Loading branch information
Showing
9 changed files
with
279 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ib/mps-test/src/test/kotlin/org/modelix/model/sync/bulk/lib/test/ResolveInfoUpdateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2024. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.modelix.model.sync.bulk.lib.test | ||
|
||
import kotlinx.serialization.json.Json | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.assertj.core.api.Assertions.linesOf | ||
import org.modelix.model.api.BuiltinLanguages | ||
import org.modelix.model.api.INode | ||
import org.modelix.model.data.ModelData | ||
import org.modelix.model.mpsadapters.MPSRepositoryAsNode | ||
import org.modelix.model.sync.bulk.ExistingAndExpectedNode | ||
import org.modelix.model.sync.bulk.asExported | ||
import org.modelix.mps.model.sync.bulk.MPSBulkSynchronizer | ||
import java.nio.file.Path | ||
|
||
class ResolveInfoUpdateTest : MPSTestBase() { | ||
|
||
fun `test resolve info is updated with name from INamedConcept (testdata ResolveInfoUpdateTest)`() { | ||
val exportedModuleJson = exportModuleJson() | ||
val modifiedModuleJson = exportedModuleJson.replace("referencedNodeA", "referencedNodeANewName") | ||
val modifiedModule: ModelData = Json.decodeFromString(modifiedModuleJson) | ||
|
||
val getModulesToImport = { sequenceOf(ExistingAndExpectedNode(getTestModule(), modifiedModule)) } | ||
MPSBulkSynchronizer.importModelsIntoRepository(mpsProject.repository, getTestModule(), false, getModulesToImport) | ||
|
||
assertThat(linesOf(getTestModuleXml())) | ||
.contains(""" <ref role="3SLt5I" node="3vHUMVfa0RY" resolve="referencedNodeANewName" />""") | ||
} | ||
|
||
fun `test resolve info is updated with resolveInfo from IResolveInfo (testdata ResolveInfoUpdateTest)`() { | ||
val exportedModuleJson = exportModuleJson() | ||
val modifiedModuleJson = exportedModuleJson.replace("referencedNodeC", "referencedNodeCNewName") | ||
val modifiedModule: ModelData = Json.decodeFromString(modifiedModuleJson) | ||
|
||
val getModulesToImport = { sequenceOf(ExistingAndExpectedNode(getTestModule(), modifiedModule)) } | ||
MPSBulkSynchronizer.importModelsIntoRepository(mpsProject.repository, getTestModule(), false, getModulesToImport) | ||
|
||
assertThat(linesOf(getTestModuleXml())) | ||
.contains(""" <ref role="3SLt5I" node="3vHUMVfa0RZ" resolve="referencedNodeCNewName" />""") | ||
} | ||
|
||
private fun getTestModule(): INode { | ||
var result: INode? = null | ||
mpsProject.repository.modelAccess.runReadAction { | ||
val repository = mpsProject.repository | ||
val repositoryNode = MPSRepositoryAsNode(repository) | ||
result = repositoryNode.getChildren(BuiltinLanguages.MPSRepositoryConcepts.Repository.modules) | ||
.single { it.getPropertyValue(BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name) == "NewSolution" } | ||
} | ||
return checkNotNull(result) | ||
} | ||
|
||
private fun getTestModuleXml(): Path { | ||
return projectDir.resolve("solutions/NewSolution/models/NewSolution.a_model.mps") | ||
} | ||
|
||
private fun exportModuleJson(): String { | ||
var result: String? = null | ||
mpsProject.repository.modelAccess.runReadAction { | ||
val module = getTestModule() | ||
val modelData = ModelData(root = module.asExported()) | ||
result = modelData.toJson() | ||
} | ||
return checkNotNull(result) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
bulk-model-sync-lib/mps-test/testdata/ResolveInfoUpdateTest/.mps/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Default ignored files | ||
/shelf/ | ||
/workspace.xml |
6 changes: 6 additions & 0 deletions
6
bulk-model-sync-lib/mps-test/testdata/ResolveInfoUpdateTest/.mps/migration.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project version="4"> | ||
<component name="MigrationProperties"> | ||
<entry key="project.baseline.version" value="211" /> | ||
</component> | ||
</project> |
8 changes: 8 additions & 0 deletions
8
bulk-model-sync-lib/mps-test/testdata/ResolveInfoUpdateTest/.mps/modules.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project version="4"> | ||
<component name="MPSProject"> | ||
<projectModules> | ||
<modulePath path="$PROJECT_DIR$/solutions/NewSolution/NewSolution.msd" folder="" /> | ||
</projectModules> | ||
</component> | ||
</project> |
18 changes: 18 additions & 0 deletions
18
...el-sync-lib/mps-test/testdata/ResolveInfoUpdateTest/solutions/NewSolution/NewSolution.msd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<solution name="NewSolution" uuid="471b29cb-3253-460b-9743-1e1443884a6b" moduleVersion="0" compileInMPS="true"> | ||
<models> | ||
<modelRoot contentPath="${module}" type="default"> | ||
<sourceRoot location="models" /> | ||
</modelRoot> | ||
</models> | ||
<facets> | ||
<facet type="java"> | ||
<classes generated="true" path="${module}/classes_gen" /> | ||
</facet> | ||
</facets> | ||
<sourcePath /> | ||
<languageVersions /> | ||
<dependencyVersions> | ||
<module reference="471b29cb-3253-460b-9743-1e1443884a6b(NewSolution)" version="0" /> | ||
</dependencyVersions> | ||
</solution> |
43 changes: 43 additions & 0 deletions
43
...-test/testdata/ResolveInfoUpdateTest/solutions/NewSolution/models/NewSolution.a_model.mps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<model ref="r:cd78e6ac-0e34-490a-9b49-e5643f948d6d(NewSolution.a_model)"> | ||
<persistence version="9" /> | ||
<languages> | ||
<use id="e2840528-cf1a-4707-9968-32c55e0e5b6c" name="NewLanguage" version="0" /> | ||
</languages> | ||
<imports /> | ||
<registry> | ||
<language id="ceab5195-25ea-4f22-9b92-103b95ca8c0c" name="jetbrains.mps.lang.core"> | ||
<concept id="1196978630214" name="jetbrains.mps.lang.core.structure.IResolveInfo" flags="ng" index="2Lv6Xg"> | ||
<property id="1196978656277" name="resolveInfo" index="2Lvdk3" /> | ||
</concept> | ||
<concept id="1169194658468" name="jetbrains.mps.lang.core.structure.INamedConcept" flags="ng" index="TrEIO"> | ||
<property id="1169194664001" name="name" index="TrG5h" /> | ||
</concept> | ||
</language> | ||
<language id="e2840528-cf1a-4707-9968-32c55e0e5b6c" name="NewLanguage"> | ||
<concept id="4030135827843012252" name="NewLanguage.structure.RootNode" flags="ng" index="3SLrQM"> | ||
<child id="4030135827843012255" name="referencedNode" index="3SLrQL" /> | ||
<child id="4030135827843012253" name="referencingNodes" index="3SLrQN" /> | ||
</concept> | ||
<concept id="4030135827842946229" name="NewLanguage.structure.ReferencingNode" flags="ng" index="3SMFYr"> | ||
<reference id="4030135827843004992" name="aReference" index="3SLt5I" /> | ||
</concept> | ||
<concept id="4030135827842946260" name="NewLanguage.structure.ReferencedNodeWithResolveInfo" flags="ng" index="3SMFZU" /> | ||
<concept id="4030135827842946256" name="NewLanguage.structure.ReferencedNodeWithName" flags="ng" index="3SMFZY" /> | ||
</language> | ||
</registry> | ||
<node concept="3SLrQM" id="3vHUMVfa5C_"> | ||
<node concept="3SMFYr" id="3vHUMVfa0RX" role="3SLrQN" > | ||
<ref role="3SLt5I" node="3vHUMVfa0RY" resolve="referencedNodeA" /> | ||
</node> | ||
<node concept="3SMFZY" id="3vHUMVfa0RY" role="3SLrQL"> | ||
<property role="TrG5h" value="referencedNodeA" /> | ||
</node> | ||
<node concept="3SMFZU" id="3vHUMVfa0RZ" role="3SLrQL"> | ||
<property role="2Lvdk3" value="referencedNodeC" /> | ||
</node> | ||
<node concept="3SMFYr" id="3vHUMVfa4pM" role="3SLrQN"> | ||
<ref role="3SLt5I" node="3vHUMVfa0RZ" resolve="referencedNodeC" /> | ||
</node> | ||
</node> | ||
</model> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters