From 16fbfc69702db15d7f6eb8cd1fedf570222d52fb Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Thu, 1 Feb 2024 13:19:39 +0100 Subject: [PATCH] fix: binary incompatibility in ModelServerConnection --- mps-legacy-sync-plugin/build.gradle.kts | 5 ++++- .../mpsplugin/AllowedBinaryIncompatibility.kt | 16 ++++++++++++++++ .../model/mpsplugin/ModelServerConnection.kt | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/AllowedBinaryIncompatibility.kt diff --git a/mps-legacy-sync-plugin/build.gradle.kts b/mps-legacy-sync-plugin/build.gradle.kts index 0635ebe6..61cd61bf 100644 --- a/mps-legacy-sync-plugin/build.gradle.kts +++ b/mps-legacy-sync-plugin/build.gradle.kts @@ -116,7 +116,10 @@ tasks { val checkBinaryCompatibility by registering { group = "verification" doLast { - val ignoredFiles = setOf("META-INF/MANIFEST.MF") + val ignoredFiles = setOf( + "META-INF/MANIFEST.MF", + "org/modelix/model/mpsplugin/AllowedBinaryIncompatibilityKt.class" + ) fun loadEntries(fileName: String) = rootProject.layout.buildDirectory .dir("binary-compatibility") .dir(project.name) diff --git a/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/AllowedBinaryIncompatibility.kt b/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/AllowedBinaryIncompatibility.kt new file mode 100644 index 00000000..56dfbf90 --- /dev/null +++ b/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/AllowedBinaryIncompatibility.kt @@ -0,0 +1,16 @@ +package org.modelix.model.mpsplugin + +import com.intellij.openapi.project.ProjectManager +import com.intellij.openapi.project.ProjectManagerListener +import com.intellij.util.messages.MessageBus +import com.intellij.util.messages.MessageBusConnection +import com.intellij.util.messages.Topic + +/** + * This file contains all API calls that lead to a difference in the compiled bytecode. + * This class file is ignored during the binary compatibility check. + * This file should contain as little code as possible. + */ + +internal fun MessageBus.connectToMessageBus(): MessageBusConnection = connect() +internal fun getProjectManagerTopic(): Topic = ProjectManager.TOPIC diff --git a/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/ModelServerConnection.kt b/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/ModelServerConnection.kt index 34ce8d37..316ed8dd 100644 --- a/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/ModelServerConnection.kt +++ b/mps-legacy-sync-plugin/src/main/java/org/modelix/model/mpsplugin/ModelServerConnection.kt @@ -72,9 +72,9 @@ class ModelServerConnection @JvmOverloads constructor(baseUrl: String, providedH if (LOG.isDebugEnabled) { LOG.debug("ModelServerConnection.init(" + baseUrl + ")") } - messageBusConnection = ApplicationManager.getApplication().messageBus.connect() + messageBusConnection = ApplicationManager.getApplication().messageBus.connectToMessageBus() messageBusConnection.subscribe( - ProjectManager.TOPIC, + getProjectManagerTopic(), object : ProjectManagerListener { override fun projectClosing(closingProject: Project) { for (closingProjectBinding: ProjectBinding? in Sequence.fromIterable(MapSequence.fromMap(bindings).values)