diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/algo.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/reparsing.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/src/syntax_node.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt | 128 |
6 files changed, 138 insertions, 9 deletions
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index b6ebb129d..c5a3d1999 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -12,7 +12,7 @@ doctest = false | |||
12 | 12 | ||
13 | [dependencies] | 13 | [dependencies] |
14 | itertools = "0.8.0" | 14 | itertools = "0.8.0" |
15 | rowan = "0.8.0" | 15 | rowan = "0.9.0" |
16 | rustc_lexer = "0.1.0" | 16 | rustc_lexer = "0.1.0" |
17 | rustc-hash = "1.0.1" | 17 | rustc-hash = "1.0.1" |
18 | arrayvec = "0.5.1" | 18 | arrayvec = "0.5.1" |
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index e4061e994..2b2b295f9 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs | |||
@@ -214,8 +214,7 @@ fn with_children( | |||
214 | new_children: Vec<NodeOrToken<rowan::GreenNode, rowan::GreenToken>>, | 214 | new_children: Vec<NodeOrToken<rowan::GreenNode, rowan::GreenToken>>, |
215 | ) -> SyntaxNode { | 215 | ) -> SyntaxNode { |
216 | let len = new_children.iter().map(|it| it.text_len()).sum::<TextUnit>(); | 216 | let len = new_children.iter().map(|it| it.text_len()).sum::<TextUnit>(); |
217 | let new_node = | 217 | let new_node = rowan::GreenNode::new(rowan::SyntaxKind(parent.kind() as u16), new_children); |
218 | rowan::GreenNode::new(rowan::cursor::SyntaxKind(parent.kind() as u16), new_children); | ||
219 | let new_root_node = parent.replace_with(new_node); | 218 | let new_root_node = parent.replace_with(new_node); |
220 | let new_root_node = SyntaxNode::new_root(new_root_node); | 219 | let new_root_node = SyntaxNode::new_root(new_root_node); |
221 | 220 | ||
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index 65b8aa10d..06bdda11d 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs | |||
@@ -70,8 +70,7 @@ fn reparse_token<'node>( | |||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | let new_token = | 73 | let new_token = GreenToken::new(rowan::SyntaxKind(token.kind().into()), text.into()); |
74 | GreenToken::new(rowan::cursor::SyntaxKind(token.kind().into()), text.into()); | ||
75 | Some((token.replace_with(new_token), token.text_range())) | 74 | Some((token.replace_with(new_token), token.text_range())) |
76 | } | 75 | } |
77 | _ => None, | 76 | _ => None, |
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index 041c6ea8d..b3eb5da63 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs | |||
@@ -21,18 +21,18 @@ pub enum RustLanguage {} | |||
21 | impl Language for RustLanguage { | 21 | impl Language for RustLanguage { |
22 | type Kind = SyntaxKind; | 22 | type Kind = SyntaxKind; |
23 | 23 | ||
24 | fn kind_from_raw(raw: rowan::cursor::SyntaxKind) -> SyntaxKind { | 24 | fn kind_from_raw(raw: rowan::SyntaxKind) -> SyntaxKind { |
25 | SyntaxKind::from(raw.0) | 25 | SyntaxKind::from(raw.0) |
26 | } | 26 | } |
27 | 27 | ||
28 | fn kind_to_raw(kind: SyntaxKind) -> rowan::cursor::SyntaxKind { | 28 | fn kind_to_raw(kind: SyntaxKind) -> rowan::SyntaxKind { |
29 | rowan::cursor::SyntaxKind(kind.into()) | 29 | rowan::SyntaxKind(kind.into()) |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | pub type SyntaxNode = rowan::SyntaxNode<RustLanguage>; | 33 | pub type SyntaxNode = rowan::SyntaxNode<RustLanguage>; |
34 | pub type SyntaxToken = rowan::SyntaxToken<RustLanguage>; | 34 | pub type SyntaxToken = rowan::SyntaxToken<RustLanguage>; |
35 | pub type SyntaxElement = rowan::NodeOrToken<SyntaxNode, SyntaxToken>; | 35 | pub type SyntaxElement = rowan::SyntaxElement<RustLanguage>; |
36 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; | 36 | pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<RustLanguage>; |
37 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; | 37 | pub type SyntaxElementChildren = rowan::SyntaxElementChildren<RustLanguage>; |
38 | 38 | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rs b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rs new file mode 100644 index 000000000..4bd428ee4 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | trait Z<U> = T<U>; | ||
2 | trait Z<U> = T<U> where U: Copy; | ||
3 | trait Z<U> = where Self: T<U>; | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt new file mode 100644 index 000000000..de1536ef0 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt | |||
@@ -0,0 +1,128 @@ | |||
1 | SOURCE_FILE@[0; 83) | ||
2 | TRAIT_DEF@[0; 18) | ||
3 | TRAIT_KW@[0; 5) "trait" | ||
4 | WHITESPACE@[5; 6) " " | ||
5 | NAME@[6; 7) | ||
6 | IDENT@[6; 7) "Z" | ||
7 | TYPE_PARAM_LIST@[7; 10) | ||
8 | L_ANGLE@[7; 8) "<" | ||
9 | TYPE_PARAM@[8; 9) | ||
10 | NAME@[8; 9) | ||
11 | IDENT@[8; 9) "U" | ||
12 | R_ANGLE@[9; 10) ">" | ||
13 | WHITESPACE@[10; 11) " " | ||
14 | EQ@[11; 12) "=" | ||
15 | WHITESPACE@[12; 13) " " | ||
16 | TYPE_BOUND_LIST@[13; 17) | ||
17 | TYPE_BOUND@[13; 17) | ||
18 | PATH_TYPE@[13; 17) | ||
19 | PATH@[13; 17) | ||
20 | PATH_SEGMENT@[13; 17) | ||
21 | NAME_REF@[13; 14) | ||
22 | IDENT@[13; 14) "T" | ||
23 | TYPE_ARG_LIST@[14; 17) | ||
24 | L_ANGLE@[14; 15) "<" | ||
25 | TYPE_ARG@[15; 16) | ||
26 | PATH_TYPE@[15; 16) | ||
27 | PATH@[15; 16) | ||
28 | PATH_SEGMENT@[15; 16) | ||
29 | NAME_REF@[15; 16) | ||
30 | IDENT@[15; 16) "U" | ||
31 | R_ANGLE@[16; 17) ">" | ||
32 | SEMI@[17; 18) ";" | ||
33 | WHITESPACE@[18; 19) "\n" | ||
34 | TRAIT_DEF@[19; 51) | ||
35 | TRAIT_KW@[19; 24) "trait" | ||
36 | WHITESPACE@[24; 25) " " | ||
37 | NAME@[25; 26) | ||
38 | IDENT@[25; 26) "Z" | ||
39 | TYPE_PARAM_LIST@[26; 29) | ||
40 | L_ANGLE@[26; 27) "<" | ||
41 | TYPE_PARAM@[27; 28) | ||
42 | NAME@[27; 28) | ||
43 | IDENT@[27; 28) "U" | ||
44 | R_ANGLE@[28; 29) ">" | ||
45 | WHITESPACE@[29; 30) " " | ||
46 | EQ@[30; 31) "=" | ||
47 | WHITESPACE@[31; 32) " " | ||
48 | TYPE_BOUND_LIST@[32; 36) | ||
49 | TYPE_BOUND@[32; 36) | ||
50 | PATH_TYPE@[32; 36) | ||
51 | PATH@[32; 36) | ||
52 | PATH_SEGMENT@[32; 36) | ||
53 | NAME_REF@[32; 33) | ||
54 | IDENT@[32; 33) "T" | ||
55 | TYPE_ARG_LIST@[33; 36) | ||
56 | L_ANGLE@[33; 34) "<" | ||
57 | TYPE_ARG@[34; 35) | ||
58 | PATH_TYPE@[34; 35) | ||
59 | PATH@[34; 35) | ||
60 | PATH_SEGMENT@[34; 35) | ||
61 | NAME_REF@[34; 35) | ||
62 | IDENT@[34; 35) "U" | ||
63 | R_ANGLE@[35; 36) ">" | ||
64 | WHITESPACE@[36; 37) " " | ||
65 | WHERE_CLAUSE@[37; 50) | ||
66 | WHERE_KW@[37; 42) "where" | ||
67 | WHITESPACE@[42; 43) " " | ||
68 | WHERE_PRED@[43; 50) | ||
69 | PATH_TYPE@[43; 44) | ||
70 | PATH@[43; 44) | ||
71 | PATH_SEGMENT@[43; 44) | ||
72 | NAME_REF@[43; 44) | ||
73 | IDENT@[43; 44) "U" | ||
74 | COLON@[44; 45) ":" | ||
75 | WHITESPACE@[45; 46) " " | ||
76 | TYPE_BOUND_LIST@[46; 50) | ||
77 | TYPE_BOUND@[46; 50) | ||
78 | PATH_TYPE@[46; 50) | ||
79 | PATH@[46; 50) | ||
80 | PATH_SEGMENT@[46; 50) | ||
81 | NAME_REF@[46; 50) | ||
82 | IDENT@[46; 50) "Copy" | ||
83 | SEMI@[50; 51) ";" | ||
84 | WHITESPACE@[51; 52) "\n" | ||
85 | TRAIT_DEF@[52; 82) | ||
86 | TRAIT_KW@[52; 57) "trait" | ||
87 | WHITESPACE@[57; 58) " " | ||
88 | NAME@[58; 59) | ||
89 | IDENT@[58; 59) "Z" | ||
90 | TYPE_PARAM_LIST@[59; 62) | ||
91 | L_ANGLE@[59; 60) "<" | ||
92 | TYPE_PARAM@[60; 61) | ||
93 | NAME@[60; 61) | ||
94 | IDENT@[60; 61) "U" | ||
95 | R_ANGLE@[61; 62) ">" | ||
96 | WHITESPACE@[62; 63) " " | ||
97 | EQ@[63; 64) "=" | ||
98 | WHITESPACE@[64; 65) " " | ||
99 | TYPE_BOUND_LIST@[65; 65) | ||
100 | WHERE_CLAUSE@[65; 81) | ||
101 | WHERE_KW@[65; 70) "where" | ||
102 | WHITESPACE@[70; 71) " " | ||
103 | WHERE_PRED@[71; 81) | ||
104 | PATH_TYPE@[71; 75) | ||
105 | PATH@[71; 75) | ||
106 | PATH_SEGMENT@[71; 75) | ||
107 | NAME_REF@[71; 75) | ||
108 | IDENT@[71; 75) "Self" | ||
109 | COLON@[75; 76) ":" | ||
110 | WHITESPACE@[76; 77) " " | ||
111 | TYPE_BOUND_LIST@[77; 81) | ||
112 | TYPE_BOUND@[77; 81) | ||
113 | PATH_TYPE@[77; 81) | ||
114 | PATH@[77; 81) | ||
115 | PATH_SEGMENT@[77; 81) | ||
116 | NAME_REF@[77; 78) | ||
117 | IDENT@[77; 78) "T" | ||
118 | TYPE_ARG_LIST@[78; 81) | ||
119 | L_ANGLE@[78; 79) "<" | ||
120 | TYPE_ARG@[79; 80) | ||
121 | PATH_TYPE@[79; 80) | ||
122 | PATH@[79; 80) | ||
123 | PATH_SEGMENT@[79; 80) | ||
124 | NAME_REF@[79; 80) | ||
125 | IDENT@[79; 80) "U" | ||
126 | R_ANGLE@[80; 81) ">" | ||
127 | SEMI@[81; 82) ";" | ||
128 | WHITESPACE@[82; 83) "\n" | ||