1
0
forked from VimPlug/jedi

Refactoring: Make Import.get_all_import_names return NameParts.

This commit is contained in:
Dave Halter
2014-09-19 01:40:05 +02:00
parent 83d2af5138
commit b2342c76be
5 changed files with 13 additions and 28 deletions

View File

@@ -28,14 +28,14 @@ def get_on_import_stmt(evaluator, user_context, user_stmt, is_like_search=False)
import_names = user_stmt.get_all_import_names()
kill_count = -1
cur_name_part = None
for i in import_names:
if user_stmt.alias == i:
for name in import_names:
if user_stmt.alias_name_part == name:
continue
for name_part in i.names:
if name_part.end_pos >= user_context.position:
if not cur_name_part:
cur_name_part = name_part
kill_count += 1
if name.end_pos >= user_context.position:
if not cur_name_part:
cur_name_part = name
kill_count += 1
context = user_context.get_context()
just_from = next(context) == 'from'

View File

@@ -70,11 +70,10 @@ def usages(evaluator, definitions, mods):
if isinstance(stmt, pr.Import):
count = 0
imps = []
for i in stmt.get_all_import_names():
for name_part in i.names:
count += 1
if unicode(name_part) == search_name:
imps.append((count, name_part))
for name in stmt.get_all_import_names():
count += 1
if unicode(name) == search_name:
imps.append((count, name))
for used_count, name_part in imps:
i = imports.ImportWrapper(evaluator, stmt, kill_count=count - used_count,