Skip to content

Commit

Permalink
Merge pull request #903 from modelix/add-uid-for-INamedConcept
Browse files Browse the repository at this point in the history
fix(model-api): add UID for INamedConcept
  • Loading branch information
odzhychko authored Jul 16, 2024
2 parents 947a3ee + ca89726 commit fd173fb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ micrometer = "1.13.2"
dokka = "1.9.20"
detekt = "1.23.6"
xmlunit = "2.10.0"
kotest = "5.9.1"

[libraries]

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

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

kotest-assertions-coreJvm = { group = "io.kotest", name = "kotest-assertions-core-jvm", version = "5.9.1" }
kotest-assertions-core = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" }
kotest-assertions-coreJvm = { group = "io.kotest", name = "kotest-assertions-core-jvm", version.ref = "kotest" }
kotest-assertions-ktor = { group = "io.kotest.extensions", name = "kotest-assertions-ktor", version = "2.0.0" }

guava = { group = "com.google.guava", name = "guava", version = "33.2.1-jre" }
Expand Down
1 change: 1 addition & 0 deletions model-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kotlin {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotest.assertions.core)
}
}
val jvmMain by getting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ object BuiltinLanguages {
init { addConcept(this) }
}

object INamedConcept : SimpleConcept(conceptName = "INamedConcept") {
object INamedConcept : SimpleConcept(
conceptName = "INamedConcept",
is_abstract = true,
uid = "mps:ceab5195-25ea-4f22-9b92-103b95ca8c0c/1169194658468",
) {
init { addConcept(this) }
val name = SimpleProperty(
"name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ interface IConcept {
/**
* Checks if this concept is abstract.
*
* A concept is abstract if it is not designated to be instantiated directly.
*
* @return true if the concept is abstract, false otherwise
*/
fun isAbstract(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.modelix.model.api

import io.kotest.inspectors.forAll
import io.kotest.matchers.string.shouldStartWith
import kotlin.test.Test
import kotlin.test.assertEquals

Expand All @@ -41,4 +43,14 @@ class BuiltinLanguagesTest {
// They were only accessible by directly calling Model.modelImports for example.
assertEquals(3, childLinks.size)
}

@Test
fun allBuiltInLanguagesHaveMpsConceptId() {
val concepts = BuiltinLanguages.getAllLanguages()
.flatMap { it.getConcepts() }

concepts.forAll { concept: IConcept ->
concept.getUID().shouldStartWith("mps:")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ data class MPSConcept(val concept: SAbstractConceptAdapter) : IConcept {
}

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

Expand Down

0 comments on commit fd173fb

Please sign in to comment.