mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
correctly process dotted names in superclass index
This commit is contained in:
@@ -12,6 +12,7 @@ import com.intellij.util.io.PersistentStringEnumerator;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyStubElementType;
|
||||
import com.jetbrains.python.psi.PyReferenceExpression;
|
||||
import com.jetbrains.python.psi.impl.PyClassImpl;
|
||||
import com.jetbrains.python.psi.stubs.PyClassNameIndex;
|
||||
import com.jetbrains.python.psi.stubs.PyClassStub;
|
||||
@@ -38,7 +39,13 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
|
||||
final PyExpression[] exprs = psi.getSuperClassExpressions();
|
||||
String[] superClasses = new String[exprs.length];
|
||||
for(int i=0; i<exprs.length; i++) {
|
||||
superClasses [i] = exprs [i].getText();
|
||||
final PyExpression expression = exprs[i];
|
||||
if (expression instanceof PyReferenceExpression) {
|
||||
superClasses [i] = ((PyReferenceExpression) expression).getReferencedName();
|
||||
}
|
||||
else {
|
||||
superClasses [i] = expression.getText();
|
||||
}
|
||||
}
|
||||
return new PyClassStubImpl(psi.getName(), parentStub, superClasses);
|
||||
}
|
||||
|
||||
3
python/testData/inheritors/dotted/A.py
Normal file
3
python/testData/inheritors/dotted/A.py
Normal file
@@ -0,0 +1,3 @@
|
||||
class A(object):
|
||||
pass
|
||||
|
||||
5
python/testData/inheritors/dotted/B.py
Normal file
5
python/testData/inheritors/dotted/B.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import A
|
||||
|
||||
class B(A.A):
|
||||
pass
|
||||
|
||||
0
python/testData/inheritors/dotted/__init__.py
Normal file
0
python/testData/inheritors/dotted/__init__.py
Normal file
@@ -31,6 +31,13 @@ public class PyInheritorsSearchTest extends CodeInsightTestCase {
|
||||
assertEquals(2, inheritors.size());
|
||||
}
|
||||
|
||||
public void testDotted() throws Exception {
|
||||
setupProject();
|
||||
final PyClass pyClass = findClass("A");
|
||||
Collection<PyClass> inheritors = PyClassInheritorsSearch.search(pyClass, true).findAll();
|
||||
assertEquals(1, inheritors.size());
|
||||
}
|
||||
|
||||
private void setupProject() throws Exception {
|
||||
String testName = getTestName(true);
|
||||
String root = PathManager.getHomePath() + "/plugins/python/testData/inheritors/" + testName;
|
||||
|
||||
Reference in New Issue
Block a user