diff --git a/jedi/parser/pytree.py b/jedi/parser/pytree.py index e80bae30..dbb9a6b9 100644 --- a/jedi/parser/pytree.py +++ b/jedi/parser/pytree.py @@ -84,6 +84,11 @@ def convert(grammar, raw_node): 'global_stmt': pr.GlobalStmt, 'nonlocal_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()) diff --git a/jedi/parser/representation.py b/jedi/parser/representation.py index 394ac6cd..d14439ba 100644 --- a/jedi/parser/representation.py +++ b/jedi/parser/representation.py @@ -470,7 +470,8 @@ class Scope(Simple, DocstringMixin): for element in children: if isinstance(element, typ): 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) return elements @@ -859,7 +860,31 @@ class Lambda(Function): 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, which indent code, but are not classes or functions: