mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
Fix some old regression tests.
This commit is contained in:
@@ -195,7 +195,7 @@ class Script(object):
|
|||||||
if leaf is None:
|
if leaf is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
context = self._evaluator.create_context(self._get_module(), leaf)
|
context = self._evaluator.create_context(self._get_module(), leaf.parent)
|
||||||
definitions = helpers.evaluate_goto_definition(self._evaluator, context, leaf)
|
definitions = helpers.evaluate_goto_definition(self._evaluator, context, leaf)
|
||||||
|
|
||||||
names = [s.name for s in definitions]
|
names = [s.name for s in definitions]
|
||||||
|
|||||||
@@ -431,8 +431,12 @@ class Evaluator(object):
|
|||||||
def_ = name.get_definition()
|
def_ = name.get_definition()
|
||||||
is_simple_name = name.parent.type not in ('power', 'trailer')
|
is_simple_name = name.parent.type not in ('power', 'trailer')
|
||||||
if is_simple_name:
|
if is_simple_name:
|
||||||
if name.parent.type in ('file_input', 'classdef', 'funcdef'):
|
if name.parent.type == 'classdef':
|
||||||
return [self.wrap(name.parent)]
|
return [er.ClassContext(self, name.parent, context)]
|
||||||
|
elif name.parent.type == 'funcdef':
|
||||||
|
return [er.FunctionContext(self, context, name.parent)]
|
||||||
|
elif name.parent.type == 'file_input':
|
||||||
|
raise NotImplementedError
|
||||||
if def_.type == 'expr_stmt' and name in def_.get_defined_names():
|
if def_.type == 'expr_stmt' and name in def_.get_defined_names():
|
||||||
return self.eval_statement(context, def_, name)
|
return self.eval_statement(context, def_, name)
|
||||||
elif def_.type == 'for_stmt':
|
elif def_.type == 'for_stmt':
|
||||||
|
|||||||
@@ -174,7 +174,8 @@ class TestRegression(TestCase):
|
|||||||
for i in range(2):
|
for i in range(2):
|
||||||
completions = Script('').completions()
|
completions = Script('').completions()
|
||||||
c = get_str_completion(completions)
|
c = get_str_completion(completions)
|
||||||
n = len(c._definition.subscopes[0].children[-1].children)
|
str_context, = c._name.infer()
|
||||||
|
n = len(str_context.classdef.children[-1].children)
|
||||||
if i == 0:
|
if i == 0:
|
||||||
limit = n
|
limit = n
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user