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

@@ -55,7 +55,7 @@ public class SqlLangDoc extends BaseLangDoc {
}
for (@NotNull DbElement dbElement : relatedDbElements) {
@Nullable String refDoc = dbElement.getComment();
if (refDoc != null && !DocSkip.skipDoc(lineInfo.appSettings, lineInfo.projectSettings, refDoc)) {
if (refDoc != null && !DocSkip.skipDoc(lineInfo, refDoc)) {
return refDoc;
}
}

View File

@@ -119,7 +119,7 @@ public abstract class BaseLangDoc extends EditorLinePainter {
protected String refElementDoc(@NotNull LineInfo lineInfo,
@NotNull PsiElement refElement) {
@Nullable String refDoc = refDoc(lineInfo, refElement);
if (refDoc != null && !DocSkip.skipDoc(lineInfo.appSettings, lineInfo.projectSettings, refDoc)) {
if (refDoc != null && !DocSkip.skipDoc(lineInfo, refDoc)) {
return refDoc;
}
return null;

View File

@@ -8,12 +8,13 @@ import org.jetbrains.annotations.Nullable;
public abstract class BaseTagLangDoc<DocElement> extends BaseLangDoc {
@Override
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T lineInfo, @NotNull PsiElement resolve) {
@Nullable DocElement docElement = toDocElement(resolve);
public @Nullable <T extends SettingsInfo> String resolveDocPrint(@NotNull T settingsInfo,
@NotNull PsiElement resolve) {
@Nullable DocElement docElement = toDocElement(settingsInfo, resolve);
if (docElement == null) {
return null;
}
return docElementToStr(lineInfo, docElement);
return docElementToStr(settingsInfo, docElement);
}
@Nullable
@@ -44,7 +45,8 @@ public abstract class BaseTagLangDoc<DocElement> extends BaseLangDoc {
}
@Nullable
protected abstract DocElement toDocElement(@NotNull PsiElement resolve);
protected abstract <T extends SettingsInfo> DocElement toDocElement(@NotNull T settingsInfo,
@NotNull PsiElement resolve);
/**
* cut / * # not filter text

View File

@@ -1,7 +1,6 @@
package io.github.linwancen.plugin.show.lang.base;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
import io.github.linwancen.plugin.show.settings.ProjectSettingsState;
import io.github.linwancen.plugin.show.bean.SettingsInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -11,38 +10,35 @@ public class DocSkip {
private DocSkip() {}
public static boolean skipSign(@NotNull AppSettingsState appSettings,
@NotNull ProjectSettingsState projectSettings, String text) {
return skipText(text,
projectSettings.globalFilterEffective, appSettings.lineInclude, appSettings.lineExclude,
projectSettings.projectFilterEffective, projectSettings.lineInclude, projectSettings.lineExclude);
public static <T extends SettingsInfo> boolean skipSign(@NotNull T settingsInfo, String text) {
return skipText(settingsInfo, text,
settingsInfo.appSettings.lineInclude, settingsInfo.appSettings.lineExclude,
settingsInfo.projectSettings.lineInclude, settingsInfo.projectSettings.lineExclude);
}
private static final Pattern NOT_ASCII_PATTERN = Pattern.compile("[^\u0000-\u007f]");
public static boolean skipDoc(@NotNull AppSettingsState appSettings,
@NotNull ProjectSettingsState projectSettings, @NotNull String text) {
if (appSettings.skipAscii && !NOT_ASCII_PATTERN.matcher(text).find()) {
public static <T extends SettingsInfo> boolean skipDoc(@NotNull T settingsInfo, @NotNull String text) {
if (settingsInfo.appSettings.skipAscii && !NOT_ASCII_PATTERN.matcher(text).find()) {
return true;
}
return skipText(text,
projectSettings.globalFilterEffective, appSettings.docInclude, appSettings.docExclude,
projectSettings.projectFilterEffective, projectSettings.docInclude, projectSettings.docExclude);
return skipText(settingsInfo, text,
settingsInfo.appSettings.docInclude, settingsInfo.appSettings.docExclude,
settingsInfo.projectSettings.docInclude, settingsInfo.projectSettings.docExclude);
}
static boolean skipText(@Nullable String text,
boolean appFilterEffective, @NotNull Pattern appDocInclude, @NotNull Pattern appDocExclude,
boolean projectFilterEffective, @NotNull Pattern projectDocInclude,
@NotNull Pattern projectDocExclude
static <T extends SettingsInfo> boolean skipText(@NotNull T settingsInfo, @Nullable String text,
@NotNull Pattern appDocInclude, @NotNull Pattern appDocExclude,
@NotNull Pattern projectDocInclude, @NotNull Pattern projectDocExclude
) {
if (text == null) {
return true;
}
if (appFilterEffective
if (settingsInfo.projectSettings.globalFilterEffective
&& skipText(text, appDocInclude, appDocExclude)) {
return true;
}
if (projectFilterEffective) {
if (settingsInfo.projectSettings.projectFilterEffective) {
return skipText(text, projectDocInclude, projectDocExclude);
}
return false;