forked from VimPlug/jedi
fix Completion.parent() issues with builtins
This commit is contained in:
@@ -340,8 +340,11 @@ class BaseDefinition(object):
|
|||||||
return [_Param(self._evaluator, p) for p in params]
|
return [_Param(self._evaluator, p) for p in params]
|
||||||
|
|
||||||
def parent(self):
|
def parent(self):
|
||||||
scope = self._definition.get_parent_until(pr.IsScope, include_current=False)
|
if isinstance(self._definition, compiled.CompiledObject):
|
||||||
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
|
non_flow = self._definition.parent
|
||||||
|
else:
|
||||||
|
scope = self._definition.get_parent_until(pr.IsScope, include_current=False)
|
||||||
|
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
|
||||||
return Definition(self._evaluator, non_flow)
|
return Definition(self._evaluator, non_flow)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ def test_line_number_errors():
|
|||||||
|
|
||||||
def _check_number(source, result='float'):
|
def _check_number(source, result='float'):
|
||||||
completions = api.Script(source).completions()
|
completions = api.Script(source).completions()
|
||||||
#assert completions[0].parent().name == result
|
assert completions[0].parent().name == result
|
||||||
assert completions[0]._definition.parent.name == result
|
|
||||||
|
|
||||||
|
|
||||||
def test_completion_on_number_literals():
|
def test_completion_on_number_literals():
|
||||||
|
|||||||
Reference in New Issue
Block a user