some optimizations
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user