mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
fix more issues and renamings
This commit is contained in:
@@ -103,14 +103,14 @@ def cache_call_signatures(stmt):
|
|||||||
|
|
||||||
|
|
||||||
def cache_star_import(func):
|
def cache_star_import(func):
|
||||||
def wrapper(scope, *args, **kwargs):
|
def wrapper(evaluator, scope, *args, **kwargs):
|
||||||
with common.ignored(KeyError):
|
with common.ignored(KeyError):
|
||||||
mods = star_import_cache[scope]
|
mods = star_import_cache[scope]
|
||||||
if mods[0] + settings.star_import_cache_validity > time.time():
|
if mods[0] + settings.star_import_cache_validity > time.time():
|
||||||
return mods[1]
|
return mods[1]
|
||||||
# cache is too old and therefore invalid or not available
|
# cache is too old and therefore invalid or not available
|
||||||
invalidate_star_import_cache(scope)
|
invalidate_star_import_cache(scope)
|
||||||
mods = func(scope, *args, **kwargs)
|
mods = func(evaluator, scope, *args, **kwargs)
|
||||||
star_import_cache[scope] = time.time(), mods
|
star_import_cache[scope] = time.time(), mods
|
||||||
|
|
||||||
return mods
|
return mods
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ DOCSTRING_RETURN_PATTERNS = [
|
|||||||
REST_ROLE_PATTERN = re.compile(r':[^`]+:`([^`]+)`')
|
REST_ROLE_PATTERN = re.compile(r':[^`]+:`([^`]+)`')
|
||||||
|
|
||||||
|
|
||||||
@memoize_default(None, is_function=True)
|
@memoize_default(None, evaluator_is_first_arg=True)
|
||||||
def follow_param(evaluator, param):
|
def follow_param(evaluator, param):
|
||||||
func = param.parent_function
|
func = param.parent_function
|
||||||
# print func, param, param.parent_function
|
# print func, param, param.parent_function
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ class Evaluator(object):
|
|||||||
return filter_name(scope_generator)
|
return filter_name(scope_generator)
|
||||||
return descriptor_check(remove_statements(filter_name(scope_generator)))
|
return descriptor_check(remove_statements(filter_name(scope_generator)))
|
||||||
|
|
||||||
@memoize_default(default=(), cache_is_in_self=True)
|
@memoize_default(default=(), evaluator_is_first_arg=True)
|
||||||
@recursion.recursion_decorator
|
@recursion.recursion_decorator
|
||||||
def follow_statement(self, stmt, seek_name=None):
|
def follow_statement(self, stmt, seek_name=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def memoize_default(default, cache_is_in_self=False, is_function=False,
|
def memoize_default(default, evaluator_is_first_arg=False, second_arg_is_evaluator=False):
|
||||||
first_arg_is_evaluator=False):
|
|
||||||
""" This is a typical memoization decorator, BUT there is one difference:
|
""" This is a typical memoization decorator, BUT there is one difference:
|
||||||
To prevent recursion it sets defaults.
|
To prevent recursion it sets defaults.
|
||||||
|
|
||||||
@@ -16,11 +15,9 @@ def memoize_default(default, cache_is_in_self=False, is_function=False,
|
|||||||
"""
|
"""
|
||||||
def func(function):
|
def func(function):
|
||||||
def wrapper(obj, *args, **kwargs):
|
def wrapper(obj, *args, **kwargs):
|
||||||
if is_function:
|
if evaluator_is_first_arg:
|
||||||
cache = obj
|
|
||||||
elif cache_is_in_self:
|
|
||||||
cache = obj.memoize_cache
|
cache = obj.memoize_cache
|
||||||
elif first_arg_is_evaluator: # needed for meta classes
|
elif second_arg_is_evaluator: # needed for meta classes
|
||||||
cache = args[0].memoize_cache
|
cache = args[0].memoize_cache
|
||||||
else:
|
else:
|
||||||
cache = obj._evaluator.memoize_cache
|
cache = obj._evaluator.memoize_cache
|
||||||
@@ -49,6 +46,6 @@ class CachedMetaClass(type):
|
|||||||
class initializations. I haven't found any other way, so I'm doing it with
|
class initializations. I haven't found any other way, so I'm doing it with
|
||||||
meta classes.
|
meta classes.
|
||||||
"""
|
"""
|
||||||
@memoize_default(None, first_arg_is_evaluator=True)
|
@memoize_default(None, second_arg_is_evaluator=True)
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
return super(CachedMetaClass, self).__call__(*args, **kwargs)
|
return super(CachedMetaClass, self).__call__(*args, **kwargs)
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class ParamListener(object):
|
|||||||
self.param_possibilities.append(params)
|
self.param_possibilities.append(params)
|
||||||
|
|
||||||
|
|
||||||
@memoize_default([], is_function=True)
|
@memoize_default([], evaluator_is_first_arg=True)
|
||||||
def search_params(evaluator, param):
|
def search_params(evaluator, param):
|
||||||
"""
|
"""
|
||||||
This is a dynamic search for params. If you try to complete a type:
|
This is a dynamic search for params. If you try to complete a type:
|
||||||
|
|||||||
Reference in New Issue
Block a user