mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
Fixed nondeterministic ordering in union types, added test data (PY-3496, CR-PY-170)
This commit is contained in:
@@ -33,21 +33,9 @@ public class PyDefUseUtil {
|
||||
throw new InstructionNotFoundException();
|
||||
}
|
||||
final boolean[] visited = new boolean[instructions.length];
|
||||
final Collection<PyElement> result = new HashSet<PyElement>();
|
||||
final Collection<PyElement> result = new LinkedHashSet<PyElement>();
|
||||
getLatestDefs(var, instructions, instr, visited, result);
|
||||
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()]);
|
||||
return result.toArray(new PyElement[result.size()]);
|
||||
}
|
||||
|
||||
private static void getLatestDefs(final PyElement var,
|
||||
|
||||
1
python/testData/quickdoc/Variable.html
Normal file
1
python/testData/quickdoc/Variable.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body><small>Assigned to <code>y</code><br></small><code><br>Inferred type: one of (str, int)</code></body></html>
|
||||
6
python/testData/quickdoc/Variable.py
Normal file
6
python/testData/quickdoc/Variable.py
Normal file
@@ -0,0 +1,6 @@
|
||||
def f(x):
|
||||
if x:
|
||||
y = 1
|
||||
else:
|
||||
y = 'foo'
|
||||
return <the_ref>y
|
||||
Reference in New Issue
Block a user