how PsiAugmentProvider return psiClass ?



I want to implement lombok builder. I have tried many ways, but I have no clue

I have implemented adding fields

I don't know LightPsiClassBuilder  if it can be realized

override fun <Psi : PsiElement> getAugments(
psiElement: PsiElement,
type: Class<Psi>,
nameHint: String?
): MutableList<Psi> {
var emptyResult = ArrayList<Psi>();

if (! {
return emptyResult;

if ((psiElement is PsiClass) == false) {
return emptyResult;
var psiClass = psiElement as PsiClass;

// create field. it's ok
val psiField: PsiField = MyFieldUtils.createCacheField(psiClass, "hello")
val psiElementList: MutableList<PsiElement> = ArrayList()

var desginName = + "Desgin"
// TODO How to add ?
var javaFile: PsiFile = PsiFileFactory.getInstance(psiElement.project)
"${desginName}.java", JavaFileType.INSTANCE, """
class ${desginName}{
public String name(){
return "";
return (psiElementList as MutableList<Psi>);




Comment actions Permalink


Why are you trying to implement Lombok functionality which is bundled in IntelliJ IDEA Community, which is free? Duplicating existing plugins and functionalities without a strong reason should be avoided.

If you still are interested in implementing it for some reason, you can get some inspiration from:

Comment actions Permalink


Thank you for your answer @Karol Lewandowski

I've looked at the lombok source code, but I think it's already very complicated, making it hard for me to understand

I have a really cool idea, but I need to know the lombok builder implementation so I can finish it

have a nice day


Please sign in to leave a comment.