forked from VimPlug/jedi
Use different limits for references and dynamic calls
This commit is contained in:
@@ -119,7 +119,10 @@ def _search_function_arguments(module_context, funcdef, string_name):
|
|||||||
|
|
||||||
if settings.dynamic_params_for_other_modules:
|
if settings.dynamic_params_for_other_modules:
|
||||||
module_contexts = get_module_contexts_containing_name(
|
module_contexts = get_module_contexts_containing_name(
|
||||||
inference_state, [module_context], string_name)
|
inference_state, [module_context], string_name,
|
||||||
|
# Limit the amounts of files to be opened massively.
|
||||||
|
limit_reduction=10,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
module_contexts = [module_context]
|
module_contexts = [module_context]
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ def find_references(module_context, tree_name):
|
|||||||
potential_modules = get_module_contexts_containing_name(
|
potential_modules = get_module_contexts_containing_name(
|
||||||
inf,
|
inf,
|
||||||
module_contexts,
|
module_contexts,
|
||||||
search_name
|
search_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
non_matching_reference_maps = {}
|
non_matching_reference_maps = {}
|
||||||
@@ -236,9 +236,13 @@ def _find_python_files_in_sys_path(inference_state, module_contexts):
|
|||||||
folder_io = folder_io.get_parent_folder()
|
folder_io = folder_io.get_parent_folder()
|
||||||
|
|
||||||
|
|
||||||
def get_module_contexts_containing_name(inference_state, module_contexts, name):
|
def get_module_contexts_containing_name(inference_state, module_contexts, name,
|
||||||
|
limit_reduction=1):
|
||||||
"""
|
"""
|
||||||
Search a name in the directories of modules.
|
Search a name in the directories of modules.
|
||||||
|
|
||||||
|
:param limit_reduction: Divides the limits on opening/parsing files by this
|
||||||
|
factor.
|
||||||
"""
|
"""
|
||||||
# Skip non python modules
|
# Skip non python modules
|
||||||
for module_context in module_contexts:
|
for module_context in module_contexts:
|
||||||
@@ -251,6 +255,8 @@ def get_module_contexts_containing_name(inference_state, module_contexts, name):
|
|||||||
if len(name) <= 2:
|
if len(name) <= 2:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
parse_limit = _PARSED_FILE_LIMIT / limit_reduction
|
||||||
|
open_limit = _OPENED_FILE_LIMIT / limit_reduction
|
||||||
file_io_count = 0
|
file_io_count = 0
|
||||||
parsed_file_count = 0
|
parsed_file_count = 0
|
||||||
regex = re.compile(r'\b' + re.escape(name) + r'\b')
|
regex = re.compile(r'\b' + re.escape(name) + r'\b')
|
||||||
@@ -260,8 +266,8 @@ def get_module_contexts_containing_name(inference_state, module_contexts, name):
|
|||||||
if m is not None:
|
if m is not None:
|
||||||
parsed_file_count += 1
|
parsed_file_count += 1
|
||||||
yield m
|
yield m
|
||||||
if parsed_file_count > _PARSED_FILE_LIMIT:
|
if parsed_file_count > parse_limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
if file_io_count > _OPENED_FILE_LIMIT:
|
if file_io_count > open_limit:
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user