From 20b4f6c363594342260c3e429383b130f2b69556 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 5 Sep 2016 18:04:53 +0200 Subject: [PATCH] Rework the parents when dividing nodes. --- jedi/parser/fast.py | 13 +++++++------ .../{test_fast_parser.py => test_diff_parser.py} | 0 2 files changed, 7 insertions(+), 6 deletions(-) rename test/test_parser/{test_fast_parser.py => test_diff_parser.py} (100%) diff --git a/jedi/parser/fast.py b/jedi/parser/fast.py index a05ed77f..568c04f6 100644 --- a/jedi/parser/fast.py +++ b/jedi/parser/fast.py @@ -333,18 +333,19 @@ class DiffParser(): new_node = copy.copy(node) new_node.children[-1] = new_suite = copy.copy(suite) - for i, child_node in enumerate(new_suite.children): - if child_node.end_pos[1] > until_line: - divided_node = self._divide_node(child_node, until_line) + for child in new_node.children: + child.parent = new_node + for i, child in enumerate(new_suite.children): + child.parent = new_suite + if child.end_pos[1] > until_line: + divided_node = self._divide_node(child, until_line) new_suite.children = new_suite.children[:i] if divided_node is not None: new_suite.children.append(divided_node) + divided_node.parent = new_suite if len(new_suite.children) < 3: # A suite only with newline and indent is not valid. return None - - for child in new_suite.children: - child.parent = new_suite break return new_node diff --git a/test/test_parser/test_fast_parser.py b/test/test_parser/test_diff_parser.py similarity index 100% rename from test/test_parser/test_fast_parser.py rename to test/test_parser/test_diff_parser.py