tjohnn
09/17/2025, 10:43 PMKotlinCoreEnvironment are now marked deprecated in the latest kotlin-compiler-embeddable and are to be removed from version 2.3+, is it safe to assume the reworked alternative will be available in version 2.3 or we should look for some other alternatives 😄?hfhbd
09/18/2025, 4:45 AMtjohnn
09/18/2025, 6:43 AMPsiManager.getInstance(KotlinCoreEnvieonment.project)), which in turn is needed for finding and parsing kotlin files (KtFile).tjohnn
09/18/2025, 6:48 AMdmitriy.novozhilov
09/18/2025, 6:57 AMKotlinCoreEnvironment eventually, in the context of removing the dependency on the intellij core from the compiler.
MockProject manually, without creating the whole environent:fun test() {
val disposable = Disposer.newDisposable()
val applicationEnvironment = JavaCoreApplicationEnvironment(disposable)
val projectEnvironment = JavaCoreProjectEnvironment(disposable, applicationEnvironment)
val manager = PsiManager.getInstance(projectEnvironment.project)
}tjohnn
09/18/2025, 7:36 AMin the context of removing the dependency on the intellij core from the compilerI see that
JavaCoreProjectEnvironment is under an **.intellij.core package, is there a chance it also depends on the intellij core dependency which you mentioned?dmitriy.novozhilov
09/18/2025, 7:55 AMtjohnn
09/18/2025, 9:17 AMJavaCoreApplicationEnvironment fails because <http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij.openapi.application.ApplicationManager.getApplication() returns nulldmitriy.novozhilov
09/18/2025, 9:32 AMDoes that mean I can't run it in a e.g stand-alone gradle task that runs independent of intellij infrastructure?Let me clarify on this. By "intellij infrastructure" I mean
intellij-core.jar which is a dependency of the kotlin compiler. It contains some basic services which are used by the real intellij, but they also could be run independently (and that's how kotlinc utilizes them).
The whole story with Project, CoreEnvironment and even PSI itself goes from this intellij-core, and by "getting rid of intellij" I meant removing this dependency and replacing all usages in the compiler with something else.
I tried your code but creation ofThat's very strange, becausefails becauseJavaCoreApplicationEnvironmentreturns null<http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij.openapi.application.ApplicationManager.getApplication()
JavaCoreApplicationEnvironment creates the application in the contstructor, it doesn't retrieve it. Could you please share the stacktrace of the exception and exact code you've run?dmitriy.novozhilov
09/18/2025, 9:34 AMorg.jetbrains.kotlin.kotlin-compiler.jar and it successfully passes.
class SomeTest {
@Test
fun someTest() {
val disposable = Disposer.newDisposable()
val applicationEnvironment = JavaCoreApplicationEnvironment(disposable)
val projectEnvironment = JavaCoreProjectEnvironment(disposable, applicationEnvironment)
val manager = PsiManager.getInstance(projectEnvironment.project)
val application = ApplicationManager.getApplication()
Assertions.assertNotNull(manager)
Assertions.assertNotNull(application)
}
}tjohnn
09/18/2025, 12:49 PM