forked from VimPlug/jedi
Rename a few IfStmt methods.
This commit is contained in:
@@ -78,13 +78,13 @@ def _break_check(context, context_scope, flow_scope, node):
|
|||||||
reachable = REACHABLE
|
reachable = REACHABLE
|
||||||
if flow_scope.type == 'if_stmt':
|
if flow_scope.type == 'if_stmt':
|
||||||
if flow_scope.is_node_after_else(node):
|
if flow_scope.is_node_after_else(node):
|
||||||
for check_node in flow_scope.get_check_nodes():
|
for check_node in flow_scope.get_test_nodes():
|
||||||
reachable = _check_if(context, check_node)
|
reachable = _check_if(context, check_node)
|
||||||
if reachable in (REACHABLE, UNSURE):
|
if reachable in (REACHABLE, UNSURE):
|
||||||
break
|
break
|
||||||
reachable = reachable.invert()
|
reachable = reachable.invert()
|
||||||
else:
|
else:
|
||||||
flow_node = flow_scope.node_in_which_check_node(node)
|
flow_node = flow_scope.in_which_test_node(node)
|
||||||
if flow_node is not None:
|
if flow_node is not None:
|
||||||
reachable = _check_if(context, flow_node)
|
reachable = _check_if(context, flow_node)
|
||||||
elif flow_scope.type in ('try_stmt', 'while_stmt'):
|
elif flow_scope.type in ('try_stmt', 'while_stmt'):
|
||||||
|
|||||||
@@ -678,9 +678,9 @@ class IfStmt(Flow):
|
|||||||
type = 'if_stmt'
|
type = 'if_stmt'
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def get_check_nodes(self):
|
def get_test_nodes(self):
|
||||||
"""
|
"""
|
||||||
Returns all the `test` nodes that are defined as x, here:
|
E.g. returns all the `test` nodes that are named as x, below:
|
||||||
|
|
||||||
if x:
|
if x:
|
||||||
pass
|
pass
|
||||||
@@ -691,14 +691,14 @@ class IfStmt(Flow):
|
|||||||
if c in ('elif', 'if'):
|
if c in ('elif', 'if'):
|
||||||
yield self.children[i + 1]
|
yield self.children[i + 1]
|
||||||
|
|
||||||
def node_in_which_check_node(self, node):
|
def in_which_test_node(self, node):
|
||||||
"""
|
"""
|
||||||
Returns the check node (see function above) that a node is contained
|
Returns the test node (see function above) that a node is contained
|
||||||
in. However if it the node is in the check node itself and not in the
|
in. However if the node is in the test node itself and not in the
|
||||||
suite return None.
|
suite return None.
|
||||||
"""
|
"""
|
||||||
start_pos = node.start_pos
|
start_pos = node.start_pos
|
||||||
for check_node in reversed(list(self.get_check_nodes())):
|
for check_node in reversed(list(self.get_test_nodes())):
|
||||||
if check_node.start_pos < start_pos:
|
if check_node.start_pos < start_pos:
|
||||||
if start_pos < check_node.end_pos:
|
if start_pos < check_node.end_pos:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user