mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +08:00
class assignments for statements is working now (oh gosh, this commit must be so non-readable for everyone except me...)
This commit is contained in:
14
evaluate.py
14
evaluate.py
@@ -7,7 +7,7 @@ follow_statement -> follow_call -> follow_paths -> follow_path
|
|||||||
TODO doc
|
TODO doc
|
||||||
TODO list comprehensions, priority? +1
|
TODO list comprehensions, priority? +1
|
||||||
TODO magic methods: __mul__, __add__, etc.
|
TODO magic methods: __mul__, __add__, etc.
|
||||||
TODO evaluate asserts (type safety)
|
TODO evaluate asserts/isinstance (type safety)
|
||||||
|
|
||||||
python 3 stuff:
|
python 3 stuff:
|
||||||
TODO class decorators
|
TODO class decorators
|
||||||
@@ -192,10 +192,7 @@ class Instance(Executable):
|
|||||||
|
|
||||||
class_names = self.base.get_defined_names()
|
class_names = self.base.get_defined_names()
|
||||||
for var in class_names:
|
for var in class_names:
|
||||||
# Functions are also instance elements.
|
names.append(InstanceElement(self, var))
|
||||||
if isinstance(var.parent, (Function, parsing.Function)):
|
|
||||||
var = InstanceElement(self, var)
|
|
||||||
names.append(var)
|
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def get_descriptor_return(self, obj):
|
def get_descriptor_return(self, obj):
|
||||||
@@ -805,9 +802,10 @@ def get_names_for_scope(scope, position=None, star_search=True,
|
|||||||
while scope:
|
while scope:
|
||||||
# `parsing.Class` is used, because the parent is never `Class`.
|
# `parsing.Class` is used, because the parent is never `Class`.
|
||||||
# Ignore the Flows, because the classes and functions care for that.
|
# Ignore the Flows, because the classes and functions care for that.
|
||||||
|
# InstanceElement of Class is ignored, if it is not the start scope.
|
||||||
if not (scope != start_scope and isinstance(scope, parsing.Class)
|
if not (scope != start_scope and isinstance(scope, parsing.Class)
|
||||||
or isinstance(scope, parsing.Flow)
|
or isinstance(scope, parsing.Flow)
|
||||||
or isinstance(scope, InstanceElement)
|
or scope != start_scope and isinstance(scope, InstanceElement)
|
||||||
and isinstance(scope.var, parsing.Class)):
|
and isinstance(scope.var, parsing.Class)):
|
||||||
try:
|
try:
|
||||||
yield scope, get_defined_names_for_position(scope, position,
|
yield scope, get_defined_names_for_position(scope, position,
|
||||||
@@ -897,10 +895,14 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
result.append(inst)
|
result.append(inst)
|
||||||
elif isinstance(par, (InstanceElement)) \
|
elif isinstance(par, (InstanceElement)) \
|
||||||
and hasattr(par, 'get_descriptor_return'):
|
and hasattr(par, 'get_descriptor_return'):
|
||||||
|
# handle descriptors
|
||||||
try:
|
try:
|
||||||
result += par.get_descriptor_return(scope)
|
result += par.get_descriptor_return(scope)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
result.append(par)
|
result.append(par)
|
||||||
|
elif (isinstance(scope, InstanceElement)
|
||||||
|
and scope.var == par.parent):
|
||||||
|
result.append(InstanceElement(scope.instance, par))
|
||||||
else:
|
else:
|
||||||
result.append(par)
|
result.append(par)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -160,16 +160,16 @@ class B():
|
|||||||
pass
|
pass
|
||||||
def t(self):
|
def t(self):
|
||||||
return ''
|
return ''
|
||||||
##p = property(t)
|
p = property(t)
|
||||||
|
|
||||||
#? []
|
#? []
|
||||||
B().r()
|
B().r()
|
||||||
#? int()
|
#? int()
|
||||||
B().r
|
B().r
|
||||||
|
|
||||||
##? str()
|
#? str()
|
||||||
B().p
|
B().p
|
||||||
##? []
|
#? []
|
||||||
B().p()
|
B().p()
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
@@ -177,16 +177,23 @@ B().p()
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class V:
|
class V:
|
||||||
def __init__(self):
|
def __init__(self, a):
|
||||||
self.a = 1
|
self.a = a
|
||||||
|
|
||||||
def ret(self):
|
def ret(self):
|
||||||
return self.a
|
return self.a
|
||||||
|
|
||||||
|
d = b
|
||||||
b = ret
|
b = ret
|
||||||
|
c = b
|
||||||
|
|
||||||
|
#? int()
|
||||||
|
V(1).b()
|
||||||
|
#? int()
|
||||||
|
V(1).c()
|
||||||
|
#? []
|
||||||
|
V(1).d()
|
||||||
|
|
||||||
##? int()
|
|
||||||
V().b()
|
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# ordering
|
# ordering
|
||||||
|
|||||||
Reference in New Issue
Block a user