Skip to content

Commit 5e7b1b3

Browse files
committed
sync(common): 同步 common 模块
1 parent d38de74 commit 5e7b1b3

5 files changed

Lines changed: 54 additions & 10 deletions

File tree

src/main/java/cn/gudqs7/plugins/common/base/action/AbstractBatchDocerSavior.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ public void actionPerformed0(@NotNull AnActionEvent e) {
8989
PsiDirectory psiDirectory = getPsiDirectory(psiElement);
9090

9191
Set<PsiClass> psiClassList = new TreeSet<>(
92-
Comparator.comparing(PsiClass::getQualifiedName)
92+
(o1, o2) -> {
93+
String qName1 = o1.getQualifiedName();
94+
String qName2 = o2.getQualifiedName();
95+
if (Objects.equals(qName1, qName2) || qName1 == null || qName2 == null) {
96+
return 0;
97+
} else {
98+
return qName1.compareTo(qName2);
99+
}
100+
}
93101
);
94102

95103
boolean isRightClickOnClass = psiClass != null;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package cn.gudqs7.plugins.common.base.error;
2+
3+
/**
4+
* 此异常可忽略不要求上报 issue
5+
*
6+
* @author wenquan
7+
* @date 2022/6/21
8+
*/
9+
public class CanIgnoreException extends RuntimeException {
10+
11+
public CanIgnoreException(String message) {
12+
super(message);
13+
}
14+
15+
public CanIgnoreException(String message, Throwable cause) {
16+
super(message, cause);
17+
}
18+
19+
public CanIgnoreException(Throwable cause) {
20+
super(cause);
21+
}
22+
23+
protected CanIgnoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
24+
super(message, cause, enableSuppression, writableStackTrace);
25+
}
26+
27+
}

src/main/java/cn/gudqs7/plugins/common/diagnostic/AbstractGithubErrorReportSubmitter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ protected String newIssueByTitleBody(String title, String body) {
7373
@SneakyThrows
7474
@Override
7575
protected String findIssueByMd5(String throwableMd5) {
76-
Map<String, String> headers = null;
7776
String q = "repo:" + getGithubRepo() + " is:issue in:body " + throwableMd5;
7877
URLCodec urlCodec = new URLCodec(CommonConst.UTF8);
7978
String query = "q=" + urlCodec.encode(q) + "&page=1&per_page=1";
80-
String result = HttpUtil.sendHttpWithBody(API_BASE_URL + "/search/issues?" + query, "GET", null, headers);
79+
String result = HttpUtil.sendHttpWithBody(API_BASE_URL + "/search/issues?" + query, "GET", null, null);
8180
System.out.println("searchIssue res :: " + result);
8281
Map map = JsonUtil.fromJson(result, Map.class);
8382
List<Map<String, Object>> items = (List<Map<String, Object>>) map.get("items");

src/main/java/cn/gudqs7/plugins/common/resolver/comment/PsiMethodAnnotationHolderImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import cn.gudqs7.plugins.common.pojo.resolver.RequestMapping;
99
import cn.gudqs7.plugins.common.pojo.resolver.ResponseCodeInfo;
1010
import cn.gudqs7.plugins.common.util.WebEnvironmentUtil;
11+
import cn.gudqs7.plugins.common.util.jetbrain.ExceptionUtil;
1112
import cn.gudqs7.plugins.common.util.jetbrain.PsiAnnotationUtil;
1213
import cn.gudqs7.plugins.common.util.jetbrain.PsiTypeUtil;
1314
import com.intellij.psi.*;
@@ -220,7 +221,11 @@ private void dealRequestMapping(CommentInfo commentInfo) {
220221

221222
// deal controller RequestMapping
222223
String controllerUrl = "/";
223-
PsiAnnotation psiAnnotation = psiMethod.getContainingClass().getAnnotation(QNAME_OF_MAPPING);
224+
PsiClass containingClass = psiMethod.getContainingClass();
225+
if (containingClass == null) {
226+
ExceptionUtil.handleSyntaxError(psiMethod.getName() + "'s Class");
227+
}
228+
PsiAnnotation psiAnnotation = containingClass.getAnnotation(QNAME_OF_MAPPING);
224229
if (psiAnnotation != null) {
225230
List<String> pathList = PsiAnnotationUtil.getAnnotationListValue(psiAnnotation, "value", null);
226231
if (CollectionUtils.isEmpty(pathList)) {

src/main/java/cn/gudqs7/plugins/common/util/jetbrain/ExceptionUtil.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.gudqs7.plugins.common.util.jetbrain;
22

3+
import cn.gudqs7.plugins.common.base.error.CanIgnoreException;
34
import lombok.Lombok;
45

56
import java.io.PrintWriter;
@@ -22,14 +23,18 @@ public static void logException(Throwable throwable, String addition) {
2223
}
2324

2425
public static void handleException(Throwable throwable) {
25-
String addition = "可通过 IDEA 右下角感叹号, 点击 Report To Gudqs7(或 Report And Clear All) 一键上报到 GitHub Issue; " +
26-
"\n另外, 请在上报异常时, 填入您的联系信息, 或 issue 生成后点击进入页面留言以获得 issue 进展通知!" +
27-
"\n";
28-
logException(throwable, addition);
29-
throw Lombok.sneakyThrow(throwable);
26+
if (throwable instanceof CanIgnoreException) {
27+
logException(throwable, "");
28+
} else {
29+
String addition = "可通过 IDEA 右下角感叹号, 点击 Report To Gudqs7(或 Report And Clear All) 一键上报到 GitHub Issue; " +
30+
"\n另外, 请在上报异常时, 填入您的联系信息, 或 issue 生成后点击进入页面留言以获得 issue 进展通知!" +
31+
"\n";
32+
logException(throwable, addition);
33+
throw Lombok.sneakyThrow(throwable);
34+
}
3035
}
3136

3237
public static void handleSyntaxError(String code) throws RuntimeException {
33-
throw new RuntimeException("您的代码可能存在语法错误, 无法为您生成代码, 参考信息: " + code);
38+
throw new CanIgnoreException("您的代码可能存在语法错误, 无法为您生成代码, 参考信息: " + code);
3439
}
3540
}

0 commit comments

Comments
 (0)