1
0
forked from VimPlug/jedi

call signature -> signature

This commit is contained in:
Dave Halter
2019-12-20 19:41:57 +01:00
parent 694b05bb8c
commit 5fc308f1f8
20 changed files with 101 additions and 101 deletions

View File

@@ -377,12 +377,12 @@ class Script(object):
:rtype: list of :class:`classes.Signature`
"""
pos = line, column
call_details = helpers.get_call_signature_details(self._module_node, pos)
call_details = helpers.get_signature_details(self._module_node, pos)
if call_details is None:
return []
context = self._get_module_context().create_context(call_details.bracket_leaf)
definitions = helpers.cache_call_signatures(
definitions = helpers.cache_signatures(
self._inference_state,
context,
call_details.bracket_leaf,

View File

@@ -225,7 +225,7 @@ class BaseDefinition(object):
Document for function f.
Notice that useful extra information is added to the actual
docstring. For function, it is call signature. If you need
docstring. For function, it is signature. If you need
actual docstring, use ``raw=True`` instead.
>>> print(script.infer(1, len('def f'))[0].docstring(raw=True))

View File

@@ -18,9 +18,9 @@ from jedi.inference.gradual.conversion import convert_values
from jedi.parser_utils import cut_value_at_position
def get_call_signature_param_names(call_signatures):
def get_signature_param_names(signatures):
# add named params
for call_sig in call_signatures:
for call_sig in signatures:
for p in call_sig.params:
# Allow protected access, because it's a public API.
if p._name.get_kind() in (Parameter.POSITIONAL_OR_KEYWORD,
@@ -74,7 +74,7 @@ def get_flow_scope_node(module_node, position):
class Completion:
def __init__(self, inference_state, module_context, code_lines, position,
call_signatures_callback, fuzzy=False):
signatures_callback, fuzzy=False):
self._inference_state = inference_state
self._module_context = module_context
self._module_node = module_context.tree_node
@@ -86,7 +86,7 @@ class Completion:
# everything. We want the start of the name we're on.
self._original_position = position
self._position = position[0], position[1] - len(self._like_name)
self._call_signatures_callback = call_signatures_callback
self._signatures_callback = signatures_callback
self._fuzzy = fuzzy
@@ -96,7 +96,7 @@ class Completion:
if string is not None:
completions = list(complete_file_name(
self._inference_state, self._module_context, start_leaf, string,
self._like_name, self._call_signatures_callback,
self._like_name, self._signatures_callback,
self._code_lines, self._original_position,
fuzzy
))
@@ -226,8 +226,8 @@ class Completion:
# 3. Decorators are very primitive and have an optional `(` with
# optional arglist in them.
if nodes[-1] in ['(', ','] and nonterminals[-1] in ('trailer', 'arglist', 'decorator'):
call_signatures = self._call_signatures_callback(*self._position)
completion_names += get_call_signature_param_names(call_signatures)
signatures = self._signatures_callback(*self._position)
completion_names += get_signature_param_names(signatures)
return completion_names

View File

@@ -9,7 +9,7 @@ from jedi.parser_utils import get_string_quote
def complete_file_name(inference_state, module_context, start_leaf, string,
like_name, call_signatures_callback, code_lines, position, fuzzy):
like_name, signatures_callback, code_lines, position, fuzzy):
# First we want to find out what can actually be changed as a name.
like_name_length = len(os.path.basename(string) + like_name)
@@ -23,7 +23,7 @@ def complete_file_name(inference_state, module_context, start_leaf, string,
must_start_with = os.path.basename(string) + like_name
string = os.path.dirname(string)
sigs = call_signatures_callback(*position)
sigs = signatures_callback(*position)
is_in_os_path_join = sigs and all(s.full_name == 'os.path.join' for s in sigs)
if is_in_os_path_join:
to_be_added = _add_os_path_join(module_context, start_leaf, sigs[0].bracket_start)

View File

@@ -14,7 +14,7 @@ from jedi.inference.base_value import NO_VALUES
from jedi.inference.syntax_tree import infer_atom
from jedi.inference.helpers import infer_call_of_leaf
from jedi.inference.compiled import get_string_value_set
from jedi.cache import call_signature_time_cache
from jedi.cache import signature_time_cache
CompletionParts = namedtuple('CompletionParts', ['path', 'has_dot', 'name'])
@@ -326,7 +326,7 @@ def _get_index_and_key(nodes, position):
return nodes_before.count(','), key_str
def _get_call_signature_details_from_error_node(node, additional_children, position):
def _get_signature_details_from_error_node(node, additional_children, position):
for index, element in reversed(list(enumerate(node.children))):
# `index > 0` means that it's a trailer and not an atom.
if element == '(' and element.end_pos <= position and index > 0:
@@ -340,7 +340,7 @@ def _get_call_signature_details_from_error_node(node, additional_children, posit
return CallDetails(element, children + additional_children, position)
def get_call_signature_details(module, position):
def get_signature_details(module, position):
leaf = module.get_leaf_for_position(position, include_prefixes=True)
# It's easier to deal with the previous token than the next one in this
# case.
@@ -355,15 +355,15 @@ def get_call_signature_details(module, position):
node = leaf.parent
while node is not None:
if node.type in ('funcdef', 'classdef'):
# Don't show call signatures if there's stuff before it that just
# makes it feel strange to have a call signature.
# Don't show signatures if there's stuff before it that just
# makes it feel strange to have a signature.
return None
additional_children = []
for n in reversed(node.children):
if n.start_pos < position:
if n.type == 'error_node':
result = _get_call_signature_details_from_error_node(
result = _get_signature_details_from_error_node(
n, additional_children, position
)
if result is not None:
@@ -390,8 +390,8 @@ def get_call_signature_details(module, position):
return None
@call_signature_time_cache("call_signatures_validity")
def cache_call_signatures(inference_state, context, bracket_leaf, code_lines, user_pos):
@signature_time_cache("call_signatures_validity")
def cache_signatures(inference_state, context, bracket_leaf, code_lines, user_pos):
"""This function calculates the cache key."""
line_index = user_pos[0] - 1