forked from VimPlug/jedi
Even more refactorings
This commit is contained in:
@@ -365,8 +365,7 @@ class Script(object):
|
|||||||
|
|
||||||
:rtype: list of :class:`classes.CallSignature`
|
:rtype: list of :class:`classes.CallSignature`
|
||||||
"""
|
"""
|
||||||
call_details = \
|
call_details = helpers.get_call_signature_details(self._module_node, self._pos)
|
||||||
helpers.get_call_signature_details(self._module_node, self._pos)
|
|
||||||
if call_details is None:
|
if call_details is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ class CallSignature(Definition):
|
|||||||
return i
|
return i
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self._call_details.call_index >= len(self.params):
|
if self._call_details.index >= len(self.params):
|
||||||
for i, param in enumerate(self.params):
|
for i, param in enumerate(self.params):
|
||||||
tree_name = param._name.tree_name
|
tree_name = param._name.tree_name
|
||||||
if tree_name is not None:
|
if tree_name is not None:
|
||||||
@@ -634,7 +634,7 @@ class CallSignature(Definition):
|
|||||||
if tree_name.get_definition().star_count == 1:
|
if tree_name.get_definition().star_count == 1:
|
||||||
return i
|
return i
|
||||||
return None
|
return None
|
||||||
return self._call_details.call_index
|
return self._call_details.index
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def params(self):
|
def params(self):
|
||||||
@@ -657,7 +657,7 @@ class CallSignature(Definition):
|
|||||||
return '<%s: %s index=%r params=[%s]>' % (
|
return '<%s: %s index=%r params=[%s]>' % (
|
||||||
type(self).__name__,
|
type(self).__name__,
|
||||||
self._name.string_name,
|
self._name.string_name,
|
||||||
self._index,
|
self.index,
|
||||||
self._params_str,
|
self._params_str,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -159,10 +159,20 @@ def evaluate_goto_definition(evaluator, context, leaf):
|
|||||||
return definitions
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
CallDetails = namedtuple(
|
class CallDetails(object):
|
||||||
'CallDetails',
|
def __init__(self, bracket_leaf, children, position):
|
||||||
['bracket_leaf', 'call_index', 'keyword_name_str']
|
['bracket_leaf', 'call_index', 'keyword_name_str']
|
||||||
)
|
self.bracket_leaf = bracket_leaf
|
||||||
|
self._children = children
|
||||||
|
self._position = position
|
||||||
|
|
||||||
|
@property
|
||||||
|
def index(self):
|
||||||
|
return _get_index_and_key(self._children, self._position)[0]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keyword_name_str(self):
|
||||||
|
return _get_index_and_key(self._children, self._position)[1]
|
||||||
|
|
||||||
|
|
||||||
def _get_index_and_key(nodes, position):
|
def _get_index_and_key(nodes, position):
|
||||||
@@ -198,10 +208,7 @@ def _get_call_signature_details_from_error_node(node, position):
|
|||||||
if name is None:
|
if name is None:
|
||||||
continue
|
continue
|
||||||
if name.type == 'name' or name.parent.type in ('trailer', 'atom'):
|
if name.type == 'name' or name.parent.type in ('trailer', 'atom'):
|
||||||
return CallDetails(
|
return CallDetails(element, children, position)
|
||||||
element,
|
|
||||||
*_get_index_and_key(children, position)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_call_signature_details(module, position):
|
def get_call_signature_details(module, position):
|
||||||
@@ -213,6 +220,7 @@ def get_call_signature_details(module, position):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if leaf == ')':
|
if leaf == ')':
|
||||||
|
# TODO is this ok?
|
||||||
if leaf.end_pos == position:
|
if leaf.end_pos == position:
|
||||||
leaf = leaf.get_next_leaf()
|
leaf = leaf.get_next_leaf()
|
||||||
|
|
||||||
@@ -235,8 +243,7 @@ def get_call_signature_details(module, position):
|
|||||||
leaf = node.get_previous_leaf()
|
leaf = node.get_previous_leaf()
|
||||||
if leaf is None:
|
if leaf is None:
|
||||||
return None
|
return None
|
||||||
return CallDetails(
|
return CallDetails(node.children[0], node.children, position)
|
||||||
node.children[0], *_get_index_and_key(node.children, position))
|
|
||||||
|
|
||||||
node = node.parent
|
node = node.parent
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user