use correct name when completing imported module (PY-1955); add icon

This commit is contained in:
Dmitry Jemerov
2010-09-23 15:37:39 +04:00
parent bf7d533aef
commit 011c1e4a51
4 changed files with 17 additions and 3 deletions
@@ -104,12 +104,12 @@ public class VariantsProcessor implements PsiScopeProcessor {
if (element instanceof PyImportElement) {
PyReferenceExpression ref = ((PyImportElement)element).getImportReference();
if (ref != null) {
final String name = ref.getName();
if (nameIsAcceptable(name)) {
String name = ref.getName();
if (name != null && nameIsAcceptable(name)) {
PsiElement resolved = ref.getReference().resolve();
if (resolved instanceof PsiNamedElement) {
handled_as_imported = true;
myVariants.put(name, setupItem(LookupElementBuilder.create((PsiNamedElement)resolved)));
myVariants.put(name, setupItem(LookupElementBuilder.create(resolved, name).setIcon(resolved.getIcon(0))));
}
}
}
@@ -0,0 +1,3 @@
from root import nested_mod
n = nested_mod
@@ -0,0 +1,3 @@
from root import nested_mod
n = nested_m<caret>
@@ -213,4 +213,12 @@ public class PythonCompletionTest extends PyLightFixtureTestCase {
myFixture.completeBasic();
myFixture.checkResultByFile("completion/importItself.after.py");
}
public void testImportedFile() { // PY-1955
final String dirname = "completion/";
myFixture.copyDirectoryToProject(dirname + "root", dirname + "root");
myFixture.configureByFile(dirname + "importedFile.py");
myFixture.completeBasic();
myFixture.checkResultByFile(dirname + "importedFile.after.py");
}
}