diff options
author | Bernardo <[email protected]> | 2018-12-11 18:07:17 +0000 |
---|---|---|
committer | Bernardo <[email protected]> | 2018-12-11 18:07:17 +0000 |
commit | 0527e3b283af0153cf13fa64fe73862a5b7655c8 (patch) | |
tree | 07c4eacaad717ea802ab26972f45223281f2c9c1 /crates/ra_syntax/src | |
parent | 7344d28768c43d8955bf23c183d606be08f27c64 (diff) |
rename Edit to TextEdit and AtomEdit to AtomTextEdit
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/reparsing.rs | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 7295fb237..34a3aabef 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -47,7 +47,7 @@ pub use crate::{ | |||
47 | }, | 47 | }, |
48 | }; | 48 | }; |
49 | 49 | ||
50 | use ra_text_edit::AtomEdit; | 50 | use ra_text_edit::AtomTextEdit; |
51 | use crate::yellow::GreenNode; | 51 | use crate::yellow::GreenNode; |
52 | 52 | ||
53 | /// `SourceFileNode` represents a parse tree for a single Rust file. | 53 | /// `SourceFileNode` represents a parse tree for a single Rust file. |
@@ -68,15 +68,15 @@ impl SourceFileNode { | |||
68 | parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root); | 68 | parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root); |
69 | SourceFileNode::new(green, errors) | 69 | SourceFileNode::new(green, errors) |
70 | } | 70 | } |
71 | pub fn reparse(&self, edit: &AtomEdit) -> SourceFileNode { | 71 | pub fn reparse(&self, edit: &AtomTextEdit) -> SourceFileNode { |
72 | self.incremental_reparse(edit) | 72 | self.incremental_reparse(edit) |
73 | .unwrap_or_else(|| self.full_reparse(edit)) | 73 | .unwrap_or_else(|| self.full_reparse(edit)) |
74 | } | 74 | } |
75 | pub fn incremental_reparse(&self, edit: &AtomEdit) -> Option<SourceFileNode> { | 75 | pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<SourceFileNode> { |
76 | reparsing::incremental_reparse(self.syntax(), edit, self.errors()) | 76 | reparsing::incremental_reparse(self.syntax(), edit, self.errors()) |
77 | .map(|(green_node, errors)| SourceFileNode::new(green_node, errors)) | 77 | .map(|(green_node, errors)| SourceFileNode::new(green_node, errors)) |
78 | } | 78 | } |
79 | fn full_reparse(&self, edit: &AtomEdit) -> SourceFileNode { | 79 | fn full_reparse(&self, edit: &AtomTextEdit) -> SourceFileNode { |
80 | let text = | 80 | let text = |
81 | text_utils::replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert); | 81 | text_utils::replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert); |
82 | SourceFileNode::parse(&text) | 82 | SourceFileNode::parse(&text) |
diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs index 873809a5a..208cae5c8 100644 --- a/crates/ra_syntax/src/reparsing.rs +++ b/crates/ra_syntax/src/reparsing.rs | |||
@@ -6,11 +6,11 @@ use crate::parser_impl; | |||
6 | use crate::text_utils::replace_range; | 6 | use crate::text_utils::replace_range; |
7 | use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNodeRef}; | 7 | use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNodeRef}; |
8 | use crate::{SyntaxKind::*, TextRange, TextUnit}; | 8 | use crate::{SyntaxKind::*, TextRange, TextUnit}; |
9 | use ra_text_edit::AtomEdit; | 9 | use ra_text_edit::AtomTextEdit; |
10 | 10 | ||
11 | pub(crate) fn incremental_reparse( | 11 | pub(crate) fn incremental_reparse( |
12 | node: SyntaxNodeRef, | 12 | node: SyntaxNodeRef, |
13 | edit: &AtomEdit, | 13 | edit: &AtomTextEdit, |
14 | errors: Vec<SyntaxError>, | 14 | errors: Vec<SyntaxError>, |
15 | ) -> Option<(GreenNode, Vec<SyntaxError>)> { | 15 | ) -> Option<(GreenNode, Vec<SyntaxError>)> { |
16 | let (node, green, new_errors) = | 16 | let (node, green, new_errors) = |
@@ -22,7 +22,7 @@ pub(crate) fn incremental_reparse( | |||
22 | 22 | ||
23 | fn reparse_leaf<'node>( | 23 | fn reparse_leaf<'node>( |
24 | node: SyntaxNodeRef<'node>, | 24 | node: SyntaxNodeRef<'node>, |
25 | edit: &AtomEdit, | 25 | edit: &AtomTextEdit, |
26 | ) -> Option<(SyntaxNodeRef<'node>, GreenNode, Vec<SyntaxError>)> { | 26 | ) -> Option<(SyntaxNodeRef<'node>, GreenNode, Vec<SyntaxError>)> { |
27 | let node = algo::find_covering_node(node, edit.delete); | 27 | let node = algo::find_covering_node(node, edit.delete); |
28 | match node.kind() { | 28 | match node.kind() { |
@@ -48,7 +48,7 @@ fn reparse_leaf<'node>( | |||
48 | 48 | ||
49 | fn reparse_block<'node>( | 49 | fn reparse_block<'node>( |
50 | node: SyntaxNodeRef<'node>, | 50 | node: SyntaxNodeRef<'node>, |
51 | edit: &AtomEdit, | 51 | edit: &AtomTextEdit, |
52 | ) -> Option<(SyntaxNodeRef<'node>, GreenNode, Vec<SyntaxError>)> { | 52 | ) -> Option<(SyntaxNodeRef<'node>, GreenNode, Vec<SyntaxError>)> { |
53 | let (node, reparser) = find_reparsable_node(node, edit.delete)?; | 53 | let (node, reparser) = find_reparsable_node(node, edit.delete)?; |
54 | let text = get_text_after_edit(node, &edit); | 54 | let text = get_text_after_edit(node, &edit); |
@@ -61,7 +61,7 @@ fn reparse_block<'node>( | |||
61 | Some((node, green, new_errors)) | 61 | Some((node, green, new_errors)) |
62 | } | 62 | } |
63 | 63 | ||
64 | fn get_text_after_edit(node: SyntaxNodeRef, edit: &AtomEdit) -> String { | 64 | fn get_text_after_edit(node: SyntaxNodeRef, edit: &AtomTextEdit) -> String { |
65 | replace_range( | 65 | replace_range( |
66 | node.text().to_string(), | 66 | node.text().to_string(), |
67 | edit.delete - node.range().start(), | 67 | edit.delete - node.range().start(), |
@@ -139,7 +139,7 @@ fn merge_errors( | |||
139 | old_errors: Vec<SyntaxError>, | 139 | old_errors: Vec<SyntaxError>, |
140 | new_errors: Vec<SyntaxError>, | 140 | new_errors: Vec<SyntaxError>, |
141 | old_node: SyntaxNodeRef, | 141 | old_node: SyntaxNodeRef, |
142 | edit: &AtomEdit, | 142 | edit: &AtomTextEdit, |
143 | ) -> Vec<SyntaxError> { | 143 | ) -> Vec<SyntaxError> { |
144 | let mut res = Vec::new(); | 144 | let mut res = Vec::new(); |
145 | for e in old_errors { | 145 | for e in old_errors { |
@@ -166,7 +166,7 @@ mod tests { | |||
166 | where | 166 | where |
167 | for<'a> F: Fn( | 167 | for<'a> F: Fn( |
168 | SyntaxNodeRef<'a>, | 168 | SyntaxNodeRef<'a>, |
169 | &AtomEdit, | 169 | &AtomTextEdit, |
170 | ) -> Option<(SyntaxNodeRef<'a>, GreenNode, Vec<SyntaxError>)>, | 170 | ) -> Option<(SyntaxNodeRef<'a>, GreenNode, Vec<SyntaxError>)>, |
171 | { | 171 | { |
172 | let (range, before) = extract_range(before); | 172 | let (range, before) = extract_range(before); |
@@ -175,7 +175,7 @@ mod tests { | |||
175 | let fully_reparsed = SourceFileNode::parse(&after); | 175 | let fully_reparsed = SourceFileNode::parse(&after); |
176 | let incrementally_reparsed = { | 176 | let incrementally_reparsed = { |
177 | let f = SourceFileNode::parse(&before); | 177 | let f = SourceFileNode::parse(&before); |
178 | let edit = AtomEdit { | 178 | let edit = AtomTextEdit { |
179 | delete: range, | 179 | delete: range, |
180 | insert: replace_with.to_string(), | 180 | insert: replace_with.to_string(), |
181 | }; | 181 | }; |