use settingsInfo

This commit is contained in:
林万程
2022-12-09 22:37:41 +08:00
parent cae3095d0e
commit b0f939888d
10 changed files with 55 additions and 55 deletions

View File

@@ -68,12 +68,12 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
}
@Override
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T lineInfo, @NotNull PsiElement resolve) {
@Nullable String resolveDocPrint = super.resolveDocPrint(lineInfo, resolve);
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T settingsInfo, @NotNull PsiElement resolve) {
@Nullable String resolveDocPrint = super.resolveDocPrint(settingsInfo, resolve);
if (resolveDocPrint != null) {
return resolveDocPrint;
}
if (lineInfo.appSettings.fromParam && resolve instanceof PsiParameter) {
if (settingsInfo.appSettings.fromParam && resolve instanceof PsiParameter) {
return paramDoc((PsiParameter) resolve);
}
return null;
@@ -105,10 +105,11 @@ public class JavaLangDoc extends BaseTagLangDoc<PsiDocComment> {
@Nullable
@Override
protected PsiDocComment toDocElement(@NotNull PsiElement resolve) {
protected <T extends SettingsInfo> PsiDocComment toDocElement(@NotNull T settingsInfo,
@NotNull PsiElement resolve) {
if (resolve instanceof PsiDocCommentOwner) {
@NotNull PsiDocCommentOwner psiDocCommentOwner = (PsiDocCommentOwner) resolve;
return OwnerToPsiDocSkip.refDoc(psiDocCommentOwner);
return OwnerToPsiDocSkip.refDoc(settingsInfo, psiDocCommentOwner);
}
return null;
}

View File

@@ -24,7 +24,7 @@ public class JavaTree {
@Nullable
public static <T extends SettingsInfo> String treeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
@NotNull Project project) {
@Nullable PsiDocComment docComment = nodeDoc(node, project);
@Nullable PsiDocComment docComment = nodeDoc(settingsInfo, node, project);
if (docComment == null) {
return null;
}
@@ -32,7 +32,8 @@ public class JavaTree {
}
@Nullable
static PsiDocComment nodeDoc(ProjectViewNode<?> node, @NotNull Project project) {
static <T extends SettingsInfo> PsiDocComment nodeDoc(@NotNull T settingsInfo, ProjectViewNode<?> node,
@NotNull Project project) {
if (node instanceof PsiFileNode) {
PsiFile psiFile = ((PsiFileNode) node).getValue();
return OwnerToPsiDocUtils.fileDoc(psiFile);
@@ -50,7 +51,7 @@ public class JavaTree {
if (type instanceof PsiClassReferenceType) {
@NotNull PsiClassReferenceType psiClassReferenceType = (PsiClassReferenceType) type;
@NotNull PsiJavaCodeReferenceElement reference = psiClassReferenceType.getReference();
return NewCallRefToPsiDoc.javaCodeDoc(reference);
return NewCallRefToPsiDoc.javaCodeDoc(settingsInfo, reference);
}
}

View File

@@ -35,7 +35,7 @@ public class KotlinLangDoc extends BaseTagLangDoc<KDocSection> {
@Override
@Nullable
protected KDocSection toDocElement(@NotNull PsiElement resolve) {
protected <T extends SettingsInfo> KDocSection toDocElement(@NotNull T settingsInfo, @NotNull PsiElement resolve) {
if (resolve instanceof PsiPackageBase) {
return null;
}

View File

@@ -4,6 +4,8 @@ import com.intellij.psi.PsiDocCommentOwner;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiJavaCodeReferenceElement;
import com.intellij.psi.javadoc.PsiDocComment;
import io.github.linwancen.plugin.show.bean.SettingsInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -14,7 +16,8 @@ public class NewCallRefToPsiDoc {
private NewCallRefToPsiDoc() {}
@Nullable
public static PsiDocComment javaCodeDoc(@Nullable PsiJavaCodeReferenceElement ref) {
public static <T extends SettingsInfo> PsiDocComment javaCodeDoc(@NotNull T settingsInfo,
@Nullable PsiJavaCodeReferenceElement ref) {
if (ref == null) {
return null;
}
@@ -25,7 +28,7 @@ public class NewCallRefToPsiDoc {
// ignore
}
if (resolve instanceof PsiDocCommentOwner) {
return OwnerToPsiDocSkip.refDoc(((PsiDocCommentOwner) resolve));
return OwnerToPsiDocSkip.refDoc(settingsInfo, ((PsiDocCommentOwner) resolve));
}
return null;
}

View File

@@ -3,9 +3,8 @@ package io.github.linwancen.plugin.show.java.line;
import com.intellij.psi.PsiDocCommentOwner;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.javadoc.PsiDocComment;
import io.github.linwancen.plugin.show.bean.SettingsInfo;
import io.github.linwancen.plugin.show.java.doc.OwnerToPsiDocUtils;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,18 +15,17 @@ public class OwnerToPsiDocSkip {
private OwnerToPsiDocSkip() {}
public static PsiDocComment refDoc(@Nullable PsiDocCommentOwner docOwner) {
public static <T extends SettingsInfo> PsiDocComment refDoc(@NotNull T settingsInfo,
@Nullable PsiDocCommentOwner docOwner) {
if (docOwner == null) {
return null;
}
@NotNull AppSettingsState appSettings = AppSettingsState.getInstance();
@NotNull ProjectSettingsState projectSettings = ProjectSettingsState.getInstance(docOwner.getProject());
if (SkipUtils.skipSign(docOwner, appSettings, projectSettings)) {
if (SkipUtils.skipSign(settingsInfo, docOwner)) {
return null;
}
@Nullable PsiDocComment docComment = docOwner instanceof PsiMethod
? OwnerToPsiDocUtils.methodDoc(((PsiMethod) docOwner))
: OwnerToPsiDocUtils.srcOrByteCodeDoc(docOwner);
return SkipUtils.skipDoc(docComment, appSettings, projectSettings);
return SkipUtils.skipDoc(settingsInfo, docComment);
}
}

View File

@@ -4,9 +4,9 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMember;
import com.intellij.psi.javadoc.PsiDocComment;
import io.github.linwancen.plugin.show.bean.FuncEnum;
import io.github.linwancen.plugin.show.bean.SettingsInfo;
import io.github.linwancen.plugin.show.lang.base.DocSkip;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -15,19 +15,19 @@ class SkipUtils {
private SkipUtils() {}
static boolean skipSign(PsiElement psiElement, @NotNull AppSettingsState appSettings,
@NotNull ProjectSettingsState projectSettings) {
@Nullable String text = psiName(psiElement, appSettings);
static <T extends SettingsInfo> boolean skipSign(@NotNull T settingsInfo, PsiElement psiElement) {
@Nullable String text = psiName(settingsInfo, psiElement);
if (text == null) {
return true;
}
return DocSkip.skipSign(appSettings, projectSettings, text);
return DocSkip.skipSign(settingsInfo, text);
}
private static @Nullable String psiName(@Nullable PsiElement psiElement, @NotNull AppSettingsState appSettings) {
@Nullable
private static <T extends SettingsInfo> String psiName(@NotNull T settingsInfo, @Nullable PsiElement psiElement) {
if (psiElement instanceof PsiClass) {
@NotNull PsiClass psiClass = (PsiClass) psiElement;
if (appSettings.skipAnnotation && psiClass.isAnnotationType()) {
if (settingsInfo.appSettings.skipAnnotation && psiClass.isAnnotationType()) {
return null;
}
return psiClass.getQualifiedName();
@@ -51,16 +51,15 @@ class SkipUtils {
return null;
}
static PsiDocComment skipDoc(@Nullable PsiDocComment doc, @NotNull AppSettingsState appSettings,
@NotNull ProjectSettingsState projectSettings) {
static <T extends SettingsInfo> PsiDocComment skipDoc(@NotNull T settingsInfo, @Nullable PsiDocComment doc) {
if (doc == null) {
return null;
}
if (appSettings.skipBlank && isBlank(doc)) {
if (settingsInfo.appSettings.skipBlank && isBlank(doc)) {
return null;
}
String text = doc.getText();
boolean skip = DocSkip.skipDoc(appSettings, projectSettings, text);
boolean skip = DocSkip.skipDoc(settingsInfo, text);
return skip ? null : doc;
}