some optimizations

This commit is contained in:
林万程
2023-12-12 18:41:28 +08:00
parent 92380697ff
commit 0d1d67b765
6 changed files with 26 additions and 24 deletions

View File

@@ -38,7 +38,7 @@ public class Tree implements ProjectViewNodeDecorator {
}
}
private void decorateImpl(@NotNull ProjectViewNode node, @NotNull PresentationData data) {
private void decorateImpl(@NotNull ProjectViewNode<?> node, @NotNull PresentationData data) {
if (!AppSettingsState.getInstance().showTreeComment) {
return;
}
@@ -52,17 +52,21 @@ public class Tree implements ProjectViewNodeDecorator {
DumbService.getInstance(project).runReadActionInSmartMode(() ->
ApplicationManager.getApplication().runReadAction(() -> {
@Nullable String doc = treeDoc(node, project);
if (doc == null) {
return;
}
@NotNull List<ColoredFragment> coloredText = data.getColoredText();
if (coloredText.isEmpty()) {
data.addText(data.getPresentableText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
data.addText(" " + doc, SimpleTextAttributes.GRAY_ATTRIBUTES);
addText(data, doc);
}));
}
static void addText(@NotNull PresentationData data, @Nullable String text) {
if (text == null) {
return;
}
@NotNull List<ColoredFragment> coloredText = data.getColoredText();
if (coloredText.isEmpty()) {
data.addText(data.getPresentableText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
data.addText(" " + text, SimpleTextAttributes.GRAY_ATTRIBUTES);
}
@Nullable
private String treeDoc(@NotNull ProjectViewNode<?> node, @NotNull Project project) {
@Nullable String doc = TreeExt.doc(node);

View File

@@ -13,13 +13,12 @@ import java.util.regex.Pattern;
class DirDoc {
@Nullable
static String dirDoc(PsiDirectoryNode node, @NotNull AbstractSettingsState settings) {
static String dirDoc(@NotNull PsiDirectoryNode node, @NotNull AbstractSettingsState settings) {
if (!settings.dirDocEffect) {
return null;
}
@NotNull Map<String, Pattern[]> patternMap = settings.dirDoc;
@NotNull PsiDirectoryNode psiDirectoryNode = node;
@Nullable PsiDirectory psiDirectory = psiDirectoryNode.getValue();
@Nullable PsiDirectory psiDirectory = node.getValue();
if (psiDirectory == null) {
return null;
}

View File

@@ -13,13 +13,12 @@ import java.util.regex.Pattern;
class FileDoc {
@Nullable
static String fileDoc(PsiFileNode node, @NotNull AbstractSettingsState settings) {
static String fileDoc(@NotNull PsiFileNode node, @NotNull AbstractSettingsState settings) {
if (!settings.fileDocEffect) {
return null;
}
@NotNull Map<String, Pattern[]> patternMap = settings.fileDoc;
@NotNull PsiFileNode psiFileNode = node;
@Nullable PsiFile psiFile = psiFileNode.getValue();
@Nullable PsiFile psiFile = node.getValue();
if (psiFile == null) {
return null;
}

View File

@@ -110,11 +110,11 @@ Show doc comment at the Project view Tree, line End, json, other
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<depends optional="true" config-file="java.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
<depends optional="true" config-file="sql.xml">com.intellij.database</depends>
<depends optional="true" config-file="js.xml">JavaScript</depends>
<depends optional="true" config-file="python.xml">com.intellij.modules.python</depends>
<depends optional="true" config-file="go.xml">org.jetbrains.plugins.go</depends>
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
<!--suppress PluginXmlValidity, MybatisMapperXmlInspection -->
<!--<depends optional="true" config-file="cs.xml">com.intellij.modules.rider</depends>-->

View File

@@ -2,11 +2,11 @@
reset.default=Reset default
show=Show
show.tree.comment=Show tree comment
compact=Support compact
show.line.end.comment=Show line end comment
only.select.line=Only Select Line
show.tree.comment=Show tree comment
compact=support compact
skip.anno=skip @
skip.blank=skip Blank
@@ -29,7 +29,7 @@ comment.include.regexp=comment include Regexp:
comment.exclude.regexp=comment exclude Regexp:
get.doc.regexp=get doc Regexp, last () when had, default is first sentence .+?(?:[\u3002\r\n]|. ) :
dir.doc.regexp=dir doc, fileName||Regexp1||Regexp2\\n:
file.doc.regexp=file doc, fileName||Regexp1||Regexp2\\n:
file.doc.regexp=file doc, fileExtension||Regexp1||Regexp2\\n:
global.settings.effective=Global Settings Effective
project.settings.effective=Project Settings Effective

View File

@@ -3,11 +3,11 @@ reset.default=\u6062\u590D\u9ED8\u8BA4
show=\u663E\u793A
show.tree.comment=\u663E\u793A\u6587\u4EF6\u6811\u6CE8\u91CA
only.select.line=\u53EA\u663E\u793A\u9009\u62E9\u884C
show.line.end.comment=\u663E\u793A\u884C\u672B\u6CE8\u91CA
compact=\u652F\u6301\u538B\u7F29\u7A7A\u7684\u4E2D\u95F4\u5305
show.line.end.comment=\u663E\u793A\u884C\u672B\u6CE8\u91CA
only.select.line=\u53EA\u663E\u793A\u9009\u62E9\u884C
line.tags=\u884C\u6CE8\u91CA @ \u6807\u7B7E | \u5206\u9694
tree.tags=\u6811\u6CE8\u91CA @ \u6807\u7B7E | \u5206\u9694
@@ -29,7 +29,7 @@ comment.include.regexp=\u6CE8\u91CA \u5305\u542B \u6B63\u5219\uFF1A
comment.exclude.regexp=\u6CE8\u91CA \u6392\u9664 \u6B63\u5219\uFF1A
get.doc.regexp=\u6CE8\u91CA\u63D0\u53D6\u6B63\u5219\uFF0C\u82E5\u6709 () \u5219\u53D6\u6700\u540E\u4E00\u4E2A\uFF0C\u9ED8\u8BA4\u6B63\u5219\u662F\u7B2C\u4E00\u53E5 .+?(?:[\u3002\r\n]|. ) :
dir.doc.regexp=\u76EE\u5F55\u6CE8\u91CA, \u6587\u4EF6\u540D||\u6B63\u52191||\u6B63\u52192\\n:
file.doc.regexp=\u6587\u4EF6\u6CE8\u91CA, \u6587\u4EF6\u540D||\u6B63\u52191||\u6B63\u52192\\n:
file.doc.regexp=\u6587\u4EF6\u6CE8\u91CA, \u6587\u4EF6\u62D3\u5C55\u540D||\u6B63\u52191||\u6B63\u52192\\n:
global.settings.effective=\u5168\u5C40\u914D\u7F6E\u751F\u6548
project.settings.effective=\u9879\u76EE\u914D\u7F6E\u751F\u6548