How to get arguments for enum constant from com.intellij.psi.impl.compiled.ClsEnumConstantImpl
已回答
I need to get the list of parameters from the enumeration of library.
For example: Enum source
public enum IntEnum {
VALUE_(3);
private Integer id;
IntEnum(Integer value) {
this.id = value;
}
public Integer getId() {
return id;
}
}
IDEA API code:
for (PsiField field : enumPsiClass.getFields()) {
if (!(field instanceof PsiEnumConstant)) {
continue;
}
PsiExpressionList argumentList = ((PsiEnumConstant) field).getArgumentList();
if (argumentList == null) {
//argumentList is null for enums of Library
} else {
//argumentList is not null for enums of Project
}
}
请先登录再写评论。
Something like this:
Thanks, Roman Shevchenko!