I'm trying to use FIR to generate declarations but...
# compiler
z
I'm trying to use FIR to generate declarations but really struggling to get it working in the latest K2 plugin in IJ 2024.3.1. Even basic things like errors fail with classloader issues. Are these worth reporting issues over or is it more of a "3rd party plugins are not supported sorry" situation?
Copy code
java.lang.NoClassDefFoundError: org/jetbrains/kotlin/com/intellij/psi/PsiElement
	at dev.zacsweers.redacted.compiler.fir.FirRedactedErrors.<clinit>(FirRedactedErrors.kt:80)
	at dev.zacsweers.redacted.compiler.fir.FirRedactedDeclarationChecker.check(FirRedactedExtensionRegistrar.kt:195)
	at dev.zacsweers.redacted.compiler.fir.FirRedactedDeclarationChecker.check(FirRedactedExtensionRegistrar.kt:82)
	at org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckersDiagnosticComponent.visitRegularClass(DeclarationCheckersDiagnosticComponent.kt:245)
From https://github.com/ZacSweers/redacted-compiler-plugin/blob/ee2515a6356d815c7f56aea[…]kotlin/dev/zacsweers/redacted/compiler/fir/FirRedactedErrors.kt
j
The relocated types from IntelliJ are, unsurprisingly, not relocated when running in IntelliJ itself.
z
👀
getting farther but now a new one
Copy code
Caused by: java.lang.NullPointerException: Cannot invoke "kotlin.Lazy.getValue()" because "<local1>" is null
	at dev.zacsweers.redacted.compiler.fir.RedactedDiagnostics.getPsiElementClass(RedactedDiagnostics.kt:77)
	at dev.zacsweers.redacted.compiler.fir.RedactedDiagnostics.error0(RedactedDiagnostics.kt:94)
	at dev.zacsweers.redacted.compiler.fir.RedactedDiagnostics.<clinit>(RedactedDiagnostics.kt:30)
	... 91 more
moving it to be top-level worked 👍
h
Do you need to use PsiElement? The KtElement is not shaded and does not require any hacks.
d
I couldn't get
KtElement
to work but I've been meaning to try again since I don't remember what the problem was
Was probably holding it wrong