mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed failed test for completion of inherited class attributes.
This commit is contained in:
+3
-9
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
public class PySuperAttributesCompletionContributor extends CompletionContributor {
|
||||
public PySuperAttributesCompletionContributor() {
|
||||
extend(CompletionType.BASIC,
|
||||
PlatformPatterns.psiElement().withParent(PyReferenceExpression.class),
|
||||
PlatformPatterns.psiElement().withParents(PyReferenceExpression.class, PyExpressionStatement.class, PyStatementList.class, PyClass.class),
|
||||
new CompletionProvider<CompletionParameters>() {
|
||||
@Override
|
||||
protected void addCompletions(@NotNull CompletionParameters parameters,
|
||||
@@ -30,17 +30,11 @@ public class PySuperAttributesCompletionContributor extends CompletionContributo
|
||||
@NotNull CompletionResultSet result) {
|
||||
PsiElement position = parameters.getOriginalPosition();
|
||||
PyClass containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class);
|
||||
if (containingClass == null && position instanceof PsiWhiteSpace) {
|
||||
position = PsiTreeUtil.prevLeaf(position);
|
||||
containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class);
|
||||
}
|
||||
|
||||
if (containingClass == null) {
|
||||
return;
|
||||
}
|
||||
PyFunction func = PsiTreeUtil.getParentOfType(position, PyFunction.class);
|
||||
if (func != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> seenNames = Lists.newArrayList();
|
||||
for (PyTargetExpression expr : containingClass.getClassAttributes()) {
|
||||
seenNames.add(expr.getName());
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo:
|
||||
attribute = 1
|
||||
|
||||
|
||||
class Boo(Foo):
|
||||
attribute = <caret>
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo:
|
||||
attribute = 1
|
||||
|
||||
|
||||
class Boo(Foo):
|
||||
attr<caret>
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo:
|
||||
attribute = 1
|
||||
|
||||
|
||||
class Boo(Foo):
|
||||
def f(self):
|
||||
attr<caret>
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo:
|
||||
attribute = 1
|
||||
|
||||
|
||||
class Boo(Foo):
|
||||
def f(self):
|
||||
attr<caret>
|
||||
@@ -267,4 +267,12 @@ public class PythonCompletionTest extends PyLightFixtureTestCase {
|
||||
public void testNoIdentifiersInImport() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuperClassAttributes() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuperClassAttributesNoCompletionInFunc() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user