Esya Bekasova
10/11/2026, 3:39 PMcom.intellij.psi.PsiElement): IDE error highlighting works fine, but the Gradle build crashes with NoClassDefFoundError: PsiElement inside FIR.
• With (using shaded org.jetbrains.kotlin.com.intellij.psi.PsiElement): The Gradle build succeeds, but IDE in-editor highlighting completely breaks.
(Toggling Build and run between Gradle and IntelliJ IDEA didn't make any difference).
To break the loop, I came up with this dynamic fallback hack:
object LapisDiagnostics : KtDiagnosticsContainer() {
// val FACTORY by error1org.jetbrains.kotlin.com.intellij.psi.PsiElement, String(SourceElementPositioningStrategies.DECLARATION_NAME)
val FACTORY = KtDiagnosticFactory1String(
name = simpleNameOfLapisDiagnostics(),
severity = Severity.ERROR,
defaultPositioningStrategy = SourceElementPositioningStrategies.DECLARATION_NAME,
psiType = runCatching { com.intellij.psi.PsiElement::class }
.getOrNull() ?: org.jetbrains.kotlin.com.intellij.psi.PsiElement::class,
rendererFactory = getRendererFactory(),
)
}
Combined with adding both as compileOnly so the IDE can resolve both paths:
dependencies {
compileOnly(libs.kotlin.compiler)
compileOnly(libs.kotlin.compiler.embeddable)
}
Now both the IDE and the build are happy, but it feels sketchy. Is this dynamic resolution safe to keep as a workaround, or am I setting myself up for hidden K2 pipeline issues down the road? 🤔
P.S. I looked at how other plugins handle this, and most people simply import the shaded org.jetbrains.kotlin.com.intellij.psi.PsiElement without overthinking it. Now I'm left wondering: do they just live with broken IDE highlighting, or does it actually work for them and something is uniquely broken in my setup? 😅dmitriy.novozhilov
10/11/2026, 4:01 PMEsya Bekasova
10/11/2026, 4:09 PMerror1KtElement, String, dropped the extra embeddable dependency, and everything works flawlessly now, both in the IDE and during the build. Appreciate the lightning-fast help!Youssef Shoaib [MOD]
10/12/2026, 8:47 AMcompileOnly(kotlin("compiler-embeddable")) and remove the unshaded compiler, but I'd stick with KtElement, especially because internal-test-framework is unshaded IIUC, so it may not like that