forked from VimPlug/jedi
position_nr -> position_index
This commit is contained in:
@@ -103,13 +103,13 @@ class ParamName(AbstractTreeName):
|
|||||||
def get_param(self):
|
def get_param(self):
|
||||||
params = self.parent_context.get_params()
|
params = self.parent_context.get_params()
|
||||||
param_node = search_ancestor(self.tree_name, 'param')
|
param_node = search_ancestor(self.tree_name, 'param')
|
||||||
return params[param_node.position_nr]
|
return params[param_node.position_index]
|
||||||
|
|
||||||
|
|
||||||
class AnonymousInstanceParamName(ParamName):
|
class AnonymousInstanceParamName(ParamName):
|
||||||
def infer(self):
|
def infer(self):
|
||||||
param_node = search_ancestor(self.tree_name, 'param')
|
param_node = search_ancestor(self.tree_name, 'param')
|
||||||
if param_node.position_nr == 0:
|
if param_node.position_index == 0:
|
||||||
# This is a speed optimization, to return the self param (because
|
# This is a speed optimization, to return the self param (because
|
||||||
# it's known). This only affects anonymous instances.
|
# it's known). This only affects anonymous instances.
|
||||||
return set([self.parent_context.instance])
|
return set([self.parent_context.instance])
|
||||||
|
|||||||
@@ -222,11 +222,6 @@ class ExecutedParam(object):
|
|||||||
|
|
||||||
return self._lazy_context.infer()
|
return self._lazy_context.infer()
|
||||||
|
|
||||||
@property
|
|
||||||
def position_nr(self):
|
|
||||||
# Need to use the original logic here, because it uses the parent.
|
|
||||||
return self._param_node.position_nr
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def var_args(self):
|
def var_args(self):
|
||||||
return self._execution_context.var_args
|
return self._execution_context.var_args
|
||||||
|
|||||||
@@ -963,7 +963,10 @@ class Param(PythonBaseNode):
|
|||||||
return self._tfpdef()
|
return self._tfpdef()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def position_nr(self):
|
def position_index(self):
|
||||||
|
"""
|
||||||
|
Returns the positional index of a paramter.
|
||||||
|
"""
|
||||||
index = self.parent.children.index(self)
|
index = self.parent.children.index(self)
|
||||||
try:
|
try:
|
||||||
keyword_only_index = self.parent.children.index('*')
|
keyword_only_index = self.parent.children.index('*')
|
||||||
@@ -975,6 +978,9 @@ class Param(PythonBaseNode):
|
|||||||
return index - 1
|
return index - 1
|
||||||
|
|
||||||
def get_parent_function(self):
|
def get_parent_function(self):
|
||||||
|
"""
|
||||||
|
Returns the function/lambda a paramter is defined in.
|
||||||
|
"""
|
||||||
return search_ancestor(self, ('funcdef', 'lambdef'))
|
return search_ancestor(self, ('funcdef', 'lambdef'))
|
||||||
|
|
||||||
def get_description(self):
|
def get_description(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user