mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 14:59:41 +08:00
Move is_scope and get_parent_scope out of the parser.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from jedi.parser_utils import get_flow_branch_keyword
|
||||
from jedi.parser_utils import get_flow_branch_keyword, is_scope, get_parent_scope
|
||||
|
||||
|
||||
class Status(object):
|
||||
lookup_table = {}
|
||||
|
||||
@@ -32,14 +34,14 @@ UNSURE = Status(None, 'unsure')
|
||||
|
||||
def _get_flow_scopes(node):
|
||||
while True:
|
||||
node = node.get_parent_scope(include_flows=True)
|
||||
if node is None or node.is_scope():
|
||||
node = get_parent_scope(node, include_flows=True)
|
||||
if node is None or is_scope(node):
|
||||
return
|
||||
yield node
|
||||
|
||||
|
||||
def reachability_check(context, context_scope, node, origin_scope=None):
|
||||
first_flow_scope = node.get_parent_scope(include_flows=True)
|
||||
first_flow_scope = get_parent_scope(node, include_flows=True)
|
||||
if origin_scope is not None:
|
||||
origin_flow_scopes = list(_get_flow_scopes(origin_scope))
|
||||
node_flow_scopes = list(_get_flow_scopes(node))
|
||||
@@ -95,7 +97,7 @@ def _break_check(context, context_scope, flow_scope, node):
|
||||
return reachable
|
||||
|
||||
if context_scope != flow_scope and context_scope != flow_scope.parent:
|
||||
flow_scope = flow_scope.get_parent_scope(include_flows=True)
|
||||
flow_scope = get_parent_scope(flow_scope, include_flows=True)
|
||||
return reachable & _break_check(context, context_scope, flow_scope, node)
|
||||
else:
|
||||
return reachable
|
||||
|
||||
Reference in New Issue
Block a user