1
0
forked from VimPlug/jedi

Reenable star import caching.

This commit is contained in:
Dave Halter
2014-12-15 15:19:22 +01:00
parent 24cfa62c8a
commit f2d35c3ff1
4 changed files with 6 additions and 7 deletions

View File

@@ -145,7 +145,7 @@ class Script(object):
# TODO this paragraph is necessary, but not sure it works. # TODO this paragraph is necessary, but not sure it works.
context = self._user_context.get_context() context = self._user_context.get_context()
print(next(self._user_context.get_context()), 'x') # print(next(self._user_context.get_context()), 'x')
if not next(context).startswith('.'): # skip the path if not next(context).startswith('.'): # skip the path
if next(context) == 'from': if next(context) == 'from':
# completion is just "import" if before stands from .. # completion is just "import" if before stands from ..

View File

@@ -166,9 +166,9 @@ def memoize(func):
def cache_star_import(func): def cache_star_import(func):
@time_cache("star_import_cache_validity") @time_cache("star_import_cache_validity")
def wrapper(evaluator, scope, *args, **kwargs): def wrapper(self):
yield scope # The cache key yield self.base # The cache key
yield func(evaluator, scope, *args, **kwargs) yield func(self)
return wrapper return wrapper

View File

@@ -46,7 +46,6 @@ def completion_names(evaluator, imp, pos):
if node.end_pos <= pos: if node.end_pos <= pos:
if node in ('.', '...'): if node in ('.', '...'):
level += len(node.value) level += len(node.value)
print(node, level)
import_path = [] import_path = []
else: else:
# Completion on an existing name. # Completion on an existing name.
@@ -127,7 +126,6 @@ class ImportWrapper(pr.Base):
self._evaluator.find_types(s, rest[0], is_goto=True) self._evaluator.find_types(s, rest[0], is_goto=True)
for s in scopes)) for s in scopes))
else: else:
print(self._import, scopes, rest)
if self._import.type == 'import_from' \ if self._import.type == 'import_from' \
or importer.str_import_path == ('os', 'path'): or importer.str_import_path == ('os', 'path'):
scopes = importer.follow_rest(scopes[0], rest) scopes = importer.follow_rest(scopes[0], rest)

View File

@@ -36,7 +36,7 @@ from jedi._compatibility import use_metaclass, unicode, Python3Method
from jedi.parser import tree as pr from jedi.parser import tree as pr
from jedi import debug from jedi import debug
from jedi import common from jedi import common
from jedi.cache import underscore_memoization from jedi.cache import underscore_memoization, cache_star_import
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
from jedi.evaluate import compiled from jedi.evaluate import compiled
from jedi.evaluate import recursion from jedi.evaluate import recursion
@@ -754,6 +754,7 @@ class ModuleWrapper(use_metaclass(CachedMetaClass, pr.Module, Wrapper)):
if sub_modules: if sub_modules:
yield self, self._sub_modules() yield self, self._sub_modules()
@cache_star_import
@memoize_default([]) @memoize_default([])
def star_imports(self): def star_imports(self):
modules = [] modules = []