Don't show private module names from builtins in completion and mark them as unresolved (PY-7805)

This commit is contained in:
Andrey Vlasovskikh
2013-02-12 22:17:45 +04:00
parent 8603259282
commit 55f0826558
7 changed files with 18 additions and 1 deletions
@@ -307,7 +307,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
if (uexpr == null) {
// ...as a builtin symbol
PyFile bfile = builtins_cache.getBuiltinsFile();
if (bfile != null) {
if (bfile != null && !PyUtil.isClassPrivateName(referencedName)) {
uexpr = bfile.getElementNamed(referencedName);
if (uexpr == null && "__builtins__".equals(referencedName)) {
uexpr = bfile; // resolve __builtins__ reference
@@ -151,6 +151,9 @@ public class CompletionVariantsProcessor extends VariantsProcessor {
@Override
protected void addElement(String name, PsiElement element) {
if (PyUtil.isClassPrivateName(name) && !PyUtil.inSameFile(element, myContext)) {
return;
}
myVariants.put(name, setupItem(LookupElementBuilder.create(element, name).withIcon(element.getIcon(0))));
}
@@ -0,0 +1 @@
___Cl
@@ -0,0 +1 @@
___Cl<caret>
@@ -0,0 +1,2 @@
<error descr="Unresolved reference '___Classobj'">___Classobj</error>
__debug__
@@ -627,4 +627,9 @@ public class PythonCompletionTest extends PyTestCase {
"VAR = 2\n" +
"__all__ = ['VAR']");
}
// PY-7805
public void testNoUnderscoredBuiltin() {
doTest();
}
}
@@ -252,6 +252,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
doTest();
}
// PY-7805
public void testUnderscoredBuiltin() {
doTest();
}
private void doTest() {
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);