diff options
Diffstat (limited to 'crates/ra_syntax')
30 files changed, 142 insertions, 52 deletions
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 6345e4725..34bb1c591 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -1,4 +1,5 @@ | |||
1 | [package] | 1 | [package] |
2 | edition = "2018" | ||
2 | name = "ra_syntax" | 3 | name = "ra_syntax" |
3 | version = "0.1.0" | 4 | version = "0.1.0" |
4 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["Aleksey Kladov <[email protected]>"] |
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs index a6678093d..e686a5704 100644 --- a/crates/ra_syntax/src/algo/mod.rs +++ b/crates/ra_syntax/src/algo/mod.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | pub mod walk; | 1 | pub mod walk; |
2 | pub mod visit; | 2 | pub mod visit; |
3 | 3 | ||
4 | use { | 4 | use crate::{ |
5 | SyntaxNodeRef, TextUnit, TextRange, | 5 | SyntaxNodeRef, TextUnit, TextRange, |
6 | text_utils::{contains_offset_nonstrict, is_subrange}, | 6 | text_utils::{contains_offset_nonstrict, is_subrange}, |
7 | }; | 7 | }; |
diff --git a/crates/ra_syntax/src/algo/visit.rs b/crates/ra_syntax/src/algo/visit.rs index 9f1c127c7..1ae988a87 100644 --- a/crates/ra_syntax/src/algo/visit.rs +++ b/crates/ra_syntax/src/algo/visit.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use std::marker::PhantomData; | 1 | use std::marker::PhantomData; |
2 | use {SyntaxNodeRef, AstNode}; | 2 | use crate::{SyntaxNodeRef, AstNode}; |
3 | 3 | ||
4 | 4 | ||
5 | pub fn visitor<'a, T>() -> impl Visitor<'a, Output=T> { | 5 | pub fn visitor<'a, T>() -> impl Visitor<'a, Output=T> { |
diff --git a/crates/ra_syntax/src/algo/walk.rs b/crates/ra_syntax/src/algo/walk.rs index 8e294d965..d34415626 100644 --- a/crates/ra_syntax/src/algo/walk.rs +++ b/crates/ra_syntax/src/algo/walk.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use { | 1 | use crate::{ |
2 | SyntaxNodeRef, | 2 | SyntaxNodeRef, |
3 | algo::generate, | 3 | algo::generate, |
4 | }; | 4 | }; |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index ef7b5b1a1..160d186b8 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run | 1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run |
2 | // Do not edit manually | 2 | // Do not edit manually |
3 | 3 | ||
4 | use { | 4 | use crate::{ |
5 | ast, | 5 | ast, |
6 | SyntaxNodeRef, AstNode, | 6 | SyntaxNodeRef, AstNode, |
7 | SyntaxKind::*, | 7 | SyntaxKind::*, |
@@ -1387,7 +1387,11 @@ impl<'a> AstNode<'a> for PathExpr<'a> { | |||
1387 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1387 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | impl<'a> PathExpr<'a> {} | 1390 | impl<'a> PathExpr<'a> { |
1391 | pub fn path(self) -> Option<Path<'a>> { | ||
1392 | super::child_opt(self) | ||
1393 | } | ||
1394 | } | ||
1391 | 1395 | ||
1392 | // PathPat | 1396 | // PathPat |
1393 | #[derive(Debug, Clone, Copy)] | 1397 | #[derive(Debug, Clone, Copy)] |
@@ -2193,3 +2197,21 @@ impl<'a> WhileExpr<'a> { | |||
2193 | } | 2197 | } |
2194 | } | 2198 | } |
2195 | 2199 | ||
2200 | // Whitespace | ||
2201 | #[derive(Debug, Clone, Copy)] | ||
2202 | pub struct Whitespace<'a> { | ||
2203 | syntax: SyntaxNodeRef<'a>, | ||
2204 | } | ||
2205 | |||
2206 | impl<'a> AstNode<'a> for Whitespace<'a> { | ||
2207 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
2208 | match syntax.kind() { | ||
2209 | WHITESPACE => Some(Whitespace { syntax }), | ||
2210 | _ => None, | ||
2211 | } | ||
2212 | } | ||
2213 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
2214 | } | ||
2215 | |||
2216 | impl<'a> Whitespace<'a> {} | ||
2217 | |||
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index ffa9c4134..5cb7a35ed 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -3,7 +3,7 @@ the below applies to the result of this template | |||
3 | #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run | 3 | #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run |
4 | // Do not edit manually | 4 | // Do not edit manually |
5 | 5 | ||
6 | use { | 6 | use crate::{ |
7 | ast, | 7 | ast, |
8 | SyntaxNodeRef, AstNode, | 8 | SyntaxNodeRef, AstNode, |
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs index 10dac72e5..88193a1ed 100644 --- a/crates/ra_syntax/src/ast/mod.rs +++ b/crates/ra_syntax/src/ast/mod.rs | |||
@@ -4,7 +4,7 @@ use std::marker::PhantomData; | |||
4 | 4 | ||
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | 6 | ||
7 | use { | 7 | use crate::{ |
8 | SmolStr, SyntaxNodeRef, SyntaxKind::*, | 8 | SmolStr, SyntaxNodeRef, SyntaxKind::*, |
9 | yellow::{RefRoot, SyntaxNodeChildren}, | 9 | yellow::{RefRoot, SyntaxNodeChildren}, |
10 | }; | 10 | }; |
@@ -100,8 +100,8 @@ impl<'a> Lifetime<'a> { | |||
100 | } | 100 | } |
101 | 101 | ||
102 | impl<'a> Comment<'a> { | 102 | impl<'a> Comment<'a> { |
103 | pub fn text(&self) -> SmolStr { | 103 | pub fn text(&self) -> &SmolStr { |
104 | self.syntax().leaf_text().unwrap().clone() | 104 | self.syntax().leaf_text().unwrap() |
105 | } | 105 | } |
106 | 106 | ||
107 | pub fn flavor(&self) -> CommentFlavor { | 107 | pub fn flavor(&self) -> CommentFlavor { |
@@ -120,9 +120,17 @@ impl<'a> Comment<'a> { | |||
120 | pub fn prefix(&self) -> &'static str { | 120 | pub fn prefix(&self) -> &'static str { |
121 | self.flavor().prefix() | 121 | self.flavor().prefix() |
122 | } | 122 | } |
123 | |||
124 | pub fn count_newlines_lazy(&self) -> impl Iterator<Item = &()> { | ||
125 | self.text().chars().filter(|&c| c == '\n').map(|_| &()) | ||
126 | } | ||
127 | |||
128 | pub fn has_newlines(&self) -> bool { | ||
129 | self.count_newlines_lazy().count() > 0 | ||
130 | } | ||
123 | } | 131 | } |
124 | 132 | ||
125 | #[derive(Debug)] | 133 | #[derive(Debug, PartialEq, Eq)] |
126 | pub enum CommentFlavor { | 134 | pub enum CommentFlavor { |
127 | Line, | 135 | Line, |
128 | Doc, | 136 | Doc, |
@@ -142,6 +150,20 @@ impl CommentFlavor { | |||
142 | } | 150 | } |
143 | } | 151 | } |
144 | 152 | ||
153 | impl<'a> Whitespace<'a> { | ||
154 | pub fn text(&self) -> &SmolStr { | ||
155 | &self.syntax().leaf_text().unwrap() | ||
156 | } | ||
157 | |||
158 | pub fn count_newlines_lazy(&self) -> impl Iterator<Item = &()> { | ||
159 | self.text().chars().filter(|&c| c == '\n').map(|_| &()) | ||
160 | } | ||
161 | |||
162 | pub fn has_newlines(&self) -> bool { | ||
163 | self.count_newlines_lazy().count() > 0 | ||
164 | } | ||
165 | } | ||
166 | |||
145 | impl<'a> Name<'a> { | 167 | impl<'a> Name<'a> { |
146 | pub fn text(&self) -> SmolStr { | 168 | pub fn text(&self) -> SmolStr { |
147 | let ident = self.syntax().first_child() | 169 | let ident = self.syntax().first_child() |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 9da0c2c13..ea8063d3b 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -342,7 +342,7 @@ Grammar( | |||
342 | "TupleExpr": (), | 342 | "TupleExpr": (), |
343 | "ArrayExpr": (), | 343 | "ArrayExpr": (), |
344 | "ParenExpr": (), | 344 | "ParenExpr": (), |
345 | "PathExpr": (), | 345 | "PathExpr": (options: ["Path"]), |
346 | "LambdaExpr": ( | 346 | "LambdaExpr": ( |
347 | options: [ | 347 | options: [ |
348 | "ParamList", | 348 | "ParamList", |
@@ -538,5 +538,6 @@ Grammar( | |||
538 | options: [ "NameRef" ] | 538 | options: [ "NameRef" ] |
539 | ), | 539 | ), |
540 | "Comment": (), | 540 | "Comment": (), |
541 | "Whitespace": (), | ||
541 | }, | 542 | }, |
542 | ) | 543 | ) |
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index a720d255f..e21de68c5 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs | |||
@@ -30,7 +30,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = | |||
30 | token_set_union![ | 30 | token_set_union![ |
31 | LITERAL_FIRST, | 31 | LITERAL_FIRST, |
32 | token_set![L_CURLY, L_PAREN, L_BRACK, PIPE, MOVE_KW, IF_KW, WHILE_KW, MATCH_KW, UNSAFE_KW, | 32 | token_set![L_CURLY, L_PAREN, L_BRACK, PIPE, MOVE_KW, IF_KW, WHILE_KW, MATCH_KW, UNSAFE_KW, |
33 | RETURN_KW, IDENT, SELF_KW, SUPER_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], | 33 | RETURN_KW, IDENT, SELF_KW, SUPER_KW, CRATE_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], |
34 | ]; | 34 | ]; |
35 | 35 | ||
36 | const EXPR_RECOVERY_SET: TokenSet = | 36 | const EXPR_RECOVERY_SET: TokenSet = |
diff --git a/crates/ra_syntax/src/grammar/mod.rs b/crates/ra_syntax/src/grammar/mod.rs index 2cb11dc1e..1199ba230 100644 --- a/crates/ra_syntax/src/grammar/mod.rs +++ b/crates/ra_syntax/src/grammar/mod.rs | |||
@@ -31,7 +31,7 @@ mod type_args; | |||
31 | mod type_params; | 31 | mod type_params; |
32 | mod types; | 32 | mod types; |
33 | 33 | ||
34 | use { | 34 | use crate::{ |
35 | token_set::TokenSet, | 35 | token_set::TokenSet, |
36 | parser_api::{Marker, CompletedMarker, Parser}, | 36 | parser_api::{Marker, CompletedMarker, Parser}, |
37 | SyntaxKind::{self, *}, | 37 | SyntaxKind::{self, *}, |
diff --git a/crates/ra_syntax/src/lexer/comments.rs b/crates/ra_syntax/src/lexer/comments.rs index eb417c2dc..afe6886a1 100644 --- a/crates/ra_syntax/src/lexer/comments.rs +++ b/crates/ra_syntax/src/lexer/comments.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use lexer::ptr::Ptr; | 1 | use crate::lexer::ptr::Ptr; |
2 | 2 | ||
3 | use SyntaxKind::{self, *}; | 3 | use crate::SyntaxKind::{self, *}; |
4 | 4 | ||
5 | pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool { | 5 | pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool { |
6 | if ptr.at_str("!/") { | 6 | if ptr.at_str("!/") { |
diff --git a/crates/ra_syntax/src/lexer/mod.rs b/crates/ra_syntax/src/lexer/mod.rs index 3e11db88b..9dc0b63d6 100644 --- a/crates/ra_syntax/src/lexer/mod.rs +++ b/crates/ra_syntax/src/lexer/mod.rs | |||
@@ -4,7 +4,7 @@ mod numbers; | |||
4 | mod ptr; | 4 | mod ptr; |
5 | mod strings; | 5 | mod strings; |
6 | 6 | ||
7 | use { | 7 | use crate::{ |
8 | SyntaxKind::{self, *}, | 8 | SyntaxKind::{self, *}, |
9 | TextUnit, | 9 | TextUnit, |
10 | }; | 10 | }; |
diff --git a/crates/ra_syntax/src/lexer/numbers.rs b/crates/ra_syntax/src/lexer/numbers.rs index 22e7d4e99..46daf5e52 100644 --- a/crates/ra_syntax/src/lexer/numbers.rs +++ b/crates/ra_syntax/src/lexer/numbers.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use lexer::classes::*; | 1 | use crate::lexer::classes::*; |
2 | use lexer::ptr::Ptr; | 2 | use crate::lexer::ptr::Ptr; |
3 | 3 | ||
4 | use SyntaxKind::{self, *}; | 4 | use crate::SyntaxKind::{self, *}; |
5 | 5 | ||
6 | pub(crate) fn scan_number(c: char, ptr: &mut Ptr) -> SyntaxKind { | 6 | pub(crate) fn scan_number(c: char, ptr: &mut Ptr) -> SyntaxKind { |
7 | if c == '0' { | 7 | if c == '0' { |
diff --git a/crates/ra_syntax/src/lexer/ptr.rs b/crates/ra_syntax/src/lexer/ptr.rs index c9a5354ea..c4708cb1c 100644 --- a/crates/ra_syntax/src/lexer/ptr.rs +++ b/crates/ra_syntax/src/lexer/ptr.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use TextUnit; | 1 | use crate::TextUnit; |
2 | 2 | ||
3 | use std::str::Chars; | 3 | use std::str::Chars; |
4 | 4 | ||
diff --git a/crates/ra_syntax/src/lexer/strings.rs b/crates/ra_syntax/src/lexer/strings.rs index 5ff483d14..bceacdcac 100644 --- a/crates/ra_syntax/src/lexer/strings.rs +++ b/crates/ra_syntax/src/lexer/strings.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use SyntaxKind::{self, *}; | 1 | use crate::SyntaxKind::{self, *}; |
2 | 2 | ||
3 | use lexer::ptr::Ptr; | 3 | use crate::lexer::ptr::Ptr; |
4 | 4 | ||
5 | pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { | 5 | pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { |
6 | match (c, c1, c2) { | 6 | match (c, c1, c2) { |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 703469629..7eba5ee61 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -46,7 +46,7 @@ mod yellow; | |||
46 | pub mod utils; | 46 | pub mod utils; |
47 | pub mod text_utils; | 47 | pub mod text_utils; |
48 | 48 | ||
49 | pub use { | 49 | pub use crate::{ |
50 | rowan::{SmolStr, TextRange, TextUnit}, | 50 | rowan::{SmolStr, TextRange, TextUnit}, |
51 | ast::AstNode, | 51 | ast::AstNode, |
52 | lexer::{tokenize, Token}, | 52 | lexer::{tokenize, Token}, |
@@ -55,11 +55,11 @@ pub use { | |||
55 | reparsing::AtomEdit, | 55 | reparsing::AtomEdit, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | use { | 58 | use crate::{ |
59 | yellow::{GreenNode}, | 59 | yellow::{GreenNode}, |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #[derive(Clone, Debug, Hash)] | 62 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] |
63 | pub struct File { | 63 | pub struct File { |
64 | root: SyntaxNode | 64 | root: SyntaxNode |
65 | } | 65 | } |
diff --git a/crates/ra_syntax/src/parser_api.rs b/crates/ra_syntax/src/parser_api.rs index 772d753af..cc23bb75e 100644 --- a/crates/ra_syntax/src/parser_api.rs +++ b/crates/ra_syntax/src/parser_api.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use { | 1 | use crate::{ |
2 | token_set::TokenSet, | 2 | token_set::TokenSet, |
3 | parser_impl::ParserImpl, | 3 | parser_impl::ParserImpl, |
4 | SyntaxKind::{self, ERROR}, | 4 | SyntaxKind::{self, ERROR}, |
diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs index 95e5ce4cc..928d2cc7a 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs | |||
@@ -8,7 +8,7 @@ | |||
8 | //! `start node`, `finish node`, and `FileBuilder` converts | 8 | //! `start node`, `finish node`, and `FileBuilder` converts |
9 | //! this stream to a real tree. | 9 | //! this stream to a real tree. |
10 | use std::mem; | 10 | use std::mem; |
11 | use { | 11 | use crate::{ |
12 | TextUnit, TextRange, SmolStr, | 12 | TextUnit, TextRange, SmolStr, |
13 | lexer::Token, | 13 | lexer::Token, |
14 | parser_impl::Sink, | 14 | parser_impl::Sink, |
diff --git a/crates/ra_syntax/src/parser_impl/input.rs b/crates/ra_syntax/src/parser_impl/input.rs index c0fe4d488..ac6d900d8 100644 --- a/crates/ra_syntax/src/parser_impl/input.rs +++ b/crates/ra_syntax/src/parser_impl/input.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use {lexer::Token, SyntaxKind, SyntaxKind::EOF, TextRange, TextUnit}; | 1 | use crate::{lexer::Token, SyntaxKind, SyntaxKind::EOF, TextRange, TextUnit}; |
2 | 2 | ||
3 | use std::ops::{Add, AddAssign}; | 3 | use std::ops::{Add, AddAssign}; |
4 | 4 | ||
diff --git a/crates/ra_syntax/src/parser_impl/mod.rs b/crates/ra_syntax/src/parser_impl/mod.rs index 8d74cef0e..c2a6448e7 100644 --- a/crates/ra_syntax/src/parser_impl/mod.rs +++ b/crates/ra_syntax/src/parser_impl/mod.rs | |||
@@ -3,7 +3,7 @@ mod input; | |||
3 | 3 | ||
4 | use std::cell::Cell; | 4 | use std::cell::Cell; |
5 | 5 | ||
6 | use { | 6 | use crate::{ |
7 | TextUnit, SmolStr, | 7 | TextUnit, SmolStr, |
8 | lexer::Token, | 8 | lexer::Token, |
9 | parser_api::Parser, | 9 | parser_api::Parser, |
@@ -13,7 +13,7 @@ use { | |||
13 | }, | 13 | }, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | use SyntaxKind::{self, EOF, TOMBSTONE}; | 16 | use crate::SyntaxKind::{self, EOF, TOMBSTONE}; |
17 | 17 | ||
18 | pub(crate) trait Sink { | 18 | pub(crate) trait Sink { |
19 | type Tree; | 19 | type Tree; |
diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs index d8b6a6a10..16272fe88 100644 --- a/crates/ra_syntax/src/reparsing.rs +++ b/crates/ra_syntax/src/reparsing.rs | |||
@@ -1,14 +1,14 @@ | |||
1 | use algo; | 1 | use crate::algo; |
2 | use grammar; | 2 | use crate::grammar; |
3 | use lexer::{tokenize, Token}; | 3 | use crate::lexer::{tokenize, Token}; |
4 | use yellow::{self, GreenNode, SyntaxNodeRef, SyntaxError}; | 4 | use crate::yellow::{self, GreenNode, SyntaxNodeRef, SyntaxError}; |
5 | use parser_impl; | 5 | use crate::parser_impl; |
6 | use parser_api::Parser; | 6 | use crate::parser_api::Parser; |
7 | use { | 7 | use crate::{ |
8 | TextUnit, TextRange, | 8 | TextUnit, TextRange, |
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
10 | }; | 10 | }; |
11 | use text_utils::replace_range; | 11 | use crate::text_utils::replace_range; |
12 | 12 | ||
13 | #[derive(Debug, Clone)] | 13 | #[derive(Debug, Clone)] |
14 | pub struct AtomEdit { | 14 | pub struct AtomEdit { |
diff --git a/crates/ra_syntax/src/syntax_kinds/mod.rs b/crates/ra_syntax/src/syntax_kinds/mod.rs index 332cd13ac..3041e5633 100644 --- a/crates/ra_syntax/src/syntax_kinds/mod.rs +++ b/crates/ra_syntax/src/syntax_kinds/mod.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | mod generated; | 1 | mod generated; |
2 | 2 | ||
3 | use std::fmt; | 3 | use std::fmt; |
4 | use SyntaxKind::*; | 4 | use crate::SyntaxKind::*; |
5 | 5 | ||
6 | pub use self::generated::SyntaxKind; | 6 | pub use self::generated::SyntaxKind; |
7 | 7 | ||
diff --git a/crates/ra_syntax/src/text_utils.rs b/crates/ra_syntax/src/text_utils.rs index 58ae1e43e..adf26ef30 100644 --- a/crates/ra_syntax/src/text_utils.rs +++ b/crates/ra_syntax/src/text_utils.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use {TextRange, TextUnit}; | 1 | use crate::{TextRange, TextUnit}; |
2 | 2 | ||
3 | pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool { | 3 | pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool { |
4 | range.start() <= offset && offset <= range.end() | 4 | range.start() <= offset && offset <= range.end() |
diff --git a/crates/ra_syntax/src/token_set.rs b/crates/ra_syntax/src/token_set.rs index c83fba81b..d407dfa48 100644 --- a/crates/ra_syntax/src/token_set.rs +++ b/crates/ra_syntax/src/token_set.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use SyntaxKind; | 1 | use crate::SyntaxKind; |
2 | 2 | ||
3 | #[derive(Clone, Copy)] | 3 | #[derive(Clone, Copy)] |
4 | pub(crate) struct TokenSet(pub(crate) u128); | 4 | pub(crate) struct TokenSet(pub(crate) u128); |
@@ -29,7 +29,7 @@ macro_rules! token_set_union { | |||
29 | 29 | ||
30 | #[test] | 30 | #[test] |
31 | fn token_set_works_for_tokens() { | 31 | fn token_set_works_for_tokens() { |
32 | use SyntaxKind::*; | 32 | use crate::SyntaxKind::*; |
33 | let ts = token_set! { EOF, SHEBANG }; | 33 | let ts = token_set! { EOF, SHEBANG }; |
34 | assert!(ts.contains(EOF)); | 34 | assert!(ts.contains(EOF)); |
35 | assert!(ts.contains(SHEBANG)); | 35 | assert!(ts.contains(SHEBANG)); |
diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs index e274f7471..df1f4b372 100644 --- a/crates/ra_syntax/src/utils.rs +++ b/crates/ra_syntax/src/utils.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use std::fmt::Write; | 1 | use std::fmt::Write; |
2 | use { | 2 | use crate::{ |
3 | algo::walk::{walk, WalkEvent}, | 3 | algo::walk::{walk, WalkEvent}, |
4 | SyntaxKind, File, SyntaxNodeRef | 4 | SyntaxKind, File, SyntaxNodeRef |
5 | }; | 5 | }; |
diff --git a/crates/ra_syntax/src/yellow/builder.rs b/crates/ra_syntax/src/yellow/builder.rs index c307b2bd0..67a1a382b 100644 --- a/crates/ra_syntax/src/yellow/builder.rs +++ b/crates/ra_syntax/src/yellow/builder.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use rowan::GreenNodeBuilder; | 1 | use rowan::GreenNodeBuilder; |
2 | use { | 2 | use crate::{ |
3 | TextUnit, SmolStr, | 3 | TextUnit, SmolStr, |
4 | parser_impl::Sink, | 4 | parser_impl::Sink, |
5 | yellow::{GreenNode, SyntaxError, RaTypes}, | 5 | yellow::{GreenNode, SyntaxError, RaTypes}, |
diff --git a/crates/ra_syntax/src/yellow/mod.rs b/crates/ra_syntax/src/yellow/mod.rs index 710320f47..ab9bca0f0 100644 --- a/crates/ra_syntax/src/yellow/mod.rs +++ b/crates/ra_syntax/src/yellow/mod.rs | |||
@@ -6,7 +6,7 @@ use std::{ | |||
6 | hash::{Hash, Hasher}, | 6 | hash::{Hash, Hasher}, |
7 | }; | 7 | }; |
8 | use rowan::Types; | 8 | use rowan::Types; |
9 | use {SyntaxKind, TextUnit, TextRange, SmolStr}; | 9 | use crate::{SyntaxKind, TextUnit, TextRange, SmolStr}; |
10 | use self::syntax_text::SyntaxText; | 10 | use self::syntax_text::SyntaxText; |
11 | 11 | ||
12 | pub use rowan::{TreeRoot}; | 12 | pub use rowan::{TreeRoot}; |
@@ -70,16 +70,16 @@ impl<'a> SyntaxNodeRef<'a> { | |||
70 | self.0.leaf_text() | 70 | self.0.leaf_text() |
71 | } | 71 | } |
72 | pub fn ancestors(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | 72 | pub fn ancestors(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { |
73 | ::algo::generate(Some(self), |&node| node.parent()) | 73 | crate::algo::generate(Some(self), |&node| node.parent()) |
74 | } | 74 | } |
75 | pub fn descendants(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | 75 | pub fn descendants(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { |
76 | ::algo::walk::walk(self).filter_map(|event| match event { | 76 | crate::algo::walk::walk(self).filter_map(|event| match event { |
77 | ::algo::walk::WalkEvent::Enter(node) => Some(node), | 77 | crate::algo::walk::WalkEvent::Enter(node) => Some(node), |
78 | ::algo::walk::WalkEvent::Exit(_) => None, | 78 | crate::algo::walk::WalkEvent::Exit(_) => None, |
79 | }) | 79 | }) |
80 | } | 80 | } |
81 | pub fn siblings(self, direction: Direction) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | 81 | pub fn siblings(self, direction: Direction) -> impl Iterator<Item=SyntaxNodeRef<'a>> { |
82 | ::algo::generate(Some(self), move |&node| match direction { | 82 | crate::algo::generate(Some(self), move |&node| match direction { |
83 | Direction::Next => node.next_sibling(), | 83 | Direction::Next => node.next_sibling(), |
84 | Direction::Prev => node.prev_sibling(), | 84 | Direction::Prev => node.prev_sibling(), |
85 | }) | 85 | }) |
@@ -156,7 +156,7 @@ impl<R: TreeRoot<RaTypes>> Iterator for SyntaxNodeChildren<R> { | |||
156 | 156 | ||
157 | 157 | ||
158 | fn has_short_text(kind: SyntaxKind) -> bool { | 158 | fn has_short_text(kind: SyntaxKind) -> bool { |
159 | use SyntaxKind::*; | 159 | use crate::SyntaxKind::*; |
160 | match kind { | 160 | match kind { |
161 | IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true, | 161 | IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true, |
162 | _ => false, | 162 | _ => false, |
diff --git a/crates/ra_syntax/src/yellow/syntax_text.rs b/crates/ra_syntax/src/yellow/syntax_text.rs index 0db1049de..ae33b993d 100644 --- a/crates/ra_syntax/src/yellow/syntax_text.rs +++ b/crates/ra_syntax/src/yellow/syntax_text.rs | |||
@@ -2,7 +2,7 @@ use std::{ | |||
2 | fmt, ops, | 2 | fmt, ops, |
3 | }; | 3 | }; |
4 | 4 | ||
5 | use { | 5 | use crate::{ |
6 | SyntaxNodeRef, TextRange, TextUnit, | 6 | SyntaxNodeRef, TextRange, TextUnit, |
7 | text_utils::{intersect, contains_offset_nonstrict}, | 7 | text_utils::{intersect, contains_offset_nonstrict}, |
8 | }; | 8 | }; |
diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs new file mode 100644 index 000000000..f1ed30220 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn main() { | ||
2 | make_query(crate::module_map::module_tree); | ||
3 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt new file mode 100644 index 000000000..364315180 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0035_crate_path_in_call.txt | |||
@@ -0,0 +1,41 @@ | |||
1 | ROOT@[0; 62) | ||
2 | FN_DEF@[0; 61) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 7) | ||
6 | IDENT@[3; 7) "main" | ||
7 | PARAM_LIST@[7; 9) | ||
8 | L_PAREN@[7; 8) | ||
9 | R_PAREN@[8; 9) | ||
10 | WHITESPACE@[9; 10) | ||
11 | BLOCK@[10; 61) | ||
12 | L_CURLY@[10; 11) | ||
13 | WHITESPACE@[11; 16) | ||
14 | EXPR_STMT@[16; 59) | ||
15 | CALL_EXPR@[16; 58) | ||
16 | PATH_EXPR@[16; 26) | ||
17 | PATH@[16; 26) | ||
18 | PATH_SEGMENT@[16; 26) | ||
19 | NAME_REF@[16; 26) | ||
20 | IDENT@[16; 26) "make_query" | ||
21 | ARG_LIST@[26; 58) | ||
22 | L_PAREN@[26; 27) | ||
23 | PATH_EXPR@[27; 57) | ||
24 | PATH@[27; 57) | ||
25 | PATH@[27; 44) | ||
26 | PATH@[27; 32) | ||
27 | PATH_SEGMENT@[27; 32) | ||
28 | CRATE_KW@[27; 32) | ||
29 | COLONCOLON@[32; 34) | ||
30 | PATH_SEGMENT@[34; 44) | ||
31 | NAME_REF@[34; 44) | ||
32 | IDENT@[34; 44) "module_map" | ||
33 | COLONCOLON@[44; 46) | ||
34 | PATH_SEGMENT@[46; 57) | ||
35 | NAME_REF@[46; 57) | ||
36 | IDENT@[46; 57) "module_tree" | ||
37 | R_PAREN@[57; 58) | ||
38 | SEMI@[58; 59) | ||
39 | WHITESPACE@[59; 60) | ||
40 | R_CURLY@[60; 61) | ||
41 | WHITESPACE@[61; 62) | ||