mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
flows no longer distort results in certain positions
This commit is contained in:
@@ -829,6 +829,7 @@ def get_names_for_scope(scope, position=None, star_search=True,
|
|||||||
the whole thing would probably start a little recursive madness.
|
the whole thing would probably start a little recursive madness.
|
||||||
"""
|
"""
|
||||||
start_scope = scope
|
start_scope = scope
|
||||||
|
in_scope = scope
|
||||||
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.
|
||||||
@@ -840,10 +841,14 @@ def get_names_for_scope(scope, position=None, star_search=True,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
yield scope, get_defined_names_for_position(scope, position,
|
yield scope, get_defined_names_for_position(scope, position,
|
||||||
start_scope)
|
in_scope)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise MultiLevelStopIteration('StopIteration raised somewhere')
|
raise MultiLevelStopIteration('StopIteration raised somewhere')
|
||||||
scope = scope.parent
|
scope = scope.parent
|
||||||
|
# This is used, because subscopes (Flow scopes) would distort the
|
||||||
|
# results.
|
||||||
|
if isinstance(scope, (Function, parsing.Function, Execution)):
|
||||||
|
in_scope = scope
|
||||||
|
|
||||||
# Add star imports.
|
# Add star imports.
|
||||||
if star_search:
|
if star_search:
|
||||||
|
|||||||
@@ -1,3 +1,24 @@
|
|||||||
|
def find_class():
|
||||||
|
""" This scope is special, because its in front of TestClass """
|
||||||
|
#? ['ret']
|
||||||
|
TestClass.ret
|
||||||
|
if 1:
|
||||||
|
#? ['ret']
|
||||||
|
TestClass.ret
|
||||||
|
|
||||||
|
class FindClass():
|
||||||
|
#? []
|
||||||
|
TestClass.ret
|
||||||
|
if a:
|
||||||
|
#? []
|
||||||
|
TestClass.ret
|
||||||
|
|
||||||
|
def find_class(self):
|
||||||
|
#? ['ret']
|
||||||
|
TestClass.ret
|
||||||
|
if 1:
|
||||||
|
#? ['ret']
|
||||||
|
TestClass.ret
|
||||||
|
|
||||||
# set variables, which should not be included, because they don't belong to the
|
# set variables, which should not be included, because they don't belong to the
|
||||||
# class
|
# class
|
||||||
|
|||||||
Reference in New Issue
Block a user