Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 接口常量字段未被过滤 #19

Closed
BOFA1ex opened this issue Dec 16, 2021 · 3 comments
Closed

fix: 接口常量字段未被过滤 #19

BOFA1ex opened this issue Dec 16, 2021 · 3 comments

Comments

@BOFA1ex
Copy link
Contributor

BOFA1ex commented Dec 16, 2021

public static boolean isNeedField(PsiField field) {
    PsiModifierList modifierList = field.getModifierList();
    if (modifierList == null || !modifierList.hasExplicitModifier(PsiModifier.STATIC)) {
        return true;
    }
    return false;
}
public interface TestInterface{
    Map<String,Integer> FIELD_MAPPINGS = Map.of("1",2,"3",4);
}

image

@BOFA1ex
Copy link
Contributor Author

BOFA1ex commented Dec 16, 2021

public static boolean isNeedField(PsiField field) {
    return !field.hasModifier(JvmModifier.STATIC);
}

@lkqm
Copy link
Member

lkqm commented Dec 16, 2021

设计如此,响应参数不应该过滤掉final字段,请求参数不考虑,正常情况请求参数不会存在final字段

@BOFA1ex
Copy link
Contributor Author

BOFA1ex commented Dec 16, 2021

我想表达的是
接口里定义类变量隐式声明为modifier static final
PsiField#getModifierList#hasExplicitModifier(PsiModifier.STATIC) 该API行为仅判定字段是否显式声明为static.
建议判断逻辑改为 field.hasModifier(JvmModifier.STATIC) 可以解决隐式声明的问题.

@lkqm lkqm closed this as completed in b52d6f5 Dec 17, 2021
lkqm added a commit that referenced this issue Dec 17, 2021
fix: #19 interface#constant should be filtered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants