mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-16 02:27:06 +08:00
Limit dynamic param searches to not go crazy in a lot of occasions. Refs #574.
This commit is contained in:
@@ -26,6 +26,9 @@ from jedi.evaluate.cache import memoize_default
|
|||||||
from jedi.evaluate import imports
|
from jedi.evaluate import imports
|
||||||
|
|
||||||
|
|
||||||
|
MAX_PARAM_SEARCHES = 10
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
@@ -54,9 +57,6 @@ def search_params(evaluator, param):
|
|||||||
if not settings.dynamic_params:
|
if not settings.dynamic_params:
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
if evaluator.dynamic_params_depth == settings.max_dynamic_params_depth:
|
|
||||||
return set()
|
|
||||||
|
|
||||||
evaluator.dynamic_params_depth += 1
|
evaluator.dynamic_params_depth += 1
|
||||||
try:
|
try:
|
||||||
func = param.get_parent_until(tree.Function)
|
func = param.get_parent_until(tree.Function)
|
||||||
@@ -123,6 +123,12 @@ def search_function_call(evaluator, func):
|
|||||||
for name, trailer in get_possible_nodes(mod, func_name):
|
for name, trailer in get_possible_nodes(mod, func_name):
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
# This is a simple way to stop Jedi's dynamic param recursion
|
||||||
|
# from going wild: The deeper Jedi's in the recursin, the less
|
||||||
|
# code should be evaluated.
|
||||||
|
if i * evaluator.dynamic_params_depth > MAX_PARAM_SEARCHES:
|
||||||
|
return listener.param_possibilities
|
||||||
|
|
||||||
for typ in evaluator.goto_definitions(name):
|
for typ in evaluator.goto_definitions(name):
|
||||||
undecorated = undecorate(typ)
|
undecorated = undecorate(typ)
|
||||||
if evaluator.wrap(compare) == undecorated:
|
if evaluator.wrap(compare) == undecorated:
|
||||||
|
|||||||
@@ -208,12 +208,6 @@ max_executions = 250
|
|||||||
A maximum amount of time, the completion may use.
|
A maximum amount of time, the completion may use.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
max_dynamic_params_depth = 3
|
|
||||||
"""
|
|
||||||
A maximum amount of a recursive search function calls, when the type of a
|
|
||||||
parameter is needed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
scale_call_signatures = 0.1
|
scale_call_signatures = 0.1
|
||||||
"""
|
"""
|
||||||
Because call_signatures is normally used on every single key hit, it has
|
Because call_signatures is normally used on every single key hit, it has
|
||||||
|
|||||||
@@ -219,5 +219,6 @@ cls().s
|
|||||||
|
|
||||||
import zipfile
|
import zipfile
|
||||||
z = zipfile.ZipFile("foo")
|
z = zipfile.ZipFile("foo")
|
||||||
#? ['upper']
|
# It's too slow. So we don't run it at the moment.
|
||||||
|
##? ['upper']
|
||||||
z.read('name').upper
|
z.read('name').upper
|
||||||
|
|||||||
Reference in New Issue
Block a user