-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mps-legacy-sync-plugin): use legacy plugin parts
This ensures that persisted binding configuration is loaded when a project is opened. Also, minor bugs where fixed that were discovered in tests during initialization and dispose of project plugin parts.
- Loading branch information
Oleksandr Dzhychko
committed
Mar 5, 2024
1 parent
d9bcc94
commit 8fb19c8
Showing
14 changed files
with
277 additions
and
21 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
17 changes: 15 additions & 2 deletions
17
...legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/history/CloudRootTreeNode.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
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
36 changes: 36 additions & 0 deletions
36
mps-legacy-sync-plugin/src/main/kotlin/org/modelix/mps/sync/ModelSyncProjectService.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,36 @@ | ||
/* | ||
* Copyright (c) 2023. | ||
* | ||
* 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.mps.sync | ||
|
||
import com.intellij.openapi.Disposable | ||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.project.Project | ||
import org.modelix.model.mpsplugin.plugin.Mpsplugin_ProjectPlugin | ||
|
||
@Service(Service.Level.PROJECT) | ||
class ModelSyncProjectService(val project: Project) : Disposable { | ||
|
||
private val legacyProjectPluginPart = Mpsplugin_ProjectPlugin() | ||
|
||
init { | ||
legacyProjectPluginPart.init(project) | ||
} | ||
|
||
override fun dispose() { | ||
legacyProjectPluginPart.dispose() | ||
} | ||
} |
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
85 changes: 85 additions & 0 deletions
85
mps-legacy-sync-plugin/src/test/kotlin/PersistedBindingsLoadingTest.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,85 @@ | ||
/* | ||
* Copyright (c) 2023. | ||
* | ||
* 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. | ||
*/ | ||
|
||
import io.ktor.client.request.parameter | ||
import io.ktor.client.request.post | ||
import io.ktor.http.appendPathSegments | ||
import io.ktor.http.takeFrom | ||
import jetbrains.mps.smodel.SModelId | ||
import org.modelix.model.api.BuiltinLanguages | ||
import org.modelix.model.client2.ModelClientV2 | ||
import org.modelix.model.mpsplugin.ModelServerConnections | ||
import org.modelix.model.mpsplugin.SModuleUtils | ||
import java.util.UUID | ||
|
||
class PersistedBindingsLoadingTest : SyncPluginTestBase("projectWithPersistedBindings") { | ||
|
||
fun `test persisted bindings are loaded initially`() = runTestWithSyncService { | ||
// Arrange | ||
delayUntil { | ||
val modelServer = ModelServerConnections.instance.modelServers | ||
.firstOrNull() | ||
if (modelServer == null) { | ||
return@delayUntil false | ||
} | ||
return@delayUntil modelServer.getRootBindings().isNotEmpty() | ||
} | ||
|
||
// Act | ||
val existingSolution = mpsProject.projectModules.single() | ||
writeAction { | ||
SModuleUtils.createModel( | ||
existingSolution, | ||
"my.wonderful.brandnew.modelInExistingModule", | ||
SModelId.regular(UUID.fromString("1c22f2f9-f1f3-45f8-8f4b-69b248928af5")), | ||
) | ||
} | ||
|
||
// Assert | ||
delayUntil { | ||
val dataOnServer = readDumpFromServer(defaultBranchRef) | ||
val moduleData = dataOnServer.children.single() | ||
val models = moduleData.children.filter { it.role == "models" } | ||
models.size == 2 | ||
} | ||
|
||
// XXX Project bindings do not close opened model server connections, | ||
// because in the meantime they might be used by other project bindings. | ||
// This should be solved by the new plugin. | ||
val modelServers = ModelServerConnections.instance.modelServers.toList() | ||
modelServers.forEach { | ||
ModelServerConnections.instance.removeModelServer(it) | ||
} | ||
} | ||
|
||
override suspend fun postModelServerSetup() { | ||
val moduleConcept = BuiltinLanguages.MPSRepositoryConcepts.Module | ||
httpClient.post { | ||
url { | ||
takeFrom(baseUrl) | ||
appendPathSegments("repositories", "${defaultBranchRef.repositoryId}", "init") | ||
parameter("useRoleIds", "false") | ||
} | ||
} | ||
ModelClientV2.builder().url(baseUrl).client(httpClient).build().use { client -> | ||
client.init() | ||
client.runWrite(defaultBranchRef) { root -> | ||
val module = root.addNewChild("modules", -1, moduleConcept) | ||
module.setPropertyValue("name", "NewSolution") | ||
} | ||
} | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
mps-legacy-sync-plugin/testdata/projectWithPersistedBindings/.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 |
15 changes: 15 additions & 0 deletions
15
mps-legacy-sync-plugin/testdata/projectWithPersistedBindings/.mps/cloudResources.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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project version="4"> | ||
<component name="CloudResources"> | ||
<option name="mappedModules"> | ||
<set> | ||
<option value="http://localhost/default#NewSolution" /> | ||
</set> | ||
</option> | ||
<option name="modelServers"> | ||
<set> | ||
<option value="http://localhost/" /> | ||
</set> | ||
</option> | ||
</component> | ||
</project> |
6 changes: 6 additions & 0 deletions
6
mps-legacy-sync-plugin/testdata/projectWithPersistedBindings/.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> |
Oops, something went wrong.