aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r--crates/ra_syntax/src/lib.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 1dbfca91b..2a095817a 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -41,7 +41,7 @@ pub use crate::{
41 ast::AstNode, 41 ast::AstNode,
42 lexer::{tokenize, Token}, 42 lexer::{tokenize, Token},
43 syntax_kinds::SyntaxKind, 43 syntax_kinds::SyntaxKind,
44 yellow::{Direction, SyntaxError, SyntaxNode, WalkEvent, Location, TreePtr}, 44 yellow::{Direction, SyntaxError, SyntaxNode, WalkEvent, Location, TreeArc},
45}; 45};
46 46
47use ra_text_edit::AtomTextEdit; 47use ra_text_edit::AtomTextEdit;
@@ -51,29 +51,29 @@ use crate::yellow::GreenNode;
51pub use crate::ast::SourceFile; 51pub use crate::ast::SourceFile;
52 52
53impl SourceFile { 53impl SourceFile {
54 fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreePtr<SourceFile> { 54 fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SourceFile> {
55 let root = SyntaxNode::new(green, errors); 55 let root = SyntaxNode::new(green, errors);
56 if cfg!(debug_assertions) { 56 if cfg!(debug_assertions) {
57 utils::validate_block_structure(&root); 57 utils::validate_block_structure(&root);
58 } 58 }
59 assert_eq!(root.kind(), SyntaxKind::SOURCE_FILE); 59 assert_eq!(root.kind(), SyntaxKind::SOURCE_FILE);
60 TreePtr::cast(root) 60 TreeArc::cast(root)
61 } 61 }
62 pub fn parse(text: &str) -> TreePtr<SourceFile> { 62 pub fn parse(text: &str) -> TreeArc<SourceFile> {
63 let tokens = tokenize(&text); 63 let tokens = tokenize(&text);
64 let (green, errors) = 64 let (green, errors) =
65 parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root); 65 parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root);
66 SourceFile::new(green, errors) 66 SourceFile::new(green, errors)
67 } 67 }
68 pub fn reparse(&self, edit: &AtomTextEdit) -> TreePtr<SourceFile> { 68 pub fn reparse(&self, edit: &AtomTextEdit) -> TreeArc<SourceFile> {
69 self.incremental_reparse(edit) 69 self.incremental_reparse(edit)
70 .unwrap_or_else(|| self.full_reparse(edit)) 70 .unwrap_or_else(|| self.full_reparse(edit))
71 } 71 }
72 pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<TreePtr<SourceFile>> { 72 pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<TreeArc<SourceFile>> {
73 reparsing::incremental_reparse(self.syntax(), edit, self.errors()) 73 reparsing::incremental_reparse(self.syntax(), edit, self.errors())
74 .map(|(green_node, errors)| SourceFile::new(green_node, errors)) 74 .map(|(green_node, errors)| SourceFile::new(green_node, errors))
75 } 75 }
76 fn full_reparse(&self, edit: &AtomTextEdit) -> TreePtr<SourceFile> { 76 fn full_reparse(&self, edit: &AtomTextEdit) -> TreeArc<SourceFile> {
77 let text = edit.apply(self.syntax().text().to_string()); 77 let text = edit.apply(self.syntax().text().to_string());
78 SourceFile::parse(&text) 78 SourceFile::parse(&text)
79 } 79 }