Fixed __file__ issues by always applying a ModuleWrapper in the global scope lookup.

This commit is contained in:
Dave Halter
2014-07-01 15:35:21 +02:00
parent 8d63e6f6e7
commit 3865c1a844
2 changed files with 7 additions and 10 deletions

View File

@@ -205,11 +205,9 @@ class Script(object):
scopes = list(self._prepare_goto(path, True))
except NotFoundError:
scopes = []
scope = self._parser.user_scope()
if isinstance(scope, pr.Module) \
and not isinstance(scope, interpreter.InterpreterNamespace):
scope = er.ModuleWrapper(self._evaluator, scope)
scope_names_generator = get_names_of_scope(self._evaluator, scope, self._pos)
scope_names_generator = get_names_of_scope(self._evaluator,
self._parser.user_scope(),
self._pos)
completions = []
for scope, name_list in scope_names_generator:
for c in name_list:
@@ -288,11 +286,7 @@ class Script(object):
stmt.start_pos = self._pos
else:
stmt.start_pos = user_stmt.start_pos
scope = self._parser.user_scope()
if isinstance(scope, pr.Module) \
and not isinstance(scope, interpreter.InterpreterNamespace):
scope = er.ModuleWrapper(self._evaluator, scope)
stmt.parent = scope
stmt.parent = self._parser.user_scope()
return stmt
def complete(self):

View File

@@ -16,6 +16,7 @@ from itertools import chain
from jedi._compatibility import hasattr, unicode, u, reraise
from jedi.parser import representation as pr, tokenize
from jedi.parser import fast
from jedi import debug
from jedi import common
from jedi import settings
@@ -513,6 +514,8 @@ def get_names_of_scope(evaluator, scope, position=None, star_search=True, includ
for g in scope.scope_names_generator():
yield g
else:
if isinstance(scope, (pr.SubModule, fast.Module)):
scope = er.ModuleWrapper(evaluator, scope)
yield scope, _get_defined_names_for_position(scope, position, in_func_scope)
except StopIteration:
reraise(common.MultiLevelStopIteration, sys.exc_info()[2])