mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-24 06:11:32 +08:00
Fixed __file__ issues by always applying a ModuleWrapper in the global scope lookup.
This commit is contained in:
@@ -205,11 +205,9 @@ class Script(object):
|
|||||||
scopes = list(self._prepare_goto(path, True))
|
scopes = list(self._prepare_goto(path, True))
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
scopes = []
|
scopes = []
|
||||||
scope = self._parser.user_scope()
|
scope_names_generator = get_names_of_scope(self._evaluator,
|
||||||
if isinstance(scope, pr.Module) \
|
self._parser.user_scope(),
|
||||||
and not isinstance(scope, interpreter.InterpreterNamespace):
|
self._pos)
|
||||||
scope = er.ModuleWrapper(self._evaluator, scope)
|
|
||||||
scope_names_generator = get_names_of_scope(self._evaluator, scope, self._pos)
|
|
||||||
completions = []
|
completions = []
|
||||||
for scope, name_list in scope_names_generator:
|
for scope, name_list in scope_names_generator:
|
||||||
for c in name_list:
|
for c in name_list:
|
||||||
@@ -288,11 +286,7 @@ class Script(object):
|
|||||||
stmt.start_pos = self._pos
|
stmt.start_pos = self._pos
|
||||||
else:
|
else:
|
||||||
stmt.start_pos = user_stmt.start_pos
|
stmt.start_pos = user_stmt.start_pos
|
||||||
scope = self._parser.user_scope()
|
stmt.parent = self._parser.user_scope()
|
||||||
if isinstance(scope, pr.Module) \
|
|
||||||
and not isinstance(scope, interpreter.InterpreterNamespace):
|
|
||||||
scope = er.ModuleWrapper(self._evaluator, scope)
|
|
||||||
stmt.parent = scope
|
|
||||||
return stmt
|
return stmt
|
||||||
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from itertools import chain
|
|||||||
|
|
||||||
from jedi._compatibility import hasattr, unicode, u, reraise
|
from jedi._compatibility import hasattr, unicode, u, reraise
|
||||||
from jedi.parser import representation as pr, tokenize
|
from jedi.parser import representation as pr, tokenize
|
||||||
|
from jedi.parser import fast
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import common
|
from jedi import common
|
||||||
from jedi import settings
|
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():
|
for g in scope.scope_names_generator():
|
||||||
yield g
|
yield g
|
||||||
else:
|
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)
|
yield scope, _get_defined_names_for_position(scope, position, in_func_scope)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
reraise(common.MultiLevelStopIteration, sys.exc_info()[2])
|
reraise(common.MultiLevelStopIteration, sys.exc_info()[2])
|
||||||
|
|||||||
Reference in New Issue
Block a user