forked from VimPlug/jedi
Add the parsers flow information as classes to parser.representation.
This commit is contained in:
@@ -84,6 +84,11 @@ def convert(grammar, raw_node):
|
|||||||
'global_stmt': pr.GlobalStmt,
|
'global_stmt': pr.GlobalStmt,
|
||||||
'nonlocal_stmt': pr.KeywordStatement,
|
'nonlocal_stmt': pr.KeywordStatement,
|
||||||
'assert_stmt': pr.KeywordStatement,
|
'assert_stmt': pr.KeywordStatement,
|
||||||
|
'if_stmt': pr.IfStmt,
|
||||||
|
'with_stmt': pr.WithStmt,
|
||||||
|
'for_stmt': pr.ForStmt,
|
||||||
|
'while_stmt': pr.WhileStmt,
|
||||||
|
'try_stmt': pr.TryStmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_mapping = dict((getattr(python_symbols, k), v) for k, v in _ast_mapping.items())
|
ast_mapping = dict((getattr(python_symbols, k), v) for k, v in _ast_mapping.items())
|
||||||
|
|||||||
@@ -470,7 +470,8 @@ class Scope(Simple, DocstringMixin):
|
|||||||
for element in children:
|
for element in children:
|
||||||
if isinstance(element, typ):
|
if isinstance(element, typ):
|
||||||
elements.append(element)
|
elements.append(element)
|
||||||
elif is_node(element, 'suite') or is_node(element, 'simple_stmt'):
|
elif is_node(element, 'suite') or is_node(element, 'simple_stmt') \
|
||||||
|
or isinstance(element, Flow):
|
||||||
elements += scan(element.children)
|
elements += scan(element.children)
|
||||||
return elements
|
return elements
|
||||||
|
|
||||||
@@ -859,7 +860,31 @@ class Lambda(Function):
|
|||||||
self.start_pos[1], self.end_pos[1])
|
self.start_pos[1], self.end_pos[1])
|
||||||
|
|
||||||
|
|
||||||
class Flow(Scope):
|
class Flow(Simple):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IfStmt(Flow):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class WhileStmt(Flow):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ForStmt(Flow):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TryStmt(Flow):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class WithStmt(Flow):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Flow_old(Scope):
|
||||||
"""
|
"""
|
||||||
Used to describe programming structure - flow statements,
|
Used to describe programming structure - flow statements,
|
||||||
which indent code, but are not classes or functions:
|
which indent code, but are not classes or functions:
|
||||||
|
|||||||
Reference in New Issue
Block a user