Skip to content

Commit fd173fb

Browse files
author
Oleksandr Dzhychko
authored
Merge pull request #903 from modelix/add-uid-for-INamedConcept
fix(model-api): add UID for INamedConcept
2 parents 947a3ee + ca89726 commit fd173fb

File tree

6 files changed

+28
-2
lines changed

6 files changed

+28
-2
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ micrometer = "1.13.2"
3939
dokka = "1.9.20"
4040
detekt = "1.23.6"
4141
xmlunit = "2.10.0"
42+
kotest = "5.9.1"
4243

4344
[libraries]
4445

@@ -84,7 +85,8 @@ ktor-serialization-json = { group = "io.ktor", name = "ktor-serialization-kotlin
8485

8586
keycloak-authz-client = { group = "org.keycloak", name = "keycloak-authz-client", version = "25.0.1" }
8687

87-
kotest-assertions-coreJvm = { group = "io.kotest", name = "kotest-assertions-core-jvm", version = "5.9.1" }
88+
kotest-assertions-core = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" }
89+
kotest-assertions-coreJvm = { group = "io.kotest", name = "kotest-assertions-core-jvm", version.ref = "kotest" }
8890
kotest-assertions-ktor = { group = "io.kotest.extensions", name = "kotest-assertions-ktor", version = "2.0.0" }
8991

9092
guava = { group = "com.google.guava", name = "guava", version = "33.2.1-jre" }

model-api/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ kotlin {
3131
val commonTest by getting {
3232
dependencies {
3333
implementation(kotlin("test"))
34+
implementation(libs.kotest.assertions.core)
3435
}
3536
}
3637
val jvmMain by getting {

model-api/src/commonMain/kotlin/org/modelix/model/api/BuiltinLanguages.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ object BuiltinLanguages {
6868
init { addConcept(this) }
6969
}
7070

71-
object INamedConcept : SimpleConcept(conceptName = "INamedConcept") {
71+
object INamedConcept : SimpleConcept(
72+
conceptName = "INamedConcept",
73+
is_abstract = true,
74+
uid = "mps:ceab5195-25ea-4f22-9b92-103b95ca8c0c/1169194658468",
75+
) {
7276
init { addConcept(this) }
7377
val name = SimpleProperty(
7478
"name",

model-api/src/commonMain/kotlin/org/modelix/model/api/IConcept.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ interface IConcept {
5656
/**
5757
* Checks if this concept is abstract.
5858
*
59+
* A concept is abstract if it is not designated to be instantiated directly.
60+
*
5961
* @return true if the concept is abstract, false otherwise
6062
*/
6163
fun isAbstract(): Boolean

model-api/src/commonTest/kotlin/org/modelix/model/api/BuiltinLanguagesTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.modelix.model.api
1818

19+
import io.kotest.inspectors.forAll
20+
import io.kotest.matchers.string.shouldStartWith
1921
import kotlin.test.Test
2022
import kotlin.test.assertEquals
2123

@@ -41,4 +43,14 @@ class BuiltinLanguagesTest {
4143
// They were only accessible by directly calling Model.modelImports for example.
4244
assertEquals(3, childLinks.size)
4345
}
46+
47+
@Test
48+
fun allBuiltInLanguagesHaveMpsConceptId() {
49+
val concepts = BuiltinLanguages.getAllLanguages()
50+
.flatMap { it.getConcepts() }
51+
52+
concepts.forAll { concept: IConcept ->
53+
concept.getUID().shouldStartWith("mps:")
54+
}
55+
}
4456
}

mps-model-adapters/src/main/kotlin/org/modelix/model/mpsadapters/MPSConcept.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ data class MPSConcept(val concept: SAbstractConceptAdapter) : IConcept {
5454
}
5555

5656
override fun isAbstract(): Boolean {
57+
// In MPS `org.jetbrains.mps.openapi.language.SAbstractConcept.isAbstract`
58+
// returns `true` for abstract concepts and interface concepts.
59+
// See https://github.com/JetBrains/MPS/blob/78b81f56866370e227262000e597a211f885b9e6/core/kernel/source/jetbrains/mps/smodel/adapter/structure/concept/SConceptAdapterById.java#L54
60+
// This exactly matches with the definition of `IConcept.isAbstract`,
61+
// as such concepts are not designated to be instantiated directly.
5762
return concept.isAbstract
5863
}
5964

0 commit comments

Comments
 (0)