Add a statement inside PsiClass

Hi,  

 

Im working on a simple plugin which create couple of files and insert few methods. I also need to add a new variable to an existing file and insert one line statement.

 

public static final int var = 0;

 

i can add a variable/field like below

 

PsiField fd = elementFactory.createField("var", PsiType.INT);
psiClass1.add(fd);

 

But i am not able to make the variable public static final.

is there any other way to achieve the same?

0

Hi,

use for it com.intellij.psi.util.PsiUtil#setModifierProperty with corresponding modifiers

Anna

0

请先登录再写评论。