mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
to have same behavior for stub-based and non-stub-based resolve, findExportedName() walks the list of stubs in reverse order
This commit is contained in:
@@ -195,7 +195,8 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
final StubElement stub = getStub();
|
||||
if (stub != null) {
|
||||
final List children = stub.getChildrenStubs();
|
||||
for (Object child : children) {
|
||||
for (int i=children.size()-1; i >= 0; i--) {
|
||||
Object child = children.get(i);
|
||||
if (child instanceof NamedStub && name.equals(((NamedStub)child).getName())) {
|
||||
return ((NamedStub) child).getPsi();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from intermediate import do_stuff
|
||||
|
||||
do_stuff()
|
||||
# <ref>
|
||||
@@ -0,0 +1,2 @@
|
||||
from pack1 import do_stuff
|
||||
from pack2 import do_stuff
|
||||
@@ -0,0 +1 @@
|
||||
def do_stuff(): print("wrong stuff")
|
||||
@@ -0,0 +1 @@
|
||||
def do_stuff(): print("the good stuff")
|
||||
@@ -179,10 +179,23 @@ public class PyMultiFileResolveTest extends PyLightFixtureTestCase {
|
||||
assertResolvesTo(PyFunction.class, "dostuff");
|
||||
}
|
||||
|
||||
public void testNameConflict() throws Exception {
|
||||
assertResolvesTo(PyFunction.class, "do_stuff", "/src/pack2.py");
|
||||
}
|
||||
|
||||
private <T extends PsiElement> void assertResolvesTo(final Class<T> aClass, final String name) throws Exception {
|
||||
assertResolvesTo(aClass, name, null);
|
||||
}
|
||||
|
||||
private <T extends PsiElement> void assertResolvesTo(final Class<T> aClass,
|
||||
final String name,
|
||||
String containingFilePath) throws Exception {
|
||||
final PsiElement element = doResolve();
|
||||
assertInstanceOf(element, aClass);
|
||||
assertEquals(name, ((PsiNamedElement) element).getName());
|
||||
if (containingFilePath != null) {
|
||||
assertEquals(containingFilePath, element.getContainingFile().getVirtualFile().getPath());
|
||||
}
|
||||
}
|
||||
|
||||
private PsiFile prepareFile() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user