mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Use ItemPresentation.getPresentableText() instead of checking for PyFunction directly
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user