Fixed completion of PyCustomMembers whose names don't match the names of resolved references (PY-14519)

This commit is contained in:
Andrey Vlasovskikh
2014-11-24 19:06:35 +03:00
parent 391ba2057c
commit 5bb6011d6d
7 changed files with 28 additions and 4 deletions
@@ -305,11 +305,16 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
final PsiElement resolved = member.resolve(location);
if (resolved != null) {
processor.execute(resolved, ResolveState.initial());
result.addAll(processor.getResultList());
}
else {
result.add(LookupElementBuilder.create(name).withIcon(member.getIcon()).withTypeText(member.getShortType()));
final List<LookupElement> lookupList = processor.getResultList();
if (!lookupList.isEmpty()) {
final LookupElement element = lookupList.get(0);
if (name.equals(element.getLookupString())) {
result.add(element);
continue;
}
}
}
result.add(LookupElementBuilder.create(name).withIcon(member.getIcon()).withTypeText(member.getShortType()));
}
}
if (point == PointInImport.NONE || point == PointInImport.AS_NAME) { // when not imported from, add regular attributes
@@ -0,0 +1,3 @@
import os
os.path
+3
View File
@@ -0,0 +1,3 @@
import os
os.pat<caret>
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
@@ -0,0 +1 @@
@@ -722,4 +722,14 @@ public class PythonCompletionTest extends PyTestCase {
assertNotNull(suggested);
assertSameElements(suggested, "VAR", "subpkg1");
}
// PY-14519
public void testOsPath() {
myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
myFixture.configureByFile("a.py");
myFixture.completeBasic();
final List<String> suggested = myFixture.getLookupElementStrings();
assertNotNull(suggested);
assertContainsElements(suggested, "path");
}
}