diff options
Diffstat (limited to 'crates/libeditor/src')
-rw-r--r-- | crates/libeditor/src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index f77647338..c762a8b0b 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs | |||
@@ -5,11 +5,12 @@ mod extend_selection; | |||
5 | mod line_index; | 5 | mod line_index; |
6 | 6 | ||
7 | use libsyntax2::{ | 7 | use libsyntax2::{ |
8 | ast, | ||
8 | SyntaxNodeRef, AstNode, | 9 | SyntaxNodeRef, AstNode, |
9 | algo::walk, | 10 | algo::walk, |
10 | SyntaxKind::*, | 11 | SyntaxKind::*, |
11 | }; | 12 | }; |
12 | pub use libsyntax2::{TextRange, TextUnit, ast}; | 13 | pub use libsyntax2::{File, TextRange, TextUnit}; |
13 | pub use self::line_index::{LineIndex, LineCol}; | 14 | pub use self::line_index::{LineIndex, LineCol}; |
14 | 15 | ||
15 | #[derive(Debug)] | 16 | #[derive(Debug)] |
@@ -43,6 +44,10 @@ pub enum RunnableKind { | |||
43 | Bin, | 44 | Bin, |
44 | } | 45 | } |
45 | 46 | ||
47 | pub fn parse(text: &str) -> ast::File { | ||
48 | ast::File::parse(text) | ||
49 | } | ||
50 | |||
46 | pub fn highlight(file: &ast::File) -> Vec<HighlightedRange> { | 51 | pub fn highlight(file: &ast::File) -> Vec<HighlightedRange> { |
47 | let syntax = file.syntax(); | 52 | let syntax = file.syntax(); |
48 | let mut res = Vec::new(); | 53 | let mut res = Vec::new(); |