use as name for completion of import elements (PY-3672)

This commit is contained in:
Dmitry Jemerov
2011-05-24 19:15:21 +04:00
parent 093ea5c106
commit 1e30440c4b
4 changed files with 11 additions and 2 deletions

View File

@@ -128,9 +128,10 @@ public class VariantsProcessor implements PsiScopeProcessor {
else if (element instanceof NameDefiner) {
boolean handled_as_imported = false;
if (element instanceof PyImportElement) {
PyReferenceExpression ref = ((PyImportElement)element).getImportReference();
final PyImportElement importElement = (PyImportElement)element;
PyReferenceExpression ref = importElement.getImportReference();
if (ref != null && ref.getQualifier() == null) {
String name = ref.getName();
String name = importElement.getAsName() != null ? importElement.getAsName() : ref.getName();
if (name != null && nameIsAcceptable(name)) {
PsiElement resolved = ref.getReference().resolve();
if (resolved instanceof PsiNamedElement) {

View File

@@ -0,0 +1,2 @@
import datetime as timedate
timedate

View File

@@ -0,0 +1,2 @@
import datetime as timedate
timeda<caret>

View File

@@ -380,4 +380,8 @@ public class PythonCompletionTest extends PyLightFixtureTestCase {
myFixture.completeBasic();
myFixture.checkResultByFile("completion/exportedConstants/a.after.py");
}
public void testAlias() { // PY-3672
doTest();
}
}