mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
properties work now also with initialization values of classes
This commit is contained in:
@@ -203,8 +203,9 @@ class Instance(Executable):
|
|||||||
def get_descriptor_return(self, obj):
|
def get_descriptor_return(self, obj):
|
||||||
""" Throws an error if there's no method. """
|
""" Throws an error if there's no method. """
|
||||||
method = self.get_subscope_by_name('__get__')
|
method = self.get_subscope_by_name('__get__')
|
||||||
# args in __set__ descriptors are obj, class.
|
# arguments in __set__ descriptors are obj, class.
|
||||||
args = parsing.Array([[obj], [obj.base]], None)
|
# `method` is the new parent of the array, don't know if that's good.
|
||||||
|
args = parsing.Array('tuple', method, values=[[obj], [obj.base]])
|
||||||
method = InstanceElement(self, method)
|
method = InstanceElement(self, method)
|
||||||
res = Execution(method, args).get_return_types()
|
res = Execution(method, args).get_return_types()
|
||||||
|
|
||||||
@@ -390,7 +391,6 @@ class Execution(Executable):
|
|||||||
# there maybe executions of executions
|
# there maybe executions of executions
|
||||||
stmts = [Instance(self.base, self.var_args)]
|
stmts = [Instance(self.base, self.var_args)]
|
||||||
elif isinstance(self.base, Generator):
|
elif isinstance(self.base, Generator):
|
||||||
print 'blubedi', self.base
|
|
||||||
return self.base.execute()
|
return self.base.execute()
|
||||||
else:
|
else:
|
||||||
# don't do this with exceptions, as usual, because some deeper
|
# don't do this with exceptions, as usual, because some deeper
|
||||||
@@ -872,7 +872,6 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
def handle_non_arrays(name):
|
def handle_non_arrays(name):
|
||||||
result = []
|
result = []
|
||||||
par = name.parent
|
par = name.parent
|
||||||
print name, par, par.parent
|
|
||||||
if isinstance(par, parsing.Flow):
|
if isinstance(par, parsing.Flow):
|
||||||
if par.command == 'for':
|
if par.command == 'for':
|
||||||
# take the first statement (for has always only
|
# take the first statement (for has always only
|
||||||
@@ -1070,7 +1069,7 @@ def follow_call_list(scope, call_list):
|
|||||||
result += follow_call_list(scope, call)
|
result += follow_call_list(scope, call)
|
||||||
else:
|
else:
|
||||||
# with things like params, these can also be functions, etc
|
# with things like params, these can also be functions, etc
|
||||||
if isinstance(call, (Function, parsing.Class)):
|
if isinstance(call, (Function, parsing.Class, Instance)):
|
||||||
result.append(call)
|
result.append(call)
|
||||||
# The string tokens are just operations (+, -, etc.)
|
# The string tokens are just operations (+, -, etc.)
|
||||||
elif not isinstance(call, str):
|
elif not isinstance(call, str):
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import parsing
|
import parsing
|
||||||
|
import debug
|
||||||
|
|
||||||
class RecursionDecorator(object):
|
class RecursionDecorator(object):
|
||||||
""" A decorator to detect recursions in statements """
|
""" A decorator to detect recursions in statements """
|
||||||
@@ -14,6 +15,7 @@ class RecursionDecorator(object):
|
|||||||
|
|
||||||
r = RecursionNode(stmt, self.current)
|
r = RecursionNode(stmt, self.current)
|
||||||
if self.check_recursion(r):
|
if self.check_recursion(r):
|
||||||
|
debug.warning('catched recursion', stmt, args, kwargs)
|
||||||
return []
|
return []
|
||||||
parent, self.current = self.current, r
|
parent, self.current = self.current, r
|
||||||
result = self.func(stmt, *args, **kwargs)
|
result = self.func(stmt, *args, **kwargs)
|
||||||
|
|||||||
@@ -802,10 +802,10 @@ class Array(Call):
|
|||||||
DICT = 'dict'
|
DICT = 'dict'
|
||||||
SET = 'set'
|
SET = 'set'
|
||||||
|
|
||||||
def __init__(self, arr_type, parent_stmt, parent=None):
|
def __init__(self, arr_type, parent_stmt, parent=None, values=None):
|
||||||
super(Array, self).__init__(None, arr_type, parent_stmt, parent)
|
super(Array, self).__init__(None, arr_type, parent_stmt, parent)
|
||||||
|
|
||||||
self.values = []
|
self.values = values if values else []
|
||||||
self.keys = []
|
self.keys = []
|
||||||
|
|
||||||
def add_field(self):
|
def add_field(self):
|
||||||
@@ -874,7 +874,6 @@ class Array(Call):
|
|||||||
type = 'noarray'
|
type = 'noarray'
|
||||||
else:
|
else:
|
||||||
type = self.type
|
type = self.type
|
||||||
#parent_str = " of %s" % self.parent if self.parent else ""
|
|
||||||
return "<%s: %s%s>" % (self.__class__.__name__, type, self.values)
|
return "<%s: %s%s>" % (self.__class__.__name__, type, self.values)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,23 @@ nothing("")[0]
|
|||||||
#? str()
|
#? str()
|
||||||
nothing("")[1]
|
nothing("")[1]
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# properties
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
class PropClass():
|
||||||
|
def __init__(self, a):
|
||||||
|
self.a = a
|
||||||
|
@property
|
||||||
|
def ret(self):
|
||||||
|
return self.a
|
||||||
|
|
||||||
|
#? str()
|
||||||
|
PropClass("").ret
|
||||||
|
|
||||||
|
#? []
|
||||||
|
PropClass().ret.
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# not found decorators
|
# not found decorators
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
2
test/completion/thirdparty/jedi.py
vendored
2
test/completion/thirdparty/jedi.py
vendored
@@ -21,5 +21,5 @@ el = scopes.
|
|||||||
#? tuple()
|
#? tuple()
|
||||||
el = evaluate.get_names_for_scope()[0]
|
el = evaluate.get_names_for_scope()[0]
|
||||||
|
|
||||||
#? tuple()
|
##? tuple()
|
||||||
el = evaluate.get_names_for_scope(1,2)[0][0]
|
el = evaluate.get_names_for_scope(1,2)[0][0]
|
||||||
|
|||||||
Reference in New Issue
Block a user