aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-12 07:52:38 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-12 07:52:38 +0000
commit0156a538089828340a823ed02da8970bf4f1175b (patch)
tree07c4eacaad717ea802ab26972f45223281f2c9c1 /crates/ra_syntax/src/lib.rs
parentf655f993fe6d9faa81b0e776b9b24308d2ea1c68 (diff)
parent0527e3b283af0153cf13fa64fe73862a5b7655c8 (diff)
Merge #276
276: Extract and rename AtomEdit and Edit into ra_text_edit r=matklad a=vemoo As discused in #105 Co-authored-by: Bernardo <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r--crates/ra_syntax/src/lib.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 0e5c9baad..34a3aabef 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -41,13 +41,13 @@ pub use rowan::{SmolStr, TextRange, TextUnit};
41pub use crate::{ 41pub use crate::{
42 ast::AstNode, 42 ast::AstNode,
43 lexer::{tokenize, Token}, 43 lexer::{tokenize, Token},
44 reparsing::AtomEdit,
45 syntax_kinds::SyntaxKind, 44 syntax_kinds::SyntaxKind,
46 yellow::{ 45 yellow::{
47 Direction, OwnedRoot, RefRoot, SyntaxError, SyntaxNode, SyntaxNodeRef, TreeRoot, WalkEvent, Location, 46 Direction, OwnedRoot, RefRoot, SyntaxError, SyntaxNode, SyntaxNodeRef, TreeRoot, WalkEvent, Location,
48 }, 47 },
49}; 48};
50 49
50use ra_text_edit::AtomTextEdit;
51use crate::yellow::GreenNode; 51use 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)