mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
instance variables are now working again, however, it's still a little bit strange
This commit is contained in:
16
evaluate.py
16
evaluate.py
@@ -1005,14 +1005,15 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
and scope.var == name.parent().parent():
|
and scope.var == name.parent().parent():
|
||||||
name = InstanceElement(scope.instance, name)
|
name = InstanceElement(scope.instance, name)
|
||||||
par = name.parent()
|
par = name.parent()
|
||||||
|
|
||||||
if par.isinstance(parsing.Flow):
|
if par.isinstance(parsing.Flow):
|
||||||
if par.command == 'for':
|
if par.command == 'for':
|
||||||
result += handle_for_loops(par)
|
result += handle_for_loops(par)
|
||||||
else:
|
else:
|
||||||
debug.warning('Flow: Why are you here? %s' % par.command)
|
debug.warning('Flow: Why are you here? %s' % par.command)
|
||||||
elif isinstance(par, parsing.Param) \
|
elif par.isinstance(parsing.Param) \
|
||||||
and par.parent() is not None \
|
and par.parent() is not None \
|
||||||
and isinstance(par.parent().parent(), parsing.Class) \
|
and par.parent().parent().isinstance(parsing.Class) \
|
||||||
and par.position_nr == 0:
|
and par.position_nr == 0:
|
||||||
# This is where self gets added - this happens at another
|
# This is where self gets added - this happens at another
|
||||||
# place, if the var_args are clear. But sometimes the class is
|
# place, if the var_args are clear. But sometimes the class is
|
||||||
@@ -1024,14 +1025,14 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
inst = Instance(Class(par.parent().parent()))
|
inst = Instance(Class(par.parent().parent()))
|
||||||
inst.is_generated = True
|
inst.is_generated = True
|
||||||
result.append(inst)
|
result.append(inst)
|
||||||
elif isinstance(par, parsing.Statement):
|
elif par.isinstance(parsing.Statement):
|
||||||
def is_execution(arr):
|
def is_execution(arr):
|
||||||
for a in arr:
|
for a in arr:
|
||||||
a = a[0] # rest is always empty with assignees
|
a = a[0] # rest is always empty with assignees
|
||||||
if isinstance(a, parsing.Array):
|
if a.isinstance(parsing.Array):
|
||||||
if is_execution(a):
|
if is_execution(a):
|
||||||
return True
|
return True
|
||||||
elif isinstance(a, parsing.Call):
|
elif a.isinstance(parsing.Call):
|
||||||
if a.name == name and a.execution:
|
if a.name == name and a.execution:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -1047,6 +1048,11 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
details = par.assignment_details
|
details = par.assignment_details
|
||||||
if details and details[0][0] != '=':
|
if details and details[0][0] != '=':
|
||||||
no_break_scope = True
|
no_break_scope = True
|
||||||
|
# TODO this makes self variables non-breakable. wanted?
|
||||||
|
r = [n for n in par.get_set_vars()
|
||||||
|
if len(n) > 1 and str(n.names[-1] == name)]
|
||||||
|
if isinstance(name, InstanceElement) and r:
|
||||||
|
no_break_scope = True
|
||||||
result.append(par)
|
result.append(par)
|
||||||
else:
|
else:
|
||||||
result.append(par)
|
result.append(par)
|
||||||
|
|||||||
@@ -798,7 +798,7 @@ class Param(Statement):
|
|||||||
return n[0]
|
return n[0]
|
||||||
|
|
||||||
|
|
||||||
class Call(object):
|
class Call(Base):
|
||||||
"""
|
"""
|
||||||
`Call` contains a call, e.g. `foo.bar` and owns the executions of those
|
`Call` contains a call, e.g. `foo.bar` and owns the executions of those
|
||||||
calls, which are `Array`s.
|
calls, which are `Array`s.
|
||||||
|
|||||||
@@ -88,14 +88,14 @@ class A(object):
|
|||||||
a = list()
|
a = list()
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.b = ""
|
self.b = ""
|
||||||
|
|
||||||
|
def before(self):
|
||||||
self.b = 3
|
self.b = 3
|
||||||
# TODO should this be so?
|
# TODO should this be so?
|
||||||
#? int() str() list()
|
#? int() str() list()
|
||||||
self.b
|
self.b
|
||||||
|
|
||||||
self.b = list
|
self.b = list
|
||||||
|
|
||||||
def before(self):
|
|
||||||
self.a = 1
|
self.a = 1
|
||||||
#? list() str() int()
|
#? list() str() int()
|
||||||
self.a
|
self.a
|
||||||
|
|||||||
Reference in New Issue
Block a user