File tree Expand file tree Collapse file tree 3 files changed +20
-15
lines changed
mps-model-adapters-plugin/src/test/kotlin/org/modelix/model/mpsadapters Expand file tree Collapse file tree 3 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,11 @@ class ChangePropertyTest : MpsAdaptersTestBase("SimpleProject") {
28
28
29
29
val repositoryNode: INode = MPSRepositoryAsNode (mpsProject.repository)
30
30
31
- writeActionOnEdt {
31
+ runCommandOnEDT {
32
32
val module = repositoryNode.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Repository .modules)
33
33
.single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1" }
34
- val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models).single()
34
+ val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models)
35
+ .single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1.model1" }
35
36
val rootNode = model.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Model .rootNodes).single()
36
37
assertEquals(" Class1" , rootNode.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name))
37
38
rootNode.setPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name, " MyRenamedClass" )
Original file line number Diff line number Diff line change @@ -97,18 +97,18 @@ abstract class MpsAdaptersTestBase(val testDataName: String?) : UsefulTestCase()
97
97
return checkNotNull(ProjectHelper .fromIdeaProject(project)) { " MPS project not loaded" }
98
98
}
99
99
100
- protected fun <R > writeAction (body : () -> R ): R {
101
- return mpsProject.modelAccess.computeWriteAction(body)
102
- }
103
-
104
- protected fun <R > writeActionOnEdt (body : () -> R ): R {
105
- return onEdt { writeAction { body() } }
106
- }
107
-
108
- protected fun <R > onEdt (body : () -> R ): R {
100
+ protected fun <R > runCommandOnEDT (body : () -> R ): R {
109
101
var result: R ? = null
110
- ThreadUtils .runInUIThreadAndWait {
111
- result = body()
102
+ val exception = ThreadUtils .runInUIThreadAndWait {
103
+ mpsProject.modelAccess.executeCommand {
104
+ result = body()
105
+ }
106
+ }
107
+ if (exception != null ) {
108
+ throw exception
109
+ }
110
+ checkNotNull(result) {
111
+ " The result was null even those no exception was thrown."
112
112
}
113
113
return result as R
114
114
}
Original file line number Diff line number Diff line change 16
16
17
17
package org.modelix.model.mpsadapters
18
18
19
+ import org.junit.Ignore
19
20
import org.modelix.model.api.BuiltinLanguages
20
21
import org.modelix.model.api.ConceptReference
21
22
import org.modelix.model.api.INode
22
23
import org.modelix.model.api.IReplaceableNode
23
24
25
+ @Ignore(" Replacing a node through MPS-model-adapters is broken. See MODELIX-920" )
24
26
class ReplaceNodeTest : MpsAdaptersTestBase (" SimpleProject" ) {
25
27
26
28
fun testReplaceNode () {
@@ -30,10 +32,12 @@ class ReplaceNodeTest : MpsAdaptersTestBase("SimpleProject") {
30
32
31
33
val repositoryNode: INode = MPSRepositoryAsNode (mpsProject.repository)
32
34
33
- writeActionOnEdt {
35
+ runCommandOnEDT {
34
36
val module = repositoryNode.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Repository .modules)
35
37
.single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1" }
36
- val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models).single()
38
+ val model = module.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Module .models)
39
+ .single { it.getPropertyValue(BuiltinLanguages .jetbrains_mps_lang_core.INamedConcept .name) == " Solution1.model1" }
40
+
37
41
val rootNode = model.getChildren(BuiltinLanguages .MPSRepositoryConcepts .Model .rootNodes).single() as IReplaceableNode
38
42
39
43
val oldProperties = rootNode.getAllProperties().toSet()
You can’t perform that action at this time.
0 commit comments