mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-28 05:42:18 +08:00
used_names copying.
This commit is contained in:
@@ -52,12 +52,12 @@ class DiffParser():
|
|||||||
self._insert_count = 0
|
self._insert_count = 0
|
||||||
|
|
||||||
self._parsed_until_line = 0
|
self._parsed_until_line = 0
|
||||||
|
self._copied_ranges = []
|
||||||
self._reset_module()
|
self._reset_module()
|
||||||
|
|
||||||
def _reset_module(self):
|
def _reset_module(self):
|
||||||
# TODO get rid of _module.global_names in evaluator.
|
# TODO get rid of _module.global_names in evaluator. It's getting ignored here.
|
||||||
self._module.global_names = []
|
self._module.global_names = []
|
||||||
self._module.used_names = {}
|
|
||||||
self._module.names_dict = {}
|
self._module.names_dict = {}
|
||||||
|
|
||||||
def update(self, lines_new):
|
def update(self, lines_new):
|
||||||
@@ -101,6 +101,9 @@ class DiffParser():
|
|||||||
assert operation == 'delete'
|
assert operation == 'delete'
|
||||||
self._delete_count += 1 # For statistics
|
self._delete_count += 1 # For statistics
|
||||||
|
|
||||||
|
self._post_parse()
|
||||||
|
self._module.used_names = self._temp_module.used_names
|
||||||
|
|
||||||
def _copy_from_old_parser(self, line_offset, until_line_old, until_line_new):
|
def _copy_from_old_parser(self, line_offset, until_line_old, until_line_new):
|
||||||
# TODO update namesdict!!! and module global_names, used_names
|
# TODO update namesdict!!! and module global_names, used_names
|
||||||
while until_line_new > self._parsed_until_line:
|
while until_line_new > self._parsed_until_line:
|
||||||
@@ -224,7 +227,7 @@ class DiffParser():
|
|||||||
|
|
||||||
def _merge_parsed_node(self, parent_node, parsed_node):
|
def _merge_parsed_node(self, parent_node, parsed_node):
|
||||||
_merge_names_dicts(parent_node.names_dict, parsed_node.names_dict)
|
_merge_names_dicts(parent_node.names_dict, parsed_node.names_dict)
|
||||||
_merge_names_dicts(self._temp_module, parsed_node.used_names)
|
_merge_names_dicts(self._temp_module.used_names, parsed_node.used_names)
|
||||||
|
|
||||||
def _divide_node(self, node, until_line):
|
def _divide_node(self, node, until_line):
|
||||||
"""
|
"""
|
||||||
@@ -324,8 +327,17 @@ class DiffParser():
|
|||||||
)
|
)
|
||||||
return self._parser.parse(tokenizer=tokenizer)
|
return self._parser.parse(tokenizer=tokenizer)
|
||||||
|
|
||||||
def _post_parser_updates(self, parser):
|
def _post_parse(self):
|
||||||
pass
|
# Add the used names from the old parser to the new one.
|
||||||
|
copied_line_numbers = set()
|
||||||
|
for l1, l2 in self._copied_ranges:
|
||||||
|
copied_line_numbers.update(range(l1, l2 + 1))
|
||||||
|
|
||||||
|
new_used_names = self._temp_module.used_names
|
||||||
|
for key, names in self._module.used_names.items():
|
||||||
|
for name in names:
|
||||||
|
if name.start_pos[0] in copied_line_numbers:
|
||||||
|
new_used_names.setdefault(key, []).add(name)
|
||||||
|
|
||||||
def _diff_tokenize(self, lines, until_line, line_offset=0):
|
def _diff_tokenize(self, lines, until_line, line_offset=0):
|
||||||
is_first_token = True
|
is_first_token = True
|
||||||
|
|||||||
Reference in New Issue
Block a user