Skip to content

Commit

Permalink
feat: fix Objects.requireNonNull 部分idea sdk 不支持次方法
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhengwei committed Dec 16, 2023
1 parent 4fe8f64 commit fddb6a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

group 'cn.bugstack.idea.plugin'

version '2.4.9'
version '2.5.0'

apply plugin: 'java'
apply plugin: 'idea'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {
// 织入代码
generateVo2Dto.doGenerate(event.getProject(), event.getDataContext(), event.getData(LangDataKeys.PSI_FILE));
} catch (Exception e) {
Messages.showErrorDialog(event.getProject(), "请按规:先复制对象后,例如:A a,再光标放到需要织入的对象上,例如:B b!", "错误提示");
Messages.showErrorDialog(event.getProject(), "请按规:先复制对象后,例如:A a,再光标放到需要织入的对象上,例如:B b!联系作者:小傅哥 微信:fustack", "错误提示");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.bugstack.guide.idea.plugin.infrastructure.DataSetting;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.*;

import java.util.ArrayList;
Expand Down Expand Up @@ -80,7 +81,9 @@ protected MethodVO getMethods(PsiClass psiClass, String regex, String typeStr) {
Pattern p = Pattern.compile("static.*?final|final.*?static");
PsiField[] fields = psiClass.getFields();
for (PsiField psiField : fields) {
String fieldVal = Objects.requireNonNull(psiField.getNameIdentifier().getContext()).getText();
PsiElement context = psiField.getNameIdentifier().getContext();
if (null == context) continue;
String fieldVal = context.getText();
// serialVersionUID 判断
if (fieldVal.contains("serialVersionUID")) {
continue;
Expand All @@ -102,6 +105,8 @@ protected MethodVO getMethods(PsiClass psiClass, String regex, String typeStr) {
}
}

Messages.showErrorDialog(""+fieldNameList.size(),"");

return new MethodVO(fieldNameList, methodNameList);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
<ul>
<li>lombok builder</li>
</ul>
<h3>V2.5.0</h3>
<ul>
<li>fix Objects.requireNonNull</li>
</ul>
]]>
</change-notes>

Expand Down

0 comments on commit fddb6a3

Please sign in to comment.