mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-25 09:48:36 +08:00
goto_definition on a name definition (statement) should land on the statement.
This commit is contained in:
+11
-3
@@ -420,9 +420,17 @@ class Script(object):
|
|||||||
definitions = set(signature._definition
|
definitions = set(signature._definition
|
||||||
for signature in self.call_signatures())
|
for signature in self.call_signatures())
|
||||||
|
|
||||||
if not definitions:
|
if re.match('\w[\w\d_]*$', goto_path) and not definitions:
|
||||||
if goto_path:
|
user_stmt = self._parser.user_stmt()
|
||||||
definitions = set(self._prepare_goto(goto_path))
|
if user_stmt is not None and user_stmt.type == 'expr_stmt':
|
||||||
|
for name in user_stmt.get_defined_names():
|
||||||
|
if name.start_pos <= self._pos <= name.end_pos:
|
||||||
|
# TODO scaning for a name and then using it should be
|
||||||
|
# the default.
|
||||||
|
definitions = set(self._evaluator.goto_definition(name))
|
||||||
|
|
||||||
|
if not definitions and goto_path:
|
||||||
|
definitions = set(self._prepare_goto(goto_path))
|
||||||
|
|
||||||
definitions = resolve_import_paths(definitions)
|
definitions = resolve_import_paths(definitions)
|
||||||
names = [s.name for s in definitions
|
names = [s.name for s in definitions
|
||||||
|
|||||||
@@ -454,6 +454,9 @@ class Evaluator(object):
|
|||||||
return types
|
return types
|
||||||
|
|
||||||
def goto_definition(self, name):
|
def goto_definition(self, name):
|
||||||
|
def_ = name.get_definition()
|
||||||
|
if def_.type == 'expr_stmt' and name in def_.get_defined_names():
|
||||||
|
return self.eval_statement(def_, name)
|
||||||
call = call_of_name(name)
|
call = call_of_name(name)
|
||||||
return self.eval_element(call)
|
return self.eval_element(call)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user