mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Intellij compatibility fixes (#2733)
* Set 2022.1.1 as base IJ version Stable AS is based on 2022.1.1 now, so we can drop supporting 2021.3 * Update IDE plugin target bytecode version to 11 When 2022.1 is used as a base for IDE plugin, inline functions from the platform & the bundled Kotlin plugin cannot be used unless target bytecode version is set to 11. * Update Intellij SDK Gradle plugin * Check editor is not disposed before showing preview toolbar #2663 * Add preview caret listener only to main editor
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("org.jetbrains.kotlin.jvm") version "1.5.10"
|
id("org.jetbrains.kotlin.jvm") version "1.5.10"
|
||||||
id("org.jetbrains.intellij") version "1.10.1"
|
id("org.jetbrains.intellij") version "1.12.0"
|
||||||
id("org.jetbrains.changelog") version "1.3.1"
|
id("org.jetbrains.changelog") version "1.3.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,11 +44,11 @@ tasks.buildSearchableOptions {
|
|||||||
tasks {
|
tasks {
|
||||||
// Set the compatibility versions to 1.8
|
// Set the compatibility versions to 1.8
|
||||||
withType<JavaCompile> {
|
withType<JavaCompile> {
|
||||||
sourceCompatibility = "1.8"
|
sourceCompatibility = "11"
|
||||||
targetCompatibility = "1.8"
|
targetCompatibility = "11"
|
||||||
}
|
}
|
||||||
withType<KotlinJvmCompile> {
|
withType<KotlinJvmCompile> {
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
kotlinOptions.jvmTarget = "11"
|
||||||
}
|
}
|
||||||
|
|
||||||
publishPlugin {
|
publishPlugin {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ deploy.version=0.1-SNAPSHOT
|
|||||||
plugin.channels=snapshots
|
plugin.channels=snapshots
|
||||||
# Intellij since-build should be updated directly in src/main/resources/META-INF/plugin.xml
|
# Intellij since-build should be updated directly in src/main/resources/META-INF/plugin.xml
|
||||||
# See https://jb.gg/intellij-platform-builds-list for available build versions.
|
# See https://jb.gg/intellij-platform-builds-list for available build versions.
|
||||||
plugin.verifier.ide.versions=2021.3, 2022.1, 2022.2
|
plugin.verifier.ide.versions=2022.1, 2022.2, 2022.3
|
||||||
|
|
||||||
platform.type=IC
|
platform.type=IC
|
||||||
platform.version=2021.3
|
platform.version=2022.1.1
|
||||||
platform.download.sources=true
|
platform.download.sources=true
|
||||||
|
|||||||
@@ -8,13 +8,17 @@ package org.jetbrains.compose.desktop.ide.preview
|
|||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||||
import com.intellij.openapi.actionSystem.DataContext
|
import com.intellij.openapi.actionSystem.DataContext
|
||||||
|
import com.intellij.openapi.diff.impl.DiffUtil
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.editor.event.CaretEvent
|
import com.intellij.openapi.editor.event.CaretEvent
|
||||||
import com.intellij.openapi.editor.event.CaretListener
|
import com.intellij.openapi.editor.event.CaretListener
|
||||||
import com.intellij.openapi.editor.toolbar.floating.AbstractFloatingToolbarProvider
|
import com.intellij.openapi.editor.toolbar.floating.AbstractFloatingToolbarProvider
|
||||||
import com.intellij.openapi.editor.toolbar.floating.FloatingToolbarComponent
|
import com.intellij.openapi.editor.toolbar.floating.FloatingToolbarComponent
|
||||||
|
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.testFramework.LightVirtualFileBase
|
||||||
import com.intellij.util.concurrency.AppExecutorUtil
|
import com.intellij.util.concurrency.AppExecutorUtil
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
|
|
||||||
class PreviewFloatingToolbarProvider : AbstractFloatingToolbarProvider(PREVIEW_EDITOR_TOOLBAR_GROUP_ID) {
|
class PreviewFloatingToolbarProvider : AbstractFloatingToolbarProvider(PREVIEW_EDITOR_TOOLBAR_GROUP_ID) {
|
||||||
override val autoHideable = false
|
override val autoHideable = false
|
||||||
@@ -22,7 +26,9 @@ class PreviewFloatingToolbarProvider : AbstractFloatingToolbarProvider(PREVIEW_E
|
|||||||
// todo: disable if not in Compose JVM module
|
// todo: disable if not in Compose JVM module
|
||||||
override fun register(dataContext: DataContext, component: FloatingToolbarComponent, parentDisposable: Disposable) {
|
override fun register(dataContext: DataContext, component: FloatingToolbarComponent, parentDisposable: Disposable) {
|
||||||
val editor = dataContext.getData(CommonDataKeys.EDITOR) ?: return
|
val editor = dataContext.getData(CommonDataKeys.EDITOR) ?: return
|
||||||
registerComponent(component, editor, parentDisposable)
|
if (isInsideMainKtEditor(editor)) {
|
||||||
|
registerComponent(component, editor, parentDisposable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerComponent(
|
private fun registerComponent(
|
||||||
@@ -50,11 +56,24 @@ internal class PreviewEditorToolbarVisibilityUpdater(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateVisibility() {
|
private fun updateVisibility() {
|
||||||
val parentPreviewFun = parentPreviewAtCaretOrNull(editor)
|
if (!editor.isDisposed) {
|
||||||
if (parentPreviewFun != null) {
|
val parentPreviewFun = parentPreviewAtCaretOrNull(editor)
|
||||||
toolbar.scheduleShow()
|
if (parentPreviewFun != null) {
|
||||||
} else {
|
toolbar.scheduleShow()
|
||||||
toolbar.scheduleHide()
|
} else {
|
||||||
|
toolbar.scheduleHide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isInsideMainKtEditor(editor: Editor): Boolean =
|
||||||
|
!DiffUtil.isDiffEditor(editor) && editor.isKtFileEditor()
|
||||||
|
|
||||||
|
private fun Editor.isKtFileEditor(): Boolean {
|
||||||
|
val documentManager = FileDocumentManager.getInstance()
|
||||||
|
val virtualFile = documentManager.getFile(document) ?: return false
|
||||||
|
return virtualFile !is LightVirtualFileBase
|
||||||
|
&& virtualFile.isValid
|
||||||
|
&& virtualFile.fileType == KotlinFileType.INSTANCE
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user