Make Tree::changed_ranges return an Iterator instead of a Vec (#437)
* Make Tree::changed_ranges return an Iterator instead of a Vec * Remove CBufferIter.free parameter
This commit is contained in:
parent
d5b5d473ab
commit
d96ba09391
5 changed files with 49 additions and 19 deletions
|
|
@ -337,7 +337,7 @@ fn check_consistent_sizes(tree: &Tree, input: &Vec<u8>) {
|
|||
}
|
||||
|
||||
fn check_changed_ranges(old_tree: &Tree, new_tree: &Tree, input: &Vec<u8>) -> Result<(), String> {
|
||||
let changed_ranges = old_tree.changed_ranges(new_tree);
|
||||
let changed_ranges = old_tree.changed_ranges(new_tree).collect();
|
||||
let old_scope_sequence = ScopeSequence::new(old_tree);
|
||||
let new_scope_sequence = ScopeSequence::new(new_tree);
|
||||
old_scope_sequence.check_changes(&new_scope_sequence, &input, &changed_ranges)
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ fn test_parsing_with_a_newly_excluded_range() {
|
|||
);
|
||||
|
||||
assert_eq!(
|
||||
tree.changed_ranges(&first_tree),
|
||||
tree.changed_ranges(&first_tree).collect::<Vec<_>>(),
|
||||
vec![
|
||||
// The first range that has changed syntax is the range of the newly-inserted text.
|
||||
Range {
|
||||
|
|
@ -837,7 +837,7 @@ fn test_parsing_with_a_newly_included_range() {
|
|||
);
|
||||
|
||||
assert_eq!(
|
||||
tree.changed_ranges(&first_tree),
|
||||
tree.changed_ranges(&first_tree).collect::<Vec<_>>(),
|
||||
vec![Range {
|
||||
start_byte: first_code_end_index + 1,
|
||||
end_byte: second_code_end_index + 1,
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ fn get_changed_ranges(
|
|||
) -> Vec<Range> {
|
||||
perform_edit(tree, source_code, &edit);
|
||||
let new_tree = parser.parse(&source_code, Some(tree)).unwrap();
|
||||
let result = tree.changed_ranges(&new_tree);
|
||||
let result = tree.changed_ranges(&new_tree).collect();
|
||||
*tree = new_tree;
|
||||
result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue