can I somehow convert IrClass to PsiClass?
# compiler
s
can I somehow convert IrClass to PsiClass?
d
You can access PSI of class via source element (
val psi = irClass.sourceElement?.getPsi()
), but this will suite only for source based classes (there won't be any PSI for library classes or synthetic classes, generated by plugins) Why do you want this?
s
@dmitriy.novozhilov I'm using IrGenerationExtension and I have only access to IrClass. What extension should I use to do something like annotation processing? I won't generate any bytecode
one bad thing about this extension is that I don't have access to code comments and it might be useful in my usecase
d
Take a look at google KSP https://github.com/google/ksp
Or you can use
AnalysisHandlerExtension
s
how is KSP different to compiler plugin? the only difference is that I cannot create bytecode?
d
KSP is a tool for creating annotation processor like compiler plugins which does not expose compiler internals Check README in KSP repo for more details
s
thanks. I think I will stick with compiler plugin for now. I don't need to generate bytecode now, but maybe later. so it would be good to learn that.
thanks for your help
s
IR extension is mostly used to generate code, so if you want to add custom checks/logic, you might want to look into DeclarationChecker, which gives you a PSI element for additional checks.
s
@shikasd thx