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