1
0
forked from VimPlug/jedi

remove old way of using a separate decorator for search param memoization, use the default one

This commit is contained in:
Dave Halter
2013-12-26 02:31:18 +01:00
parent 8f564a301f
commit 84c2be9f58
2 changed files with 3 additions and 22 deletions

View File

@@ -14,7 +14,6 @@ from jedi import cache
from jedi.evaluate import representation as er from jedi.evaluate import representation as er
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi import keywords from jedi import keywords
from jedi.evaluate import dynamic
def clear_caches(): def clear_caches():
@@ -23,7 +22,6 @@ def clear_caches():
be deleted is the module cache. be deleted is the module cache.
""" """
cache.clear_caches() cache.clear_caches()
dynamic.search_param_cache.clear()
def _clear_caches_after_call(func): def _clear_caches_after_call(func):

View File

@@ -64,7 +64,6 @@ from jedi.evaluate.cache import memoize_default
# This is something like the sys.path, but only for searching params. It means # This is something like the sys.path, but only for searching params. It means
# that this is the order in which Jedi searches params. # that this is the order in which Jedi searches params.
search_param_modules = ['.'] search_param_modules = ['.']
search_param_cache = {}
def get_directory_modules_for_name(mods, name): def get_directory_modules_for_name(mods, name):
@@ -110,22 +109,6 @@ def get_directory_modules_for_name(mods, name):
yield c yield c
def _search_param_memoize(func):
"""
Is only good for search params memoize, respectively the closure,
because it just caches the input, not the func, like normal memoize does.
"""
def wrapper(*args, **kwargs):
key = (args, frozenset(kwargs.items()))
if key in search_param_cache:
return search_param_cache[key]
else:
rv = func(*args, **kwargs)
search_param_cache[key] = rv
return rv
return wrapper
class ParamListener(object): class ParamListener(object):
""" """
This listener is used to get the params for a function. This listener is used to get the params for a function.
@@ -158,8 +141,8 @@ def search_params(evaluator, param):
""" """
Returns the values of a param, or an empty array. Returns the values of a param, or an empty array.
""" """
@_search_param_memoize @memoize_default([], evaluator_is_first_arg=True)
def get_posibilities(module, func_name): def get_posibilities(evaluator, module, func_name):
try: try:
possible_stmts = module.used_names[func_name] possible_stmts = module.used_names[func_name]
except KeyError: except KeyError:
@@ -209,7 +192,7 @@ def search_params(evaluator, param):
return listener.param_possibilities return listener.param_possibilities
result = [] result = []
for params in get_posibilities(module, func_name): for params in get_posibilities(evaluator, module, func_name):
for p in params: for p in params:
if str(p) == param_name: if str(p) == param_name:
result += evaluator.follow_statement(p.parent) result += evaluator.follow_statement(p.parent)