mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed completion of classobj attributes for old-style classes (PY-5486)
This commit is contained in:
@@ -18,6 +18,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
@@ -287,7 +288,7 @@ public class PyBuiltinCache {
|
||||
|
||||
@Nullable
|
||||
public PyClassType getOldstyleClassobjType() {
|
||||
return getObjectType("___Classobj");
|
||||
return getObjectType(PyNames.FAKE_OLD_BASE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -256,6 +256,14 @@ public class PyClassType extends UserDataHolderBase implements PyCallableType {
|
||||
|
||||
addInheritedMembers(prefix, location, context, ret);
|
||||
|
||||
if (!myClass.isNewStyleClass()) {
|
||||
final PyBuiltinCache cache = PyBuiltinCache.getInstance(myClass);
|
||||
final PyClassType classobjType = cache.getOldstyleClassobjType();
|
||||
if (classobjType != null) {
|
||||
ret.addAll(Arrays.asList(classobjType.getCompletionVariants(prefix, location, context)));
|
||||
}
|
||||
}
|
||||
|
||||
if (isDefinition() && myClass.isNewStyleClass()) {
|
||||
PyClassType typeType = PyBuiltinCache.getInstance(myClass).getObjectType("type");
|
||||
if (typeType != null) {
|
||||
@@ -385,7 +393,7 @@ public class PyClassType extends UserDataHolderBase implements PyCallableType {
|
||||
public String toString() {
|
||||
return (isValid() ? "" : "[INVALID] ") + "PyClassType: " + getClassQName();
|
||||
}
|
||||
|
||||
|
||||
public boolean isValid() {
|
||||
return myClass == null || myClass.isValid();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class C:
|
||||
pass
|
||||
c = C()
|
||||
c.__class__
|
||||
@@ -0,0 +1,4 @@
|
||||
class C:
|
||||
pass
|
||||
c = C()
|
||||
c.__cla<caret>
|
||||
@@ -487,23 +487,23 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
public void testImportKeyword() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testAssignedNearby() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testDunderAll() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
|
||||
public void testAsName() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
|
||||
public void testKeywordArgumentsForImplicitCall() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testTypeMembers() { // PY-5311
|
||||
myFixture.configureByText(PythonFileType.INSTANCE, "a = 'string'\n" +
|
||||
"a.<caret>");
|
||||
@@ -512,8 +512,12 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
final List<String> strings = myFixture.getLookupElementStrings();
|
||||
assertFalse(strings.contains("mro"));
|
||||
}
|
||||
|
||||
|
||||
public void testDunderAllReference() { // PY-5502
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOldStyleClassAttributes() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user