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);