1
0
forked from VimPlug/jedi

Writing a different Name.get_definition() implementation, returns the node, if there's no expr_stmt parent.

This commit is contained in:
Dave Halter
2015-03-05 15:17:08 +01:00
parent 0ceadf69a3
commit 8f58258f4d
2 changed files with 9 additions and 4 deletions

View File

@@ -546,7 +546,11 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
elif isinstance(d, pr.Param):
d = d.get_code()
else: # ExprStmt
first_leaf = d.first_leaf()
try:
first_leaf = d.first_leaf()
except AttributeError:
# `d` is already a Leaf (Name).
first_leaf = d
# Remove the prefix, because that's not what we want for get_code
# here.
old, first_leaf.prefix = first_leaf.prefix, ''