Skip to content

Commit

Permalink
Fix some old regression tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Dec 7, 2016
1 parent 97ccb74 commit 2be5da3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jedi/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def goto_definitions(self):
if leaf is None:
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)

names = [s.name for s in definitions]
Expand Down
8 changes: 6 additions & 2 deletions jedi/evaluate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,12 @@ def goto_definitions(self, context, name):
def_ = name.get_definition()
is_simple_name = name.parent.type not in ('power', 'trailer')
if is_simple_name:
if name.parent.type in ('file_input', 'classdef', 'funcdef'):
return [self.wrap(name.parent)]
if name.parent.type == 'classdef':
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():
return self.eval_statement(context, def_, name)
elif def_.type == 'for_stmt':
Expand Down
3 changes: 2 additions & 1 deletion test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def get_str_completion(values):
for i in range(2):
completions = Script('').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:
limit = n
else:
Expand Down

0 comments on commit 2be5da3

Please sign in to comment.