add try catch

This commit is contained in:
林万程
2023-06-13 07:45:15 +08:00
parent 2c6f96712b
commit 83e0a0a5ee
13 changed files with 138 additions and 20 deletions

View File

@@ -12,6 +12,8 @@ import io.github.linwancen.plugin.show.java.doc.PsiClassUtils;
import io.github.linwancen.plugin.show.jump.JsonRef;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
@@ -19,8 +21,18 @@ import java.util.List;
public class JsonJumpJava extends PsiReferenceContributor {
private static final Logger LOG = LoggerFactory.getLogger(JsonJumpJava.class);
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
try {
register(registrar);
} catch (Exception e) {
LOG.info("JsonJumpJava catch Throwable but log to record.", e);
}
}
private static void register(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(PlatformPatterns.psiElement(JsonStringLiteral.class),
new PsiReferenceProvider() {
@Override

View File

@@ -15,7 +15,12 @@ public class OwnerToPsiDocUtils {
@Nullable
public static PsiDocComment srcOrByteCodeDoc(@NotNull PsiDocCommentOwner psiDocCommentOwner) {
PsiElement navElement = psiDocCommentOwner.getNavigationElement();
PsiElement navElement;
try {
navElement = psiDocCommentOwner.getNavigationElement();
} catch (Exception e) {
return null;
}
if (navElement instanceof PsiDocCommentOwner) {
psiDocCommentOwner = (PsiDocCommentOwner) navElement;
}

View File

@@ -15,7 +15,12 @@ class PsiMethodToPsiDoc {
@Nullable
static PsiDocComment methodSupperNewPropDoc(@NotNull PsiMethod psiMethod) {
// .class
PsiElement navElement = psiMethod.getNavigationElement();
PsiElement navElement = null;
try {
navElement = psiMethod.getNavigationElement();
} catch (Exception e) {
return null;
}
if (navElement instanceof PsiMethod) {
psiMethod = (PsiMethod) navElement;
}