aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/reparsing.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/reparsing.rs')
-rw-r--r--crates/ra_syntax/src/reparsing.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs
index d5d72e1f8..2f1de6b02 100644
--- a/crates/ra_syntax/src/reparsing.rs
+++ b/crates/ra_syntax/src/reparsing.rs
@@ -3,7 +3,6 @@ use crate::grammar;
3use crate::lexer::{tokenize, Token}; 3use crate::lexer::{tokenize, Token};
4use crate::parser_api::Parser; 4use crate::parser_api::Parser;
5use crate::parser_impl; 5use crate::parser_impl;
6use crate::text_utils::replace_range;
7use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNode}; 6use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNode};
8use crate::{SyntaxKind::*, TextRange, TextUnit}; 7use crate::{SyntaxKind::*, TextRange, TextUnit};
9use ra_text_edit::AtomTextEdit; 8use ra_text_edit::AtomTextEdit;
@@ -62,11 +61,8 @@ fn reparse_block<'node>(
62} 61}
63 62
64fn get_text_after_edit(node: &SyntaxNode, edit: &AtomTextEdit) -> String { 63fn get_text_after_edit(node: &SyntaxNode, edit: &AtomTextEdit) -> String {
65 replace_range( 64 let edit = AtomTextEdit::replace(edit.delete - node.range().start(), edit.insert.clone());
66 node.text().to_string(), 65 edit.apply(node.text().to_string())
67 edit.delete - node.range().start(),
68 &edit.insert,
69 )
70} 66}
71 67
72fn is_contextual_kw(text: &str) -> bool { 68fn is_contextual_kw(text: &str) -> bool {
@@ -156,7 +152,7 @@ fn merge_errors(
156mod tests { 152mod tests {
157 use test_utils::{extract_range, assert_eq_text}; 153 use test_utils::{extract_range, assert_eq_text};
158 154
159 use crate::{SourceFile, AstNode, text_utils::replace_range, utils::dump_tree}; 155 use crate::{SourceFile, AstNode, utils::dump_tree};
160 use super::*; 156 use super::*;
161 157
162 fn do_check<F>(before: &str, replace_with: &str, reparser: F) 158 fn do_check<F>(before: &str, replace_with: &str, reparser: F)
@@ -167,7 +163,8 @@ mod tests {
167 ) -> Option<(&'a SyntaxNode, GreenNode, Vec<SyntaxError>)>, 163 ) -> Option<(&'a SyntaxNode, GreenNode, Vec<SyntaxError>)>,
168 { 164 {
169 let (range, before) = extract_range(before); 165 let (range, before) = extract_range(before);
170 let after = replace_range(before.clone(), range, replace_with); 166 let edit = AtomTextEdit::replace(range, replace_with.to_owned());
167 let after = edit.apply(before.clone());
171 168
172 let fully_reparsed = SourceFile::parse(&after); 169 let fully_reparsed = SourceFile::parse(&after);
173 let incrementally_reparsed = { 170 let incrementally_reparsed = {