forked from VimPlug/jedi
assignment details description
This commit is contained in:
@@ -794,7 +794,10 @@ class Statement(Simple):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not set_vars:
|
if not set_vars:
|
||||||
return set_vars
|
return []
|
||||||
|
|
||||||
|
if _assignment_details():
|
||||||
|
s
|
||||||
result = set(set_vars)
|
result = set(set_vars)
|
||||||
last = None
|
last = None
|
||||||
in_lookup = 0
|
in_lookup = 0
|
||||||
@@ -805,14 +808,16 @@ class Statement(Simple):
|
|||||||
result.discard(tok)
|
result.discard(tok)
|
||||||
elif isinstance(tok, tuple):
|
elif isinstance(tok, tuple):
|
||||||
tok = tok[1]
|
tok = tok[1]
|
||||||
if in_lookup == 0 and tok == '(':
|
if in_lookup == 0 and tok == '(':
|
||||||
is_execution = True
|
is_execution = True
|
||||||
for t in self.token_list[:i]:
|
for t in self.token_list[:i]:
|
||||||
result.discard(t)
|
result.discard(t)
|
||||||
if tok == '[' and isinstance(last, Name):
|
if tok in '[(' and isinstance(last, Name):
|
||||||
in_lookup += 1
|
in_lookup += 1
|
||||||
elif tok == ']' and in_lookup > 0:
|
elif tok in ')]' and in_lookup > 0:
|
||||||
in_lookup -= 1
|
in_lookup -= 1
|
||||||
|
elif '=' in tok and in_lookup == 0:
|
||||||
|
break
|
||||||
last = tok
|
last = tok
|
||||||
return list(result)
|
return list(result)
|
||||||
|
|
||||||
@@ -842,6 +847,15 @@ class Statement(Simple):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def assignment_details(self):
|
def assignment_details(self):
|
||||||
|
"""
|
||||||
|
Returns an array of tuples of the elements before the assignment.
|
||||||
|
|
||||||
|
For example the following code::
|
||||||
|
|
||||||
|
x = (y, z) = 2, ''
|
||||||
|
|
||||||
|
would result in ``[(Name(x), '='), (Array([Name(y), Name(z)]), '=')]``.
|
||||||
|
"""
|
||||||
# parse statement which creates the assignment details.
|
# parse statement which creates the assignment details.
|
||||||
self.get_commands()
|
self.get_commands()
|
||||||
return self._assignment_details
|
return self._assignment_details
|
||||||
|
|||||||
Reference in New Issue
Block a user