mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't show private module names from builtins in completion and mark them as unresolved (PY-7805)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user