fixed remainig problems with imports. detected with py3k

This commit is contained in:
David Halter
2012-09-12 22:56:29 +02:00
parent 44c96e5b98
commit 0322aceeca
2 changed files with 10 additions and 8 deletions

View File

@@ -240,6 +240,13 @@ def get_definition(source, line, column, source_path):
:return: list of Definition objects, which are basically scopes.
:rtype: list
"""
def resolve_import_paths(scopes):
for s in scopes.copy():
if isinstance(s, imports.ImportPath):
scopes.remove(s)
scopes.update(resolve_import_paths(set(s.follow())))
return scopes
pos = (line, column)
f = modules.ModuleWithCursor(source_path, source=source, position=pos)
goto_path = f.get_path_under_cursor()
@@ -253,11 +260,7 @@ def get_definition(source, line, column, source_path):
else:
scopes = set(_prepare_goto(pos, source_path, f, goto_path))
for s in scopes.copy():
if isinstance(s, imports.ImportPath):
scopes.remove(s)
evaluate.statement_path = []
scopes.update(evaluate.goto([s]))
scopes = resolve_import_paths(scopes)
# add keywords
scopes |= keywords.get_keywords(string=goto_path, pos=pos)