Fix to Create a static final field in class

Answered

How can I create a fix to generate a final static field only?

Right now with the following code, it generates also the getter and the setter, but I was trying to avoid it.

About the "final" and "static" annotations I've no idea on how to generate them. I've tried to play around with several classes but I had hard times figuring out a solution

new CreateFieldOrPropertyFix(clazz,
"MY_CONSTANT",
PsiType.getTypeByName("java.lang.String",clazz.getProject(),clazz.getResolveScope()),
PropertyMemberType.GETTER,
new PsiAnnotation[0]
)
0
1 comment

Hi,

 

please take a look at com.intellij.psi.util.PsiUtil#setModifierProperty and com.intellij.codeInsight.daemon.impl.quickfix.CreateFieldFromUsageFix to find out how to create fields.

 

Anna

0

Please sign in to leave a comment.