diff options
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 9b7664576..6203b6206 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -42,8 +42,6 @@ use std::{marker::PhantomData, sync::Arc}; | |||
42 | use ra_text_edit::Indel; | 42 | use ra_text_edit::Indel; |
43 | use stdx::format_to; | 43 | use stdx::format_to; |
44 | 44 | ||
45 | use crate::syntax_node::GreenNode; | ||
46 | |||
47 | pub use crate::{ | 45 | pub use crate::{ |
48 | algo::InsertPosition, | 46 | algo::InsertPosition, |
49 | ast::{AstNode, AstToken}, | 47 | ast::{AstNode, AstToken}, |
@@ -51,7 +49,7 @@ pub use crate::{ | |||
51 | ptr::{AstPtr, SyntaxNodePtr}, | 49 | ptr::{AstPtr, SyntaxNodePtr}, |
52 | syntax_error::SyntaxError, | 50 | syntax_error::SyntaxError, |
53 | syntax_node::{ | 51 | syntax_node::{ |
54 | Direction, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, | 52 | Direction, GreenNode, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, |
55 | SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, | 53 | SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, |
56 | }, | 54 | }, |
57 | }; | 55 | }; |
@@ -189,7 +187,7 @@ impl ast::Expr { | |||
189 | } | 187 | } |
190 | } | 188 | } |
191 | 189 | ||
192 | impl ast::ModuleItem { | 190 | impl ast::Item { |
193 | /// Returns `text`, parsed as an item, but only if it has no errors. | 191 | /// Returns `text`, parsed as an item, but only if it has no errors. |
194 | pub fn parse(text: &str) -> Result<Self, ()> { | 192 | pub fn parse(text: &str) -> Result<Self, ()> { |
195 | parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) | 193 | parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) |
@@ -257,11 +255,11 @@ fn api_walkthrough() { | |||
257 | let mut func = None; | 255 | let mut func = None; |
258 | for item in file.items() { | 256 | for item in file.items() { |
259 | match item { | 257 | match item { |
260 | ast::ModuleItem::FnDef(f) => func = Some(f), | 258 | ast::Item::Fn(f) => func = Some(f), |
261 | _ => unreachable!(), | 259 | _ => unreachable!(), |
262 | } | 260 | } |
263 | } | 261 | } |
264 | let func: ast::FnDef = func.unwrap(); | 262 | let func: ast::Fn = func.unwrap(); |
265 | 263 | ||
266 | // Each AST node has a bunch of getters for children. All getters return | 264 | // Each AST node has a bunch of getters for children. All getters return |
267 | // `Option`s though, to account for incomplete code. Some getters are common | 265 | // `Option`s though, to account for incomplete code. Some getters are common |
@@ -318,7 +316,7 @@ fn api_walkthrough() { | |||
318 | ); | 316 | ); |
319 | 317 | ||
320 | // As well as some iterator helpers: | 318 | // As well as some iterator helpers: |
321 | let f = expr_syntax.ancestors().find_map(ast::FnDef::cast); | 319 | let f = expr_syntax.ancestors().find_map(ast::Fn::cast); |
322 | assert_eq!(f, Some(func)); | 320 | assert_eq!(f, Some(func)); |
323 | assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); | 321 | assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); |
324 | assert_eq!( | 322 | assert_eq!( |