mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
position stuff works now also with function that are located after the just called function
This commit is contained in:
13
evaluate.py
13
evaluate.py
@@ -771,7 +771,7 @@ class ArrayElement(object):
|
||||
return "<%s of %s>" % (self.__class__.__name__, self.name)
|
||||
|
||||
|
||||
def get_defined_names_for_position(obj, position=None):
|
||||
def get_defined_names_for_position(obj, position=None, start_scope=None):
|
||||
"""
|
||||
:param position: the position as a row/column tuple, default is infinity.
|
||||
"""
|
||||
@@ -779,7 +779,9 @@ def get_defined_names_for_position(obj, position=None):
|
||||
# instances have special rules, always return all the possible completions,
|
||||
# because class variables are always valid and the `self.` variables, too.
|
||||
if not position or isinstance(obj, Instance) or isinstance(obj, Function) \
|
||||
and isinstance(obj.decorated_func, Instance):
|
||||
and isinstance(obj.decorated_func, Instance) \
|
||||
or start_scope != obj and isinstance(start_scope,
|
||||
(parsing.Function, Execution)):
|
||||
return names
|
||||
names_new = []
|
||||
for n in names:
|
||||
@@ -799,9 +801,12 @@ def get_names_for_scope(scope, position=None, star_search=True):
|
||||
# `parsing.Class` is used, because the parent is never `Class`.
|
||||
# ignore the Flows, because the classes and functions care for that.
|
||||
if not (scope != start_scope and isinstance(scope, parsing.Class)
|
||||
or isinstance(scope, parsing.Flow)):
|
||||
or isinstance(scope, parsing.Flow)
|
||||
or isinstance(scope, InstanceElement)
|
||||
and isinstance(scope.var, parsing.Class)):
|
||||
try:
|
||||
yield scope, get_defined_names_for_position(scope, position)
|
||||
yield scope, get_defined_names_for_position(scope, position,
|
||||
start_scope)
|
||||
except StopIteration:
|
||||
raise MultiLevelStopIteration('StopIteration raised somewhere')
|
||||
scope = scope.parent
|
||||
|
||||
@@ -187,3 +187,25 @@ class V:
|
||||
|
||||
##? int()
|
||||
V().b()
|
||||
|
||||
# -----------------
|
||||
# ordering
|
||||
# -----------------
|
||||
class A():
|
||||
def b(self):
|
||||
#? int()
|
||||
a()
|
||||
#? str()
|
||||
self.a()
|
||||
return a()
|
||||
|
||||
def a(self):
|
||||
return ""
|
||||
|
||||
def a():
|
||||
return 1
|
||||
|
||||
#? int()
|
||||
A().b()
|
||||
#? str()
|
||||
A().a()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
def array(first_param):
|
||||
#? ['first_param']
|
||||
first_param
|
||||
@@ -66,6 +65,24 @@ def recursion(a, b):
|
||||
##? int() float()
|
||||
recursion("a", 1.0)
|
||||
|
||||
# -----------------
|
||||
# ordering
|
||||
# -----------------
|
||||
|
||||
#def b():
|
||||
#return ""
|
||||
|
||||
def a():
|
||||
#? int()
|
||||
b()
|
||||
return b()
|
||||
|
||||
def b():
|
||||
return 1
|
||||
|
||||
#? int()
|
||||
a()
|
||||
|
||||
# -----------------
|
||||
# keyword arguments
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user