diff --git a/src/main/java/io/github/linwancen/plugin/show/Tree.java b/src/main/java/io/github/linwancen/plugin/show/Tree.java index c0db917..5901bfa 100644 --- a/src/main/java/io/github/linwancen/plugin/show/Tree.java +++ b/src/main/java/io/github/linwancen/plugin/show/Tree.java @@ -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 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 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); diff --git a/src/main/java/io/github/linwancen/plugin/show/tree/DirDoc.java b/src/main/java/io/github/linwancen/plugin/show/tree/DirDoc.java index a8ab7a9..70a7833 100644 --- a/src/main/java/io/github/linwancen/plugin/show/tree/DirDoc.java +++ b/src/main/java/io/github/linwancen/plugin/show/tree/DirDoc.java @@ -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 patternMap = settings.dirDoc; - @NotNull PsiDirectoryNode psiDirectoryNode = node; - @Nullable PsiDirectory psiDirectory = psiDirectoryNode.getValue(); + @Nullable PsiDirectory psiDirectory = node.getValue(); if (psiDirectory == null) { return null; } diff --git a/src/main/java/io/github/linwancen/plugin/show/tree/FileDoc.java b/src/main/java/io/github/linwancen/plugin/show/tree/FileDoc.java index 2d1a3b3..f3f7baa 100644 --- a/src/main/java/io/github/linwancen/plugin/show/tree/FileDoc.java +++ b/src/main/java/io/github/linwancen/plugin/show/tree/FileDoc.java @@ -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 patternMap = settings.fileDoc; - @NotNull PsiFileNode psiFileNode = node; - @Nullable PsiFile psiFile = psiFileNode.getValue(); + @Nullable PsiFile psiFile = node.getValue(); if (psiFile == null) { return null; } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 4c792fe..31ed5ea 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -110,11 +110,11 @@ Show doc comment at the Project view Tree, line End, json, other on how to target different products --> com.intellij.modules.platform com.intellij.modules.java + org.jetbrains.kotlin com.intellij.database JavaScript com.intellij.modules.python org.jetbrains.plugins.go - org.jetbrains.kotlin diff --git a/src/main/resources/messages/ShowCommentBundle.properties b/src/main/resources/messages/ShowCommentBundle.properties index 7f75b3f..d55db35 100644 --- a/src/main/resources/messages/ShowCommentBundle.properties +++ b/src/main/resources/messages/ShowCommentBundle.properties @@ -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 diff --git a/src/main/resources/messages/ShowCommentBundle_zh.properties b/src/main/resources/messages/ShowCommentBundle_zh.properties index 5266867..dbddceb 100644 --- a/src/main/resources/messages/ShowCommentBundle_zh.properties +++ b/src/main/resources/messages/ShowCommentBundle_zh.properties @@ -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