mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Sorting of Python union type members is performed during latest definitions search
This commit is contained in:
@@ -160,12 +160,13 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i
|
||||
}
|
||||
}
|
||||
if (type instanceof PyUnionType) {
|
||||
final List<String> typeNames = new ArrayList<String>();
|
||||
for (PyType t : ((PyUnionType)type).getMembers()) {
|
||||
typeNames.add(getTypeName(t, context));
|
||||
}
|
||||
Collections.sort(typeNames);
|
||||
return String.format("one of (%s)", StringUtil.join(typeNames, ", "));
|
||||
return String.format("one of (%s)", StringUtil.join(((PyUnionType)type).getMembers(),
|
||||
new Function<PyType, String>() {
|
||||
@Override
|
||||
public String fun(PyType t) {
|
||||
return getTypeName(t, context);
|
||||
}
|
||||
}, ", "));
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
@@ -36,7 +35,19 @@ public class PyDefUseUtil {
|
||||
final boolean[] visited = new boolean[instructions.length];
|
||||
final Collection<PyElement> result = new HashSet<PyElement>();
|
||||
getLatestDefs(var, instructions, instr, visited, result);
|
||||
return result.toArray(new PyElement[result.size()]);
|
||||
final List<PyElement> sortedResult = new ArrayList<PyElement>();
|
||||
sortedResult.addAll(result);
|
||||
Collections.sort(sortedResult, new Comparator<PyElement>() {
|
||||
@Override
|
||||
public int compare(PyElement e1, PyElement e2) {
|
||||
final String n1 = e1.getName();
|
||||
if (n1 != null) {
|
||||
return n1.compareTo(e2.getName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
return sortedResult.toArray(new PyElement[sortedResult.size()]);
|
||||
}
|
||||
|
||||
private static void getLatestDefs(final PyElement var,
|
||||
|
||||
Reference in New Issue
Block a user