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.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index cbba1d4ae..755ccd8e0 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -18,13 +18,7 @@
18 18
19pub mod algo; 19pub mod algo;
20pub mod ast; 20pub mod ast;
21mod lexer; 21mod parsing;
22#[macro_use]
23mod token_set;
24mod grammar;
25mod parser_api;
26mod parser_impl;
27mod reparsing;
28mod string_lexing; 22mod string_lexing;
29mod syntax_kinds; 23mod syntax_kinds;
30/// Utilities for simple uses of the parser. 24/// Utilities for simple uses of the parser.
@@ -36,10 +30,10 @@ mod ptr;
36pub use rowan::{SmolStr, TextRange, TextUnit}; 30pub use rowan::{SmolStr, TextRange, TextUnit};
37pub use crate::{ 31pub use crate::{
38 ast::AstNode, 32 ast::AstNode,
39 lexer::{tokenize, Token},
40 syntax_kinds::SyntaxKind, 33 syntax_kinds::SyntaxKind,
41 syntax_node::{Direction, SyntaxError, SyntaxNode, WalkEvent, Location, TreeArc}, 34 syntax_node::{Direction, SyntaxError, SyntaxNode, WalkEvent, Location, TreeArc},
42 ptr::{SyntaxNodePtr, AstPtr}, 35 ptr::{SyntaxNodePtr, AstPtr},
36 parsing::{tokenize, Token},
43}; 37};
44 38
45use ra_text_edit::AtomTextEdit; 39use ra_text_edit::AtomTextEdit;
@@ -59,9 +53,7 @@ impl SourceFile {
59 } 53 }
60 54
61 pub fn parse(text: &str) -> TreeArc<SourceFile> { 55 pub fn parse(text: &str) -> TreeArc<SourceFile> {
62 let tokens = tokenize(&text); 56 let (green, errors) = parsing::parse_text(text);
63 let (green, errors) =
64 parser_impl::parse_with(syntax_node::GreenBuilder::new(), text, &tokens, grammar::root);
65 SourceFile::new(green, errors) 57 SourceFile::new(green, errors)
66 } 58 }
67 59
@@ -70,7 +62,7 @@ impl SourceFile {
70 } 62 }
71 63
72 pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<TreeArc<SourceFile>> { 64 pub fn incremental_reparse(&self, edit: &AtomTextEdit) -> Option<TreeArc<SourceFile>> {
73 reparsing::incremental_reparse(self.syntax(), edit, self.errors()) 65 parsing::incremental_reparse(self.syntax(), edit, self.errors())
74 .map(|(green_node, errors)| SourceFile::new(green_node, errors)) 66 .map(|(green_node, errors)| SourceFile::new(green_node, errors))
75 } 67 }
76 68