forked from VimPlug/jedi
somehow temporary solution to enable completion of __file__
This commit is contained in:
@@ -205,9 +205,11 @@ class Script(object):
|
|||||||
scopes = list(self._prepare_goto(path, True))
|
scopes = list(self._prepare_goto(path, True))
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
scopes = []
|
scopes = []
|
||||||
scope_names_generator = get_names_of_scope(self._evaluator,
|
scope = self._parser.user_scope()
|
||||||
self._parser.user_scope(),
|
if isinstance(scope, pr.Module) \
|
||||||
self._pos)
|
and not isinstance(scope, interpreter.InterpreterNamespace):
|
||||||
|
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:
|
||||||
@@ -286,7 +288,11 @@ 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
|
||||||
stmt.parent = self._parser.user_scope()
|
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
|
||||||
return stmt
|
return stmt
|
||||||
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
|
|||||||
@@ -554,6 +554,10 @@ class ModuleWrapper(use_metaclass(CachedMetaClass, pr.Module)):
|
|||||||
|
|
||||||
@memoize_default()
|
@memoize_default()
|
||||||
def _sub_modules(self):
|
def _sub_modules(self):
|
||||||
|
"""
|
||||||
|
Lists modules in the directory of this module (if this module is a
|
||||||
|
package).
|
||||||
|
"""
|
||||||
path = self._module.path
|
path = self._module.path
|
||||||
names = []
|
names = []
|
||||||
if path.endswith(os.path.sep + '__init__.py'):
|
if path.endswith(os.path.sep + '__init__.py'):
|
||||||
|
|||||||
@@ -365,3 +365,13 @@ if foo is not None:
|
|||||||
foo = ''.join(foo)
|
foo = ''.join(foo)
|
||||||
#? str()
|
#? str()
|
||||||
foo
|
foo
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# module attributes
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
# Don't move this to imports.py, because there's a star import.
|
||||||
|
#? str()
|
||||||
|
__file__
|
||||||
|
#? ['__file__']
|
||||||
|
__file__
|
||||||
|
|||||||
@@ -75,9 +75,8 @@ def test_star_import_cache_duration():
|
|||||||
|
|
||||||
# reset values
|
# reset values
|
||||||
jedi.settings.star_import_cache_validity = old
|
jedi.settings.star_import_cache_validity = old
|
||||||
length = len(cache._star_import_cache)
|
assert len(cache._star_import_cache) == 1
|
||||||
cache._star_import_cache = {}
|
cache._star_import_cache = {}
|
||||||
assert length == 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_cache_call_signatures():
|
def test_cache_call_signatures():
|
||||||
|
|||||||
Reference in New Issue
Block a user