diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 18:59:55 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 19:03:13 +0000 |
commit | 921689b70da39160dd381e9716472827e36b03b8 (patch) | |
tree | a390d74ee5272a4a0070f5d4ea5281a04d4ba56a /crates/ra_syntax/src/reparsing.rs | |
parent | f553837c1ca30a52bf5091689c21d3c3e3362395 (diff) |
kill text utils
Diffstat (limited to 'crates/ra_syntax/src/reparsing.rs')
-rw-r--r-- | crates/ra_syntax/src/reparsing.rs | 13 |
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; | |||
3 | use crate::lexer::{tokenize, Token}; | 3 | use crate::lexer::{tokenize, Token}; |
4 | use crate::parser_api::Parser; | 4 | use crate::parser_api::Parser; |
5 | use crate::parser_impl; | 5 | use crate::parser_impl; |
6 | use crate::text_utils::replace_range; | ||
7 | use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNode}; | 6 | use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNode}; |
8 | use crate::{SyntaxKind::*, TextRange, TextUnit}; | 7 | use crate::{SyntaxKind::*, TextRange, TextUnit}; |
9 | use ra_text_edit::AtomTextEdit; | 8 | use ra_text_edit::AtomTextEdit; |
@@ -62,11 +61,8 @@ fn reparse_block<'node>( | |||
62 | } | 61 | } |
63 | 62 | ||
64 | fn get_text_after_edit(node: &SyntaxNode, edit: &AtomTextEdit) -> String { | 63 | fn 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 | ||
72 | fn is_contextual_kw(text: &str) -> bool { | 68 | fn is_contextual_kw(text: &str) -> bool { |
@@ -156,7 +152,7 @@ fn merge_errors( | |||
156 | mod tests { | 152 | mod 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 = { |