diff options
Diffstat (limited to 'crates/syntax')
-rw-r--r-- | crates/syntax/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/syntax/src/ast.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/syntax/src/lib.rs | 11 | ||||
-rw-r--r-- | crates/syntax/src/parsing.rs | 4 | ||||
-rw-r--r-- | crates/syntax/src/parsing/text_token_source.rs | 2 | ||||
-rw-r--r-- | crates/syntax/src/syntax_node.rs | 6 | ||||
-rw-r--r-- | crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast | 54 | ||||
-rw-r--r-- | crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rs | 2 |
9 files changed, 73 insertions, 18 deletions
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index e8de61868..61d2acb49 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml | |||
@@ -13,7 +13,7 @@ doctest = false | |||
13 | [dependencies] | 13 | [dependencies] |
14 | itertools = "0.9.0" | 14 | itertools = "0.9.0" |
15 | rowan = "0.10.0" | 15 | rowan = "0.10.0" |
16 | rustc_lexer = { version = "685.0.0", package = "rustc-ap-rustc_lexer" } | 16 | rustc_lexer = { version = "686.0.0", package = "rustc-ap-rustc_lexer" } |
17 | rustc-hash = "1.1.0" | 17 | rustc-hash = "1.1.0" |
18 | arrayvec = "0.5.1" | 18 | arrayvec = "0.5.1" |
19 | once_cell = "1.3.1" | 19 | once_cell = "1.3.1" |
@@ -27,7 +27,7 @@ serde = { version = "1.0.106", features = ["derive"] } | |||
27 | stdx = { path = "../stdx", version = "0.0.0" } | 27 | stdx = { path = "../stdx", version = "0.0.0" } |
28 | text_edit = { path = "../text_edit", version = "0.0.0" } | 28 | text_edit = { path = "../text_edit", version = "0.0.0" } |
29 | parser = { path = "../parser", version = "0.0.0" } | 29 | parser = { path = "../parser", version = "0.0.0" } |
30 | test_utils = { path = "../test_utils" } | 30 | test_utils = { path = "../test_utils", version = "0.0.0" } |
31 | 31 | ||
32 | [dev-dependencies] | 32 | [dev-dependencies] |
33 | walkdir = "2.3.1" | 33 | walkdir = "2.3.1" |
diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs index d536bb1e7..8a0e3d27b 100644 --- a/crates/syntax/src/ast.rs +++ b/crates/syntax/src/ast.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | 17 | ||
18 | pub use self::{ | 18 | pub use self::{ |
19 | expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, | 19 | expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, |
20 | generated::*, | 20 | generated::{nodes::*, tokens::*}, |
21 | node_ext::{ | 21 | node_ext::{ |
22 | AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, | 22 | AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, |
23 | StructKind, TypeBoundKind, VisibilityKind, | 23 | StructKind, TypeBoundKind, VisibilityKind, |
diff --git a/crates/syntax/src/ast/generated.rs b/crates/syntax/src/ast/generated.rs index 4a6f41ee7..843b43cf0 100644 --- a/crates/syntax/src/ast/generated.rs +++ b/crates/syntax/src/ast/generated.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | //! This file is actually hand-written, but the submodules are indeed generated. | 1 | //! This file is actually hand-written, but the submodules are indeed generated. |
2 | #[rustfmt::skip] | 2 | #[rustfmt::skip] |
3 | mod nodes; | 3 | pub(crate) mod nodes; |
4 | #[rustfmt::skip] | 4 | #[rustfmt::skip] |
5 | mod tokens; | 5 | pub(crate) mod tokens; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | AstNode, | 8 | AstNode, |
@@ -10,7 +10,7 @@ use crate::{ | |||
10 | SyntaxNode, | 10 | SyntaxNode, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | pub use {nodes::*, tokens::*}; | 13 | pub(crate) use nodes::*; |
14 | 14 | ||
15 | // Stmt is the only nested enum, so it's easier to just hand-write it | 15 | // Stmt is the only nested enum, so it's easier to just hand-write it |
16 | impl AstNode for Stmt { | 16 | impl AstNode for Stmt { |
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index 849a1cdd6..e753b11bb 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs | |||
@@ -46,16 +46,19 @@ use text_edit::Indel; | |||
46 | pub use crate::{ | 46 | pub use crate::{ |
47 | algo::InsertPosition, | 47 | algo::InsertPosition, |
48 | ast::{AstNode, AstToken}, | 48 | ast::{AstNode, AstToken}, |
49 | parsing::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token}, | 49 | parsing::lexer::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token}, |
50 | ptr::{AstPtr, SyntaxNodePtr}, | 50 | ptr::{AstPtr, SyntaxNodePtr}, |
51 | syntax_error::SyntaxError, | 51 | syntax_error::SyntaxError, |
52 | syntax_node::{ | 52 | syntax_node::{ |
53 | Direction, GreenNode, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, | 53 | SyntaxElement, SyntaxElementChildren, SyntaxNode, SyntaxNodeChildren, SyntaxToken, |
54 | SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, | 54 | SyntaxTreeBuilder, |
55 | }, | 55 | }, |
56 | }; | 56 | }; |
57 | pub use parser::{SyntaxKind, T}; | 57 | pub use parser::{SyntaxKind, T}; |
58 | pub use rowan::{SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, WalkEvent}; | 58 | pub use rowan::{ |
59 | Direction, GreenNode, NodeOrToken, SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, | ||
60 | WalkEvent, | ||
61 | }; | ||
59 | 62 | ||
60 | /// `Parse` is the result of the parsing: a syntax tree and a collection of | 63 | /// `Parse` is the result of the parsing: a syntax tree and a collection of |
61 | /// errors. | 64 | /// errors. |
diff --git a/crates/syntax/src/parsing.rs b/crates/syntax/src/parsing.rs index 68a39eb21..333bde54a 100644 --- a/crates/syntax/src/parsing.rs +++ b/crates/syntax/src/parsing.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Lexing, bridging to parser (which does the actual parsing) and | 1 | //! Lexing, bridging to parser (which does the actual parsing) and |
2 | //! incremental reparsing. | 2 | //! incremental reparsing. |
3 | 3 | ||
4 | mod lexer; | 4 | pub(crate) mod lexer; |
5 | mod text_token_source; | 5 | mod text_token_source; |
6 | mod text_tree_sink; | 6 | mod text_tree_sink; |
7 | mod reparsing; | 7 | mod reparsing; |
@@ -10,7 +10,7 @@ use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; | |||
10 | use text_token_source::TextTokenSource; | 10 | use text_token_source::TextTokenSource; |
11 | use text_tree_sink::TextTreeSink; | 11 | use text_tree_sink::TextTreeSink; |
12 | 12 | ||
13 | pub use lexer::*; | 13 | pub(crate) use lexer::*; |
14 | 14 | ||
15 | pub(crate) use self::reparsing::incremental_reparse; | 15 | pub(crate) use self::reparsing::incremental_reparse; |
16 | use parser::SyntaxKind; | 16 | use parser::SyntaxKind; |
diff --git a/crates/syntax/src/parsing/text_token_source.rs b/crates/syntax/src/parsing/text_token_source.rs index df866dc2b..0614194a5 100644 --- a/crates/syntax/src/parsing/text_token_source.rs +++ b/crates/syntax/src/parsing/text_token_source.rs | |||
@@ -65,7 +65,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Tok | |||
65 | 65 | ||
66 | impl<'t> TextTokenSource<'t> { | 66 | impl<'t> TextTokenSource<'t> { |
67 | /// Generate input from tokens(expect comment and whitespace). | 67 | /// Generate input from tokens(expect comment and whitespace). |
68 | pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> { | 68 | pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> { |
69 | let token_offset_pairs: Vec<_> = raw_tokens | 69 | let token_offset_pairs: Vec<_> = raw_tokens |
70 | .iter() | 70 | .iter() |
71 | .filter_map({ | 71 | .filter_map({ |
diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs index b2abcbfbb..cc30138fa 100644 --- a/crates/syntax/src/syntax_node.rs +++ b/crates/syntax/src/syntax_node.rs | |||
@@ -10,9 +10,7 @@ use rowan::{GreenNodeBuilder, Language}; | |||
10 | 10 | ||
11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; | 11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; |
12 | 12 | ||
13 | pub use rowan::GreenNode; | 13 | pub(crate) use rowan::{GreenNode, GreenToken, NodeOrToken}; |
14 | |||
15 | pub(crate) use rowan::GreenToken; | ||
16 | 14 | ||
17 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
18 | pub enum RustLanguage {} | 16 | pub enum RustLanguage {} |
@@ -34,8 +32,6 @@ pub type SyntaxElement = rowan::SyntaxElement<RustLanguage>; | |||
34 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; | 32 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; |
35 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; | 33 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; |
36 | 34 | ||
37 | pub use rowan::{Direction, NodeOrToken}; | ||
38 | |||
39 | #[derive(Default)] | 35 | #[derive(Default)] |
40 | pub struct SyntaxTreeBuilder { | 36 | pub struct SyntaxTreeBuilder { |
41 | errors: Vec<SyntaxError>, | 37 | errors: Vec<SyntaxError>, |
diff --git a/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast b/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast new file mode 100644 index 000000000..c204f0e2d --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rast | |||
@@ -0,0 +1,54 @@ | |||
1 | [email protected] | ||
2 | [email protected] | ||
3 | [email protected] "struct" | ||
4 | [email protected] " " | ||
5 | [email protected] | ||
6 | [email protected] "B" | ||
7 | [email protected] | ||
8 | [email protected] "(" | ||
9 | [email protected] | ||
10 | [email protected] | ||
11 | [email protected] "pub" | ||
12 | [email protected] " " | ||
13 | [email protected] | ||
14 | [email protected] "(" | ||
15 | [email protected] | ||
16 | [email protected] | ||
17 | [email protected] | ||
18 | [email protected] | ||
19 | [email protected] "super" | ||
20 | [email protected] "::" | ||
21 | [email protected] | ||
22 | [email protected] | ||
23 | [email protected] "A" | ||
24 | [email protected] ")" | ||
25 | [email protected] ")" | ||
26 | [email protected] ";" | ||
27 | [email protected] "\n" | ||
28 | [email protected] | ||
29 | [email protected] "struct" | ||
30 | [email protected] " " | ||
31 | [email protected] | ||
32 | [email protected] "B" | ||
33 | [email protected] | ||
34 | [email protected] "(" | ||
35 | [email protected] | ||
36 | [email protected] | ||
37 | [email protected] "pub" | ||
38 | [email protected] " " | ||
39 | [email protected] | ||
40 | [email protected] "(" | ||
41 | [email protected] | ||
42 | [email protected] | ||
43 | [email protected] | ||
44 | [email protected] | ||
45 | [email protected] "crate" | ||
46 | [email protected] "::" | ||
47 | [email protected] | ||
48 | [email protected] | ||
49 | [email protected] "A" | ||
50 | [email protected] "," | ||
51 | [email protected] ")" | ||
52 | [email protected] ")" | ||
53 | [email protected] ";" | ||
54 | [email protected] "\n" | ||
diff --git a/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rs b/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rs new file mode 100644 index 000000000..d4c163822 --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0153_pub_parens_typepath.rs | |||
@@ -0,0 +1,2 @@ | |||
1 | struct B(pub (super::A)); | ||
2 | struct B(pub (crate::A,)); | ||