diff --git a/CHANGELOG.md b/CHANGELOG.md index 089fcc5f7..4c2fba0ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix a compilation error with migration files when CREATE UNIQUE INDEX referenced by FOREIGN KEY (https://github.com/sqldelight/sql-psi/pull/732) - Fix insert statement exposes columns to a select statement when used as the row source (https://github.com/sqldelight/sql-psi/pull/750) - Add rules ANY and ALL for dialects to use as SqlTypes (https://github.com/sqldelight/sql-psi/pull/760) +- Update IntelliJ target to 2023.3.1 ## [0.7.3] - 2026-03-13 [0.7.3]: https://github.com/sqldelight/sql-psi/releases/tag/0.7.3 diff --git a/build.gradle b/build.gradle index bbf814e10..b0f5ec3ed 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +buildscript { + dependencies { + // https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/2062 + classpath(libs.serialization.json) + } +} + plugins { alias(libs.plugins.kotlinJvm) apply false alias(libs.plugins.spotless) diff --git a/core/build.gradle b/core/build.gradle index f08e2b5f3..c22252549 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.grammarkit.tasks.GenerateParserTask + plugins { alias(libs.plugins.kotlinJvm) alias(libs.plugins.grammarKitComposer) @@ -10,6 +12,14 @@ grammarKit { intellijRelease.set(libs.versions.ideaVersion) } +// Constructing CoreApplicationEnvironment on 233+ initializes DisabledPluginsState, which resolves +// PathManager.getConfigPath() and throws when there is no IDE installation to derive it from. +// Kotlin contains this same workaround: +// https://github.com/JetBrains/kotlin/blob/39a9b922d16293bcf7be79c5c7e98edbcf448964/compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt#L38-L53 +tasks.withType(GenerateParserTask).configureEach { + systemProperty('idea.config.path', 'some/non/existent/path') +} + sourceSets { main.java.srcDir(tasks.named("generateLexer").flatMap { it.targetOutputDir }) } diff --git a/environment/src/main/kotlin/com/alecstrong/sql/psi/core/SqlCoreEnvironment.kt b/environment/src/main/kotlin/com/alecstrong/sql/psi/core/SqlCoreEnvironment.kt index 6b0bb6426..848b984b9 100644 --- a/environment/src/main/kotlin/com/alecstrong/sql/psi/core/SqlCoreEnvironment.kt +++ b/environment/src/main/kotlin/com/alecstrong/sql/psi/core/SqlCoreEnvironment.kt @@ -9,11 +9,11 @@ import com.alecstrong.sql.psi.core.psi.SqlCreateVirtualTableStmt import com.intellij.core.CoreApplicationEnvironment import com.intellij.core.CoreProjectEnvironment import com.intellij.lang.MetaLanguage +import com.intellij.openapi.application.PathManager import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ContentIterator import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.roots.ProjectRootManager -import com.intellij.openapi.roots.impl.CustomEntityProjectModelInfoProvider import com.intellij.openapi.roots.impl.DirectoryIndex import com.intellij.openapi.roots.impl.DirectoryIndexImpl import com.intellij.openapi.roots.impl.ProjectFileIndexImpl @@ -35,10 +35,23 @@ import com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexImpl import java.nio.file.Path import kotlin.io.path.pathString import kotlin.reflect.KClass +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel private class ApplicationEnvironment { val disposable = Disposer.newDisposable() + init { + // Constructing CoreApplicationEnvironment on 233+ initializes DisabledPluginsState, which + // resolves PathManager.getConfigPath() and throws when there is no IDE installation to + // derive it from. Kotlin contains this same workaround: + // https://github.com/JetBrains/kotlin/blob/39a9b922d16293bcf7be79c5c7e98edbcf448964/compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt#L38-L53 + if (System.getProperty(PathManager.PROPERTY_CONFIG_PATH) == null) { + System.setProperty(PathManager.PROPERTY_CONFIG_PATH, "some/non/existent/path") + } + } + val coreApplicationEnvironment: CoreApplicationEnvironment = CoreApplicationEnvironment(disposable).apply { System.setProperty("ide.hide.excluded.files", "false") @@ -57,16 +70,13 @@ private class ApplicationEnvironment { WorkspaceFileIndexImpl.EP_NAME, WorkspaceFileIndexContributor::class.java, ) - CoreApplicationEnvironment.registerApplicationExtensionPoint( - CustomEntityProjectModelInfoProvider.EP, - CustomEntityProjectModelInfoProvider::class.java, - ) } } open class SqlCoreEnvironment(sourceFolders: List, dependencies: List) : AutoCloseable { private val fileIndex: CoreFileIndex + private val coroutineScope = CoroutineScope(SupervisorJob()) private val env = ApplicationEnvironment() protected val projectEnvironment = CoreProjectEnvironment(env.disposable, env.coreApplicationEnvironment) @@ -77,7 +87,7 @@ open class SqlCoreEnvironment(sourceFolders: List, dependencies: List, dependencies: List