diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-16 14:44:24 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-16 14:44:24 +0100 |
commit | 1216878f7be20dd0e652fb8cdc395009fdcfae07 (patch) | |
tree | 6551967cc8c6e921b66071453ad7888a9121d326 /crates/ra_syntax/src/lib.rs | |
parent | 39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (diff) | |
parent | 61f3a438d3a729a6be941bca1ff4c6a97a33f221 (diff) |
Merge #134
134: Cargo Format run r=kjeremy a=kjeremy
I'm not sure how appreciated this is but I figured I would run `cargo fmt` and see what came up.
I made sure that `cargo test` still passes.
Co-authored-by: Jeremy A. Kolb <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 7eba5ee61..7a9718aad 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -20,11 +20,11 @@ | |||
20 | #![allow(missing_docs)] | 20 | #![allow(missing_docs)] |
21 | //#![warn(unreachable_pub)] // rust-lang/rust#47816 | 21 | //#![warn(unreachable_pub)] // rust-lang/rust#47816 |
22 | 22 | ||
23 | extern crate itertools; | ||
24 | extern crate unicode_xid; | ||
25 | extern crate drop_bomb; | 23 | extern crate drop_bomb; |
24 | extern crate itertools; | ||
26 | extern crate parking_lot; | 25 | extern crate parking_lot; |
27 | extern crate rowan; | 26 | extern crate rowan; |
27 | extern crate unicode_xid; | ||
28 | 28 | ||
29 | #[cfg(test)] | 29 | #[cfg(test)] |
30 | #[macro_use] | 30 | #[macro_use] |
@@ -35,33 +35,31 @@ pub mod ast; | |||
35 | mod lexer; | 35 | mod lexer; |
36 | #[macro_use] | 36 | #[macro_use] |
37 | mod token_set; | 37 | mod token_set; |
38 | mod parser_api; | ||
39 | mod grammar; | 38 | mod grammar; |
39 | mod parser_api; | ||
40 | mod parser_impl; | 40 | mod parser_impl; |
41 | mod reparsing; | 41 | mod reparsing; |
42 | 42 | ||
43 | mod syntax_kinds; | 43 | mod syntax_kinds; |
44 | mod yellow; | 44 | pub mod text_utils; |
45 | /// Utilities for simple uses of the parser. | 45 | /// Utilities for simple uses of the parser. |
46 | pub mod utils; | 46 | pub mod utils; |
47 | pub mod text_utils; | 47 | mod yellow; |
48 | 48 | ||
49 | pub use crate::{ | 49 | pub use crate::{ |
50 | rowan::{SmolStr, TextRange, TextUnit}, | ||
51 | ast::AstNode, | 50 | ast::AstNode, |
52 | lexer::{tokenize, Token}, | 51 | lexer::{tokenize, Token}, |
53 | syntax_kinds::SyntaxKind, | ||
54 | yellow::{SyntaxNode, SyntaxNodeRef, OwnedRoot, RefRoot, TreeRoot, SyntaxError, Direction}, | ||
55 | reparsing::AtomEdit, | 52 | reparsing::AtomEdit, |
53 | rowan::{SmolStr, TextRange, TextUnit}, | ||
54 | syntax_kinds::SyntaxKind, | ||
55 | yellow::{Direction, OwnedRoot, RefRoot, SyntaxError, SyntaxNode, SyntaxNodeRef, TreeRoot}, | ||
56 | }; | 56 | }; |
57 | 57 | ||
58 | use crate::{ | 58 | use crate::yellow::GreenNode; |
59 | yellow::{GreenNode}, | ||
60 | }; | ||
61 | 59 | ||
62 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] | 60 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] |
63 | pub struct File { | 61 | pub struct File { |
64 | root: SyntaxNode | 62 | root: SyntaxNode, |
65 | } | 63 | } |
66 | 64 | ||
67 | impl File { | 65 | impl File { |
@@ -74,21 +72,21 @@ impl File { | |||
74 | } | 72 | } |
75 | pub fn parse(text: &str) -> File { | 73 | pub fn parse(text: &str) -> File { |
76 | let tokens = tokenize(&text); | 74 | let tokens = tokenize(&text); |
77 | let (green, errors) = parser_impl::parse_with( | 75 | let (green, errors) = |
78 | yellow::GreenBuilder::new(), | 76 | parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root); |
79 | text, &tokens, grammar::root, | ||
80 | ); | ||
81 | File::new(green, errors) | 77 | File::new(green, errors) |
82 | } | 78 | } |
83 | pub fn reparse(&self, edit: &AtomEdit) -> File { | 79 | pub fn reparse(&self, edit: &AtomEdit) -> File { |
84 | self.incremental_reparse(edit).unwrap_or_else(|| self.full_reparse(edit)) | 80 | self.incremental_reparse(edit) |
81 | .unwrap_or_else(|| self.full_reparse(edit)) | ||
85 | } | 82 | } |
86 | pub fn incremental_reparse(&self, edit: &AtomEdit) -> Option<File> { | 83 | pub fn incremental_reparse(&self, edit: &AtomEdit) -> Option<File> { |
87 | reparsing::incremental_reparse(self.syntax(), edit, self.errors()) | 84 | reparsing::incremental_reparse(self.syntax(), edit, self.errors()) |
88 | .map(|(green_node, errors)| File::new(green_node, errors)) | 85 | .map(|(green_node, errors)| File::new(green_node, errors)) |
89 | } | 86 | } |
90 | fn full_reparse(&self, edit: &AtomEdit) -> File { | 87 | fn full_reparse(&self, edit: &AtomEdit) -> File { |
91 | let text = text_utils::replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert); | 88 | let text = |
89 | text_utils::replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert); | ||
92 | File::parse(&text) | 90 | File::parse(&text) |
93 | } | 91 | } |
94 | pub fn ast(&self) -> ast::Root { | 92 | pub fn ast(&self) -> ast::Root { |