summaryrefslogtreecommitdiff
path: root/python/src/com/jetbrains/python/projectView/PyElementNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/com/jetbrains/python/projectView/PyElementNode.java')
-rw-r--r--python/src/com/jetbrains/python/projectView/PyElementNode.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/python/src/com/jetbrains/python/projectView/PyElementNode.java b/python/src/com/jetbrains/python/projectView/PyElementNode.java
index 20c7b811b8a6..6ec347236773 100644
--- a/python/src/com/jetbrains/python/projectView/PyElementNode.java
+++ b/python/src/com/jetbrains/python/projectView/PyElementNode.java
@@ -19,11 +19,14 @@ import com.intellij.ide.projectView.PresentationData;
import com.intellij.ide.projectView.ViewSettings;
import com.intellij.ide.projectView.impl.nodes.BasePsiNode;
import com.intellij.ide.util.treeView.AbstractTreeNode;
+import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.project.Project;
+import com.jetbrains.python.PyNames;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyElement;
import com.jetbrains.python.psi.PyFunction;
+import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -57,14 +60,23 @@ public class PyElementNode extends BasePsiNode<PyElement> {
@Override
protected void updateImpl(PresentationData data) {
- PyElement value = getValue();
+ final PyElement value = getValue();
final String name = value.getName();
- StringBuilder presentableText = new StringBuilder(name != null ? name : "<unnamed>");
- if (value instanceof PyFunction) {
- presentableText.append(((PyFunction) value).getParameterList().getPresentableText(false));
+ final ItemPresentation presentation = value.getPresentation();
+ String presentableText = name != null ? name : PyNames.UNNAMED_ELEMENT;
+ Icon presentableIcon = value.getIcon(0);
+ if (presentation != null) {
+ final String text = presentation.getPresentableText();
+ if (text != null) {
+ presentableText = text;
+ }
+ final Icon icon = presentation.getIcon(false);
+ if (icon != null) {
+ presentableIcon = icon;
+ }
}
- data.setPresentableText(presentableText.toString());
- data.setIcon(value.getIcon(0));
+ data.setPresentableText(presentableText);
+ data.setIcon(presentableIcon);
}
@Override