aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api/src/call_info.rs114
-rw-r--r--crates/ra_ide_api/src/completion.rs41
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs2
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs5
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap14
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap6
-rw-r--r--crates/ra_ide_api/src/display.rs82
-rw-r--r--crates/ra_ide_api/src/display/function_signature.rs101
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs (renamed from crates/ra_ide_api/src/navigation_target.rs)82
-rw-r--r--crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap (renamed from crates/ra_ide_api/src/snapshots/tests__file_structure.snap)6
-rw-r--r--crates/ra_ide_api/src/display/structure.rs (renamed from crates/ra_ide_api/src/structure.rs)0
-rw-r--r--crates/ra_ide_api/src/hover.rs110
-rw-r--r--crates/ra_ide_api/src/lib.rs12
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs2
-rw-r--r--crates/ra_lsp_server/src/conv.rs22
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs23
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs18
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs.tera18
-rw-r--r--crates/ra_syntax/Cargo.toml2
-rw-r--r--crates/ra_syntax/src/ast.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated.rs230
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera6
-rw-r--r--crates/ra_syntax/src/lib.rs2
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs2
-rw-r--r--crates/ra_syntax/src/syntax_node.rs62
25 files changed, 580 insertions, 386 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 29fa7d30b..dbb3853d0 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -6,9 +6,8 @@ use ra_syntax::{
6 ast::{self, ArgListOwner}, 6 ast::{self, ArgListOwner},
7 algo::find_node_at_offset, 7 algo::find_node_at_offset,
8}; 8};
9use hir::Docs;
10 9
11use crate::{FilePosition, CallInfo, db::RootDatabase}; 10use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase};
12 11
13/// Computes parameter information for the given call expression. 12/// Computes parameter information for the given call expression.
14pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { 13pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {
@@ -27,10 +26,10 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
27 let fn_def = ast::FnDef::cast(fn_def).unwrap(); 26 let fn_def = ast::FnDef::cast(fn_def).unwrap();
28 let function = hir::source_binder::function_from_source(db, symbol.file_id, fn_def)?; 27 let function = hir::source_binder::function_from_source(db, symbol.file_id, fn_def)?;
29 28
30 let mut call_info = CallInfo::new(db, function, fn_def)?; 29 let mut call_info = CallInfo::new(db, function);
31 30
32 // If we have a calling expression let's find which argument we are on 31 // If we have a calling expression let's find which argument we are on
33 let num_params = call_info.parameters.len(); 32 let num_params = call_info.parameters().len();
34 let has_self = fn_def.param_list().and_then(|l| l.self_param()).is_some(); 33 let has_self = fn_def.param_list().and_then(|l| l.self_param()).is_some();
35 34
36 if num_params == 1 { 35 if num_params == 1 {
@@ -107,28 +106,15 @@ impl<'a> FnCallNode<'a> {
107} 106}
108 107
109impl CallInfo { 108impl CallInfo {
110 fn new(db: &RootDatabase, function: hir::Function, node: &ast::FnDef) -> Option<Self> { 109 fn new(db: &RootDatabase, function: hir::Function) -> Self {
111 let label = crate::completion::function_label(node)?; 110 let signature = FunctionSignature::from_hir(db, function);
112 let doc = function.docs(db);
113 111
114 Some(CallInfo { parameters: param_list(node), label, doc, active_parameter: None }) 112 CallInfo { signature, active_parameter: None }
115 } 113 }
116}
117
118fn param_list(node: &ast::FnDef) -> Vec<String> {
119 let mut res = vec![];
120 if let Some(param_list) = node.param_list() {
121 if let Some(self_param) = param_list.self_param() {
122 res.push(self_param.syntax().text().to_string())
123 }
124 114
125 // Maybe use param.pat here? See if we can just extract the name? 115 fn parameters(&self) -> &[String] {
126 //res.extend(param_list.params().map(|p| p.syntax().text().to_string())); 116 &self.signature.parameters
127 res.extend(
128 param_list.params().filter_map(|p| p.pat()).map(|pat| pat.syntax().text().to_string()),
129 );
130 } 117 }
131 res
132} 118}
133 119
134#[cfg(test)] 120#[cfg(test)]
@@ -139,6 +125,17 @@ mod tests {
139 125
140 use super::*; 126 use super::*;
141 127
128 // These are only used when testing
129 impl CallInfo {
130 fn doc(&self) -> Option<hir::Documentation> {
131 self.signature.doc.clone()
132 }
133
134 fn label(&self) -> String {
135 self.signature.to_string()
136 }
137 }
138
142 fn call_info(text: &str) -> CallInfo { 139 fn call_info(text: &str) -> CallInfo {
143 let (analysis, position) = single_file_with_position(text); 140 let (analysis, position) = single_file_with_position(text);
144 analysis.call_info(position).unwrap().unwrap() 141 analysis.call_info(position).unwrap().unwrap()
@@ -151,7 +148,7 @@ mod tests {
151fn bar() { foo(<|>3, ); }"#, 148fn bar() { foo(<|>3, ); }"#,
152 ); 149 );
153 150
154 assert_eq!(info.parameters, vec!("x".to_string(), "y".to_string())); 151 assert_eq!(info.parameters(), ["x: u32", "y: u32"]);
155 assert_eq!(info.active_parameter, Some(0)); 152 assert_eq!(info.active_parameter, Some(0));
156 } 153 }
157 154
@@ -162,7 +159,7 @@ fn bar() { foo(<|>3, ); }"#,
162fn bar() { foo(3, <|>); }"#, 159fn bar() { foo(3, <|>); }"#,
163 ); 160 );
164 161
165 assert_eq!(info.parameters, vec!("x".to_string(), "y".to_string())); 162 assert_eq!(info.parameters(), ["x: u32", "y: u32"]);
166 assert_eq!(info.active_parameter, Some(1)); 163 assert_eq!(info.active_parameter, Some(1));
167 } 164 }
168 165
@@ -173,18 +170,57 @@ fn bar() { foo(3, <|>); }"#,
173fn bar() { foo(<|>); }"#, 170fn bar() { foo(<|>); }"#,
174 ); 171 );
175 172
176 assert_eq!(info.parameters, vec!("x".to_string(), "y".to_string())); 173 assert_eq!(info.parameters(), ["x: u32", "y: u32"]);
174 assert_eq!(info.active_parameter, Some(0));
175 }
176
177 #[test]
178 fn test_fn_signature_two_args_first_generics() {
179 let info = call_info(
180 r#"fn foo<T, U: Copy + Display>(x: T, y: U) -> u32 where T: Copy + Display, U: Debug {x + y}
181fn bar() { foo(<|>3, ); }"#,
182 );
183
184 assert_eq!(info.parameters(), ["x: T", "y: U"]);
185 assert_eq!(
186 info.label(),
187 r#"
188fn foo<T, U: Copy + Display>(x: T, y: U) -> u32
189where T: Copy + Display,
190 U: Debug
191 "#
192 .trim()
193 );
177 assert_eq!(info.active_parameter, Some(0)); 194 assert_eq!(info.active_parameter, Some(0));
178 } 195 }
179 196
180 #[test] 197 #[test]
198 fn test_fn_signature_no_params() {
199 let info = call_info(
200 r#"fn foo<T>() -> T where T: Copy + Display {}
201fn bar() { foo(<|>); }"#,
202 );
203
204 assert!(info.parameters().is_empty());
205 assert_eq!(
206 info.label(),
207 r#"
208fn foo<T>() -> T
209where T: Copy + Display
210 "#
211 .trim()
212 );
213 assert!(info.active_parameter.is_none());
214 }
215
216 #[test]
181 fn test_fn_signature_for_impl() { 217 fn test_fn_signature_for_impl() {
182 let info = call_info( 218 let info = call_info(
183 r#"struct F; impl F { pub fn new() { F{}} } 219 r#"struct F; impl F { pub fn new() { F{}} }
184fn bar() {let _ : F = F::new(<|>);}"#, 220fn bar() {let _ : F = F::new(<|>);}"#,
185 ); 221 );
186 222
187 assert_eq!(info.parameters, Vec::<String>::new()); 223 assert!(info.parameters().is_empty());
188 assert_eq!(info.active_parameter, None); 224 assert_eq!(info.active_parameter, None);
189 } 225 }
190 226
@@ -206,7 +242,7 @@ fn bar() {
206}"#, 242}"#,
207 ); 243 );
208 244
209 assert_eq!(info.parameters, vec!["&self".to_string()]); 245 assert_eq!(info.parameters(), ["&self"]);
210 assert_eq!(info.active_parameter, None); 246 assert_eq!(info.active_parameter, None);
211 } 247 }
212 248
@@ -228,7 +264,7 @@ fn bar() {
228}"#, 264}"#,
229 ); 265 );
230 266
231 assert_eq!(info.parameters, vec!["&self".to_string(), "x".to_string()]); 267 assert_eq!(info.parameters(), ["&self", "x: i32"]);
232 assert_eq!(info.active_parameter, Some(1)); 268 assert_eq!(info.active_parameter, Some(1));
233 } 269 }
234 270
@@ -248,10 +284,10 @@ fn bar() {
248"#, 284"#,
249 ); 285 );
250 286
251 assert_eq!(info.parameters, vec!["j".to_string()]); 287 assert_eq!(info.parameters(), ["j: u32"]);
252 assert_eq!(info.active_parameter, Some(0)); 288 assert_eq!(info.active_parameter, Some(0));
253 assert_eq!(info.label, "fn foo(j: u32) -> u32".to_string()); 289 assert_eq!(info.label(), "fn foo(j: u32) -> u32");
254 assert_eq!(info.doc.map(|it| it.into()), Some("test".to_string())); 290 assert_eq!(info.doc().map(|it| it.into()), Some("test".to_string()));
255 } 291 }
256 292
257 #[test] 293 #[test]
@@ -276,11 +312,11 @@ pub fn do() {
276}"#, 312}"#,
277 ); 313 );
278 314
279 assert_eq!(info.parameters, vec!["x".to_string()]); 315 assert_eq!(info.parameters(), ["x: i32"]);
280 assert_eq!(info.active_parameter, Some(0)); 316 assert_eq!(info.active_parameter, Some(0));
281 assert_eq!(info.label, "pub fn add_one(x: i32) -> i32".to_string()); 317 assert_eq!(info.label(), "pub fn add_one(x: i32) -> i32");
282 assert_eq!( 318 assert_eq!(
283 info.doc.map(|it| it.into()), 319 info.doc().map(|it| it.into()),
284 Some( 320 Some(
285 r#"Adds one to the number given. 321 r#"Adds one to the number given.
286 322
@@ -322,11 +358,11 @@ pub fn do_it() {
322}"#, 358}"#,
323 ); 359 );
324 360
325 assert_eq!(info.parameters, vec!["x".to_string()]); 361 assert_eq!(info.parameters(), ["x: i32"]);
326 assert_eq!(info.active_parameter, Some(0)); 362 assert_eq!(info.active_parameter, Some(0));
327 assert_eq!(info.label, "pub fn add_one(x: i32) -> i32".to_string()); 363 assert_eq!(info.label(), "pub fn add_one(x: i32) -> i32");
328 assert_eq!( 364 assert_eq!(
329 info.doc.map(|it| it.into()), 365 info.doc().map(|it| it.into()),
330 Some( 366 Some(
331 r#"Adds one to the number given. 367 r#"Adds one to the number given.
332 368
@@ -375,10 +411,10 @@ pub fn foo() {
375"#, 411"#,
376 ); 412 );
377 413
378 assert_eq!(info.parameters, vec!["&mut self".to_string(), "ctx".to_string()]); 414 assert_eq!(info.parameters(), ["&mut self", "ctx: &mut Self::Context"]);
379 assert_eq!(info.active_parameter, Some(1)); 415 assert_eq!(info.active_parameter, Some(1));
380 assert_eq!( 416 assert_eq!(
381 info.doc.map(|it| it.into()), 417 info.doc().map(|it| it.into()),
382 Some( 418 Some(
383 r#"Method is called when writer finishes. 419 r#"Method is called when writer finishes.
384 420
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs
index a846a7a3c..deff59cd3 100644
--- a/crates/ra_ide_api/src/completion.rs
+++ b/crates/ra_ide_api/src/completion.rs
@@ -13,7 +13,6 @@ mod complete_scope;
13mod complete_postfix; 13mod complete_postfix;
14 14
15use ra_db::SourceDatabase; 15use ra_db::SourceDatabase;
16use ra_syntax::{ast::{self, AstNode}, SyntaxKind::{ATTR, COMMENT}};
17 16
18use crate::{ 17use crate::{
19 db, 18 db,
@@ -70,43 +69,3 @@ pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Opti
70 complete_postfix::complete_postfix(&mut acc, &ctx); 69 complete_postfix::complete_postfix(&mut acc, &ctx);
71 Some(acc) 70 Some(acc)
72} 71}
73
74pub fn function_label(node: &ast::FnDef) -> Option<String> {
75 let label: String = if let Some(body) = node.body() {
76 let body_range = body.syntax().range();
77 let label: String = node
78 .syntax()
79 .children_with_tokens()
80 .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body
81 .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR)) // Filter out comments and attrs
82 .map(|node| node.to_string())
83 .collect();
84 label
85 } else {
86 node.syntax().text().to_string()
87 };
88
89 Some(label.trim().to_owned())
90}
91
92pub fn const_label(node: &ast::ConstDef) -> String {
93 let label: String = node
94 .syntax()
95 .children_with_tokens()
96 .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR))
97 .map(|node| node.to_string())
98 .collect();
99
100 label.trim().to_owned()
101}
102
103pub fn type_label(node: &ast::TypeAliasDef) -> String {
104 let label: String = node
105 .syntax()
106 .children_with_tokens()
107 .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR))
108 .map(|node| node.to_string())
109 .collect();
110
111 label.trim().to_owned()
112}
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 6146b7bb6..9d82f2270 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -145,7 +145,7 @@ mod tests {
145 check_reference_completion( 145 check_reference_completion(
146 "dont_show_both_completions_for_shadowing", 146 "dont_show_both_completions_for_shadowing",
147 r" 147 r"
148 fn foo() -> { 148 fn foo() {
149 let bar = 92; 149 let bar = 92;
150 { 150 {
151 let bar = 62; 151 let bar = 62;
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index 28c8f83ab..9aa346688 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -6,6 +6,9 @@ use ra_syntax::ast::NameOwner;
6 6
7use crate::completion::{ 7use crate::completion::{
8 Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, 8 Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem,
9};
10
11use crate::display::{
9 function_label, const_label, type_label, 12 function_label, const_label, type_label,
10}; 13};
11 14
@@ -101,7 +104,7 @@ impl Completions {
101 CompletionItemKind::Function 104 CompletionItemKind::Function
102 }) 105 })
103 .set_documentation(func.docs(ctx.db)) 106 .set_documentation(func.docs(ctx.db))
104 .set_detail(detail); 107 .detail(detail);
105 // If not an import, add parenthesis automatically. 108 // If not an import, add parenthesis automatically.
106 if ctx.use_item_syntax.is_none() && !ctx.is_call { 109 if ctx.use_item_syntax.is_none() && !ctx.is_call {
107 tested_by!(inserts_parens_for_function_calls); 110 tested_by!(inserts_parens_for_function_calls);
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap
index 87691b304..34adcda6c 100644
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap
@@ -1,23 +1,23 @@
1--- 1---
2created: "2019-02-18T09:22:24.188564584Z" 2created: "2019-04-04T14:52:24.531844100Z"
3creator: insta@0.6.2 3creator: insta@0.7.4
4source: crates/ra_ide_api/src/completion/completion_item.rs 4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions 5expression: kind_completions
6--- 6---
7[ 7[
8 CompletionItem { 8 CompletionItem {
9 label: "bar", 9 label: "bar",
10 source_range: [129; 129), 10 source_range: [126; 126),
11 delete: [129; 129), 11 delete: [126; 126),
12 insert: "bar", 12 insert: "bar",
13 kind: Binding 13 kind: Binding
14 }, 14 },
15 CompletionItem { 15 CompletionItem {
16 label: "foo", 16 label: "foo",
17 source_range: [129; 129), 17 source_range: [126; 126),
18 delete: [129; 129), 18 delete: [126; 126),
19 insert: "foo()$0", 19 insert: "foo()$0",
20 kind: Function, 20 kind: Function,
21 detail: "fn foo() ->" 21 detail: "fn foo()"
22 } 22 }
23] 23]
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap
index 0738cf466..ff36df707 100644
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap
@@ -1,6 +1,6 @@
1--- 1---
2created: "2019-02-18T09:22:24.182964414Z" 2created: "2019-04-04T14:52:24.525395600Z"
3creator: insta@0.6.2 3creator: insta@0.7.4
4source: crates/ra_ide_api/src/completion/completion_item.rs 4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions 5expression: kind_completions
6--- 6---
@@ -18,6 +18,6 @@ expression: kind_completions
18 delete: [47; 47), 18 delete: [47; 47),
19 insert: "x()$0", 19 insert: "x()$0",
20 kind: Function, 20 kind: Function,
21 detail: "fn x() ->" 21 detail: "fn x()"
22 } 22 }
23] 23]
diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide_api/src/display.rs
new file mode 100644
index 000000000..1b06abf94
--- /dev/null
+++ b/crates/ra_ide_api/src/display.rs
@@ -0,0 +1,82 @@
1//! This module contains utilities for turning SyntaxNodes and HIR types
2//! into types that may be used to render in a UI.
3
4mod function_signature;
5mod navigation_target;
6mod structure;
7
8use crate::db::RootDatabase;
9use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}};
10
11pub use navigation_target::NavigationTarget;
12pub use structure::{StructureNode, file_structure};
13pub use function_signature::FunctionSignature;
14
15pub(crate) fn function_label(node: &ast::FnDef) -> String {
16 FunctionSignature::from(node).to_string()
17}
18
19pub(crate) fn const_label(node: &ast::ConstDef) -> String {
20 let label: String = node
21 .syntax()
22 .children_with_tokens()
23 .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR))
24 .map(|node| node.to_string())
25 .collect();
26
27 label.trim().to_owned()
28}
29
30pub(crate) fn type_label(node: &ast::TypeAliasDef) -> String {
31 let label: String = node
32 .syntax()
33 .children_with_tokens()
34 .filter(|child| !(child.kind() == COMMENT || child.kind() == ATTR))
35 .map(|node| node.to_string())
36 .collect();
37
38 label.trim().to_owned()
39}
40
41pub(crate) fn generic_parameters<N: TypeParamsOwner>(node: &N) -> Vec<String> {
42 let mut res = vec![];
43 if let Some(type_params) = node.type_param_list() {
44 res.extend(type_params.lifetime_params().map(|p| p.syntax().text().to_string()));
45 res.extend(type_params.type_params().map(|p| p.syntax().text().to_string()));
46 }
47 res
48}
49
50pub(crate) fn where_predicates<N: TypeParamsOwner>(node: &N) -> Vec<String> {
51 let mut res = vec![];
52 if let Some(clause) = node.where_clause() {
53 res.extend(clause.predicates().map(|p| p.syntax().text().to_string()));
54 }
55 res
56}
57
58pub(crate) fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String {
59 rust_code_markup_with_doc::<_, &str>(val, None)
60}
61
62pub(crate) fn rust_code_markup_with_doc<CODE, DOC>(val: CODE, doc: Option<DOC>) -> String
63where
64 CODE: AsRef<str>,
65 DOC: AsRef<str>,
66{
67 if let Some(doc) = doc {
68 format!("```rust\n{}\n```\n\n{}", val.as_ref(), doc.as_ref())
69 } else {
70 format!("```rust\n{}\n```", val.as_ref())
71 }
72}
73
74// FIXME: this should not really use navigation target. Rather, approximately
75// resolved symbol should return a `DefId`.
76pub(crate) fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Option<String> {
77 match (nav.description(db), nav.docs(db)) {
78 (Some(desc), docs) => Some(rust_code_markup_with_doc(desc, docs)),
79 (None, Some(docs)) => Some(docs),
80 _ => None,
81 }
82}
diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs
new file mode 100644
index 000000000..d09950bce
--- /dev/null
+++ b/crates/ra_ide_api/src/display/function_signature.rs
@@ -0,0 +1,101 @@
1use super::{where_predicates, generic_parameters};
2use crate::db;
3use std::fmt::{self, Display};
4use join_to_string::join;
5use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
6use std::convert::From;
7use hir::{Docs, Documentation};
8
9/// Contains information about a function signature
10#[derive(Debug)]
11pub struct FunctionSignature {
12 /// Optional visibility
13 pub visibility: Option<String>,
14 /// Name of the function
15 pub name: Option<String>,
16 /// Documentation for the function
17 pub doc: Option<Documentation>,
18 /// Generic parameters
19 pub generic_parameters: Vec<String>,
20 /// Parameters of the function
21 pub parameters: Vec<String>,
22 /// Optional return type
23 pub ret_type: Option<String>,
24 /// Where predicates
25 pub where_predicates: Vec<String>,
26}
27
28impl FunctionSignature {
29 pub(crate) fn with_doc_opt(mut self, doc: Option<Documentation>) -> Self {
30 self.doc = doc;
31 self
32 }
33
34 pub(crate) fn from_hir(db: &db::RootDatabase, function: hir::Function) -> Self {
35 let doc = function.docs(db);
36 let (_, ast_node) = function.source(db);
37 FunctionSignature::from(&*ast_node).with_doc_opt(doc)
38 }
39}
40
41impl From<&'_ ast::FnDef> for FunctionSignature {
42 fn from(node: &ast::FnDef) -> FunctionSignature {
43 fn param_list(node: &ast::FnDef) -> Vec<String> {
44 let mut res = vec![];
45 if let Some(param_list) = node.param_list() {
46 if let Some(self_param) = param_list.self_param() {
47 res.push(self_param.syntax().text().to_string())
48 }
49
50 res.extend(param_list.params().map(|param| param.syntax().text().to_string()));
51 }
52 res
53 }
54
55 FunctionSignature {
56 visibility: node.visibility().map(|n| n.syntax().text().to_string()),
57 name: node.name().map(|n| n.text().to_string()),
58 ret_type: node
59 .ret_type()
60 .and_then(|r| r.type_ref())
61 .map(|n| n.syntax().text().to_string()),
62 parameters: param_list(node),
63 generic_parameters: generic_parameters(node),
64 where_predicates: where_predicates(node),
65 // docs are processed separately
66 doc: None,
67 }
68 }
69}
70
71impl Display for FunctionSignature {
72 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
73 if let Some(t) = &self.visibility {
74 write!(f, "{} ", t)?;
75 }
76
77 if let Some(name) = &self.name {
78 write!(f, "fn {}", name)?;
79 }
80
81 if !self.generic_parameters.is_empty() {
82 join(self.generic_parameters.iter())
83 .separator(", ")
84 .surround_with("<", ">")
85 .to_fmt(f)?;
86 }
87
88 join(self.parameters.iter()).separator(", ").surround_with("(", ")").to_fmt(f)?;
89
90 if let Some(t) = &self.ret_type {
91 write!(f, " -> {}", t)?;
92 }
93
94 if !self.where_predicates.is_empty() {
95 write!(f, "\nwhere ")?;
96 join(self.where_predicates.iter()).separator(",\n ").to_fmt(f)?;
97 }
98
99 Ok(())
100 }
101}
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index f6d7f3192..3c518faf5 100644
--- a/crates/ra_ide_api/src/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -1,7 +1,9 @@
1use ra_db::FileId; 1use ra_db::{FileId, SourceDatabase};
2use ra_syntax::{ 2use ra_syntax::{
3 SyntaxNode, SyntaxNodePtr, AstNode, SmolStr, TextRange, ast, 3 SyntaxNode, SyntaxNodePtr, AstNode, SmolStr, TextRange, TreeArc,
4 SyntaxKind::{self, NAME}, 4 SyntaxKind::{self, NAME},
5 ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner},
6 algo::visit::{visitor, Visitor},
5}; 7};
6use hir::{ModuleSource, FieldSource, Name, ImplItem}; 8use hir::{ModuleSource, FieldSource, Name, ImplItem};
7 9
@@ -248,4 +250,80 @@ impl NavigationTarget {
248 container_name: None, 250 container_name: None,
249 } 251 }
250 } 252 }
253
254 pub(crate) fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> {
255 let source_file = db.parse(self.file_id());
256 let source_file = source_file.syntax();
257 let node = source_file
258 .descendants()
259 .find(|node| node.kind() == self.kind() && node.range() == self.full_range())?
260 .to_owned();
261 Some(node)
262 }
263
264 pub(crate) fn docs(&self, db: &RootDatabase) -> Option<String> {
265 let node = self.node(db)?;
266 fn doc_comments<N: ast::DocCommentsOwner>(node: &N) -> Option<String> {
267 node.doc_comment_text()
268 }
269
270 visitor()
271 .visit(doc_comments::<ast::FnDef>)
272 .visit(doc_comments::<ast::StructDef>)
273 .visit(doc_comments::<ast::EnumDef>)
274 .visit(doc_comments::<ast::TraitDef>)
275 .visit(doc_comments::<ast::Module>)
276 .visit(doc_comments::<ast::TypeAliasDef>)
277 .visit(doc_comments::<ast::ConstDef>)
278 .visit(doc_comments::<ast::StaticDef>)
279 .visit(doc_comments::<ast::NamedFieldDef>)
280 .visit(doc_comments::<ast::EnumVariant>)
281 .accept(&node)?
282 }
283
284 /// Get a description of this node.
285 ///
286 /// e.g. `struct Name`, `enum Name`, `fn Name`
287 pub(crate) fn description(&self, db: &RootDatabase) -> Option<String> {
288 // FIXME: After type inference is done, add type information to improve the output
289 let node = self.node(db)?;
290
291 fn visit_ascribed_node<T>(node: &T, prefix: &str) -> Option<String>
292 where
293 T: NameOwner + VisibilityOwner + TypeAscriptionOwner,
294 {
295 let mut string = visit_node(node, prefix)?;
296
297 if let Some(type_ref) = node.ascribed_type() {
298 string.push_str(": ");
299 type_ref.syntax().text().push_to(&mut string);
300 }
301
302 Some(string)
303 }
304
305 fn visit_node<T>(node: &T, label: &str) -> Option<String>
306 where
307 T: NameOwner + VisibilityOwner,
308 {
309 let mut string =
310 node.visibility().map(|v| format!("{} ", v.syntax().text())).unwrap_or_default();
311 string.push_str(label);
312 string.push_str(node.name()?.text().as_str());
313 Some(string)
314 }
315
316 visitor()
317 .visit(|node: &ast::FnDef| Some(crate::display::function_label(node)))
318 .visit(|node: &ast::StructDef| visit_node(node, "struct "))
319 .visit(|node: &ast::EnumDef| visit_node(node, "enum "))
320 .visit(|node: &ast::TraitDef| visit_node(node, "trait "))
321 .visit(|node: &ast::Module| visit_node(node, "mod "))
322 .visit(|node: &ast::TypeAliasDef| visit_node(node, "type "))
323 .visit(|node: &ast::ConstDef| visit_ascribed_node(node, "const "))
324 .visit(|node: &ast::StaticDef| visit_ascribed_node(node, "static "))
325 .visit(|node: &ast::NamedFieldDef| visit_ascribed_node(node, ""))
326 .visit(|node: &ast::EnumVariant| Some(node.name()?.text().to_string()))
327 .accept(&node)?
328 }
251} 329}
diff --git a/crates/ra_ide_api/src/snapshots/tests__file_structure.snap b/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap
index 2efa8e22c..32dd99484 100644
--- a/crates/ra_ide_api/src/snapshots/tests__file_structure.snap
+++ b/crates/ra_ide_api/src/display/snapshots/tests__file_structure.snap
@@ -1,7 +1,7 @@
1--- 1---
2created: "2019-02-05T22:03:50.763530100Z" 2created: "2019-04-08T09:44:50.196004400Z"
3creator: insta@0.6.1 3creator: insta@0.7.4
4source: crates/ra_ide_api/src/structure.rs 4source: crates/ra_ide_api/src/display/structure.rs
5expression: structure 5expression: structure
6--- 6---
7[ 7[
diff --git a/crates/ra_ide_api/src/structure.rs b/crates/ra_ide_api/src/display/structure.rs
index ec2c9bbc6..ec2c9bbc6 100644
--- a/crates/ra_ide_api/src/structure.rs
+++ b/crates/ra_ide_api/src/display/structure.rs
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index bfa7cd67a..3a8c93b99 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -1,11 +1,11 @@
1use ra_db::SourceDatabase; 1use ra_db::SourceDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 AstNode, SyntaxNode, TreeArc, ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner}, 3 AstNode, ast,
4 algo::{find_covering_element, find_node_at_offset, find_token_at_offset, visit::{visitor, Visitor}}, 4 algo::{find_covering_element, find_node_at_offset, find_token_at_offset},
5}; 5};
6use hir::HirDisplay; 6use hir::HirDisplay;
7 7
8use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget}; 8use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, display::{rust_code_markup, doc_text_for}};
9 9
10/// Contains the results when hovering over an item 10/// Contains the results when hovering over an item
11#[derive(Debug, Clone)] 11#[derive(Debug, Clone)]
@@ -145,110 +145,6 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
145 } 145 }
146} 146}
147 147
148fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String {
149 rust_code_markup_with_doc::<_, &str>(val, None)
150}
151
152fn rust_code_markup_with_doc<CODE, DOC>(val: CODE, doc: Option<DOC>) -> String
153where
154 CODE: AsRef<str>,
155 DOC: AsRef<str>,
156{
157 if let Some(doc) = doc {
158 format!("```rust\n{}\n```\n\n{}", val.as_ref(), doc.as_ref())
159 } else {
160 format!("```rust\n{}\n```", val.as_ref())
161 }
162}
163
164// FIXME: this should not really use navigation target. Rather, approximately
165// resolved symbol should return a `DefId`.
166fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Option<String> {
167 match (nav.description(db), nav.docs(db)) {
168 (Some(desc), docs) => Some(rust_code_markup_with_doc(desc, docs)),
169 (None, Some(docs)) => Some(docs),
170 _ => None,
171 }
172}
173
174impl NavigationTarget {
175 fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> {
176 let source_file = db.parse(self.file_id());
177 let source_file = source_file.syntax();
178 let node = source_file
179 .descendants()
180 .find(|node| node.kind() == self.kind() && node.range() == self.full_range())?
181 .to_owned();
182 Some(node)
183 }
184
185 fn docs(&self, db: &RootDatabase) -> Option<String> {
186 let node = self.node(db)?;
187 fn doc_comments<N: ast::DocCommentsOwner>(node: &N) -> Option<String> {
188 node.doc_comment_text()
189 }
190
191 visitor()
192 .visit(doc_comments::<ast::FnDef>)
193 .visit(doc_comments::<ast::StructDef>)
194 .visit(doc_comments::<ast::EnumDef>)
195 .visit(doc_comments::<ast::TraitDef>)
196 .visit(doc_comments::<ast::Module>)
197 .visit(doc_comments::<ast::TypeAliasDef>)
198 .visit(doc_comments::<ast::ConstDef>)
199 .visit(doc_comments::<ast::StaticDef>)
200 .visit(doc_comments::<ast::NamedFieldDef>)
201 .visit(doc_comments::<ast::EnumVariant>)
202 .accept(&node)?
203 }
204
205 /// Get a description of this node.
206 ///
207 /// e.g. `struct Name`, `enum Name`, `fn Name`
208 fn description(&self, db: &RootDatabase) -> Option<String> {
209 // FIXME: After type inference is done, add type information to improve the output
210 let node = self.node(db)?;
211
212 fn visit_ascribed_node<T>(node: &T, prefix: &str) -> Option<String>
213 where
214 T: NameOwner + VisibilityOwner + TypeAscriptionOwner,
215 {
216 let mut string = visit_node(node, prefix)?;
217
218 if let Some(type_ref) = node.ascribed_type() {
219 string.push_str(": ");
220 type_ref.syntax().text().push_to(&mut string);
221 }
222
223 Some(string)
224 }
225
226 fn visit_node<T>(node: &T, label: &str) -> Option<String>
227 where
228 T: NameOwner + VisibilityOwner,
229 {
230 let mut string =
231 node.visibility().map(|v| format!("{} ", v.syntax().text())).unwrap_or_default();
232 string.push_str(label);
233 string.push_str(node.name()?.text().as_str());
234 Some(string)
235 }
236
237 visitor()
238 .visit(crate::completion::function_label)
239 .visit(|node: &ast::StructDef| visit_node(node, "struct "))
240 .visit(|node: &ast::EnumDef| visit_node(node, "enum "))
241 .visit(|node: &ast::TraitDef| visit_node(node, "trait "))
242 .visit(|node: &ast::Module| visit_node(node, "mod "))
243 .visit(|node: &ast::TypeAliasDef| visit_node(node, "type "))
244 .visit(|node: &ast::ConstDef| visit_ascribed_node(node, "const "))
245 .visit(|node: &ast::StaticDef| visit_ascribed_node(node, "static "))
246 .visit(|node: &ast::NamedFieldDef| visit_ascribed_node(node, ""))
247 .visit(|node: &ast::EnumVariant| Some(node.name()?.text().to_string()))
248 .accept(&node)?
249 }
250}
251
252#[cfg(test)] 148#[cfg(test)]
253mod tests { 149mod tests {
254 use ra_syntax::TextRange; 150 use ra_syntax::TextRange;
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 9063f78a9..d25795adc 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -13,7 +13,6 @@
13mod db; 13mod db;
14pub mod mock_analysis; 14pub mod mock_analysis;
15mod symbol_index; 15mod symbol_index;
16mod navigation_target;
17mod change; 16mod change;
18 17
19mod status; 18mod status;
@@ -34,9 +33,9 @@ mod folding_ranges;
34mod line_index; 33mod line_index;
35mod line_index_utils; 34mod line_index_utils;
36mod join_lines; 35mod join_lines;
37mod structure;
38mod typing; 36mod typing;
39mod matching_brace; 37mod matching_brace;
38mod display;
40 39
41#[cfg(test)] 40#[cfg(test)]
42mod marks; 41mod marks;
@@ -62,7 +61,6 @@ pub use crate::{
62 change::{AnalysisChange, LibraryData}, 61 change::{AnalysisChange, LibraryData},
63 completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, 62 completion::{CompletionItem, CompletionItemKind, InsertTextFormat},
64 runnables::{Runnable, RunnableKind}, 63 runnables::{Runnable, RunnableKind},
65 navigation_target::NavigationTarget,
66 references::ReferenceSearchResult, 64 references::ReferenceSearchResult,
67 assists::{Assist, AssistId}, 65 assists::{Assist, AssistId},
68 hover::{HoverResult}, 66 hover::{HoverResult},
@@ -70,8 +68,8 @@ pub use crate::{
70 line_index_utils::translate_offset_with_edit, 68 line_index_utils::translate_offset_with_edit,
71 folding_ranges::{Fold, FoldKind}, 69 folding_ranges::{Fold, FoldKind},
72 syntax_highlighting::HighlightedRange, 70 syntax_highlighting::HighlightedRange,
73 structure::{StructureNode, file_structure},
74 diagnostics::Severity, 71 diagnostics::Severity,
72 display::{FunctionSignature, NavigationTarget, StructureNode, file_structure},
75}; 73};
76 74
77pub use ra_db::{ 75pub use ra_db::{
@@ -243,9 +241,7 @@ impl<T> RangeInfo<T> {
243 241
244#[derive(Debug)] 242#[derive(Debug)]
245pub struct CallInfo { 243pub struct CallInfo {
246 pub label: String, 244 pub signature: FunctionSignature,
247 pub doc: Option<Documentation>,
248 pub parameters: Vec<String>,
249 pub active_parameter: Option<usize>, 245 pub active_parameter: Option<usize>,
250} 246}
251 247
@@ -387,7 +383,7 @@ impl Analysis {
387 /// file outline. 383 /// file outline.
388 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { 384 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {
389 let file = self.db.parse(file_id); 385 let file = self.db.parse(file_id);
390 structure::file_structure(&file) 386 file_structure(&file)
391 } 387 }
392 388
393 /// Returns the set of folding ranges. 389 /// Returns the set of folding ranges.
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
index 0eadc4e71..914d3fc71 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -275,7 +275,7 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> {
275mod tests { 275mod tests {
276 use ra_syntax::SmolStr; 276 use ra_syntax::SmolStr;
277 use crate::{ 277 use crate::{
278 navigation_target::NavigationTarget, 278 display::NavigationTarget,
279 mock_analysis::single_file, 279 mock_analysis::single_file,
280 Query, 280 Query,
281}; 281};
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index 74e91c236..4d6ede316 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -174,6 +174,28 @@ impl Conv for ra_ide_api::Documentation {
174 } 174 }
175} 175}
176 176
177impl Conv for ra_ide_api::FunctionSignature {
178 type Output = lsp_types::SignatureInformation;
179 fn conv(self) -> Self::Output {
180 use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation};
181
182 let label = self.to_string();
183
184 let documentation = self.doc.map(|it| it.conv());
185
186 let parameters: Vec<ParameterInformation> = self
187 .parameters
188 .into_iter()
189 .map(|param| ParameterInformation {
190 label: ParameterLabel::Simple(param),
191 documentation: None,
192 })
193 .collect();
194
195 SignatureInformation { label, documentation, parameters: Some(parameters) }
196 }
197}
198
177impl ConvWith for TextEdit { 199impl ConvWith for TextEdit {
178 type Ctx = LineIndex; 200 type Ctx = LineIndex;
179 type Output = Vec<lsp_types::TextEdit>; 201 type Output = Vec<lsp_types::TextEdit>;
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 89e96a33a..b96deb061 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -3,8 +3,8 @@ use lsp_types::{
3 CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, CodeAction, 3 CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, CodeAction,
4 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, 4 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange,
5 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, 5 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent,
6 MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, 6 MarkupKind, Position, PrepareRenameResponse, Range,
7 RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, 7 RenameParams,SymbolInformation, TextDocumentIdentifier, TextEdit,
8 WorkspaceEdit, 8 WorkspaceEdit,
9}; 9};
10use ra_ide_api::{ 10use ra_ide_api::{
@@ -403,26 +403,13 @@ pub fn handle_signature_help(
403) -> Result<Option<req::SignatureHelp>> { 403) -> Result<Option<req::SignatureHelp>> {
404 let position = params.try_conv_with(&world)?; 404 let position = params.try_conv_with(&world)?;
405 if let Some(call_info) = world.analysis().call_info(position)? { 405 if let Some(call_info) = world.analysis().call_info(position)? {
406 let parameters: Vec<ParameterInformation> = call_info 406 let active_parameter = call_info.active_parameter.map(|it| it as i64);
407 .parameters 407 let sig_info = call_info.signature.conv();
408 .into_iter()
409 .map(|param| ParameterInformation {
410 label: ParameterLabel::Simple(param.clone()),
411 documentation: None,
412 })
413 .collect();
414 408
415 let documentation = call_info.doc.map(|it| it.conv());
416
417 let sig_info = SignatureInformation {
418 label: call_info.label,
419 documentation,
420 parameters: Some(parameters),
421 };
422 Ok(Some(req::SignatureHelp { 409 Ok(Some(req::SignatureHelp {
423 signatures: vec![sig_info], 410 signatures: vec![sig_info],
424 active_signature: Some(0), 411 active_signature: Some(0),
425 active_parameter: call_info.active_parameter.map(|it| it as i64), 412 active_parameter,
426 })) 413 }))
427 } else { 414 } else {
428 Ok(None) 415 Ok(None)
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 547af1b27..b8350266f 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -7,6 +7,7 @@ use super::SyntaxInfo;
7 7
8/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 8/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
9#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 9#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[repr(u16)]
10pub enum SyntaxKind { 11pub enum SyntaxKind {
11 // Technical SyntaxKinds: they appear temporally during parsing, 12 // Technical SyntaxKinds: they appear temporally during parsing,
12 // but never end up in the final tree 13 // but never end up in the final tree
@@ -230,9 +231,25 @@ pub enum SyntaxKind {
230 ARG_LIST, 231 ARG_LIST,
231 TYPE_BOUND, 232 TYPE_BOUND,
232 TYPE_BOUND_LIST, 233 TYPE_BOUND_LIST,
234 // Technical kind so that we can cast from u16 safely
235 #[doc(hidden)]
236 __LAST,
233} 237}
234use self::SyntaxKind::*; 238use self::SyntaxKind::*;
235 239
240impl From<u16> for SyntaxKind {
241 fn from(d: u16) -> SyntaxKind {
242 assert!(d <= (__LAST as u16));
243 unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
244 }
245}
246
247impl From<SyntaxKind> for u16 {
248 fn from(k: SyntaxKind) -> u16 {
249 k as u16
250 }
251}
252
236impl SyntaxKind { 253impl SyntaxKind {
237 pub fn is_keyword(self) -> bool { 254 pub fn is_keyword(self) -> bool {
238 match self { 255 match self {
@@ -573,6 +590,7 @@ impl SyntaxKind {
573 TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" }, 590 TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" },
574 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, 591 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
575 EOF => &SyntaxInfo { name: "EOF" }, 592 EOF => &SyntaxInfo { name: "EOF" },
593 __LAST => &SyntaxInfo { name: "__LAST" },
576 } 594 }
577 } 595 }
578 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { 596 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs.tera b/crates/ra_parser/src/syntax_kind/generated.rs.tera
index f241a21a0..5b9ff21af 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs.tera
+++ b/crates/ra_parser/src/syntax_kind/generated.rs.tera
@@ -9,6 +9,7 @@ use super::SyntaxInfo;
9 9
10/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 10/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
11#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 11#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[repr(u16)]
12pub enum SyntaxKind { 13pub enum SyntaxKind {
13 // Technical SyntaxKinds: they appear temporally during parsing, 14 // Technical SyntaxKinds: they appear temporally during parsing,
14 // but never end up in the final tree 15 // but never end up in the final tree
@@ -26,9 +27,25 @@ pub enum SyntaxKind {
26{% for t in concat(a=literals, b=tokens, c=nodes) %} 27{% for t in concat(a=literals, b=tokens, c=nodes) %}
27 {{t}}, 28 {{t}},
28{%- endfor %} 29{%- endfor %}
30 // Technical kind so that we can cast from u16 safely
31 #[doc(hidden)]
32 __LAST,
29} 33}
30use self::SyntaxKind::*; 34use self::SyntaxKind::*;
31 35
36impl From<u16> for SyntaxKind {
37 fn from(d: u16) -> SyntaxKind {
38 assert!(d <= (__LAST as u16));
39 unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
40 }
41}
42
43impl From<SyntaxKind> for u16 {
44 fn from(k: SyntaxKind) -> u16 {
45 k as u16
46 }
47}
48
32impl SyntaxKind { 49impl SyntaxKind {
33 pub fn is_keyword(self) -> bool { 50 pub fn is_keyword(self) -> bool {
34 match self { 51 match self {
@@ -72,6 +89,7 @@ impl SyntaxKind {
72{%- endfor %} 89{%- endfor %}
73 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, 90 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
74 EOF => &SyntaxInfo { name: "EOF" }, 91 EOF => &SyntaxInfo { name: "EOF" },
92 __LAST => &SyntaxInfo { name: "__LAST" },
75 } 93 }
76 } 94 }
77 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { 95 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index 1a763fb47..1f3981f5a 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -13,7 +13,7 @@ unicode-xid = "0.1.0"
13itertools = "0.8.0" 13itertools = "0.8.0"
14drop_bomb = "0.1.4" 14drop_bomb = "0.1.4"
15parking_lot = "0.7.0" 15parking_lot = "0.7.0"
16rowan = "0.4.0" 16rowan = "0.5.0"
17 17
18# ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here 18# ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here
19# to reduce number of compilations 19# to reduce number of compilations
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index c2ab19d97..f7e33366e 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -9,7 +9,7 @@ mod expr_extensions;
9use std::marker::PhantomData; 9use std::marker::PhantomData;
10 10
11use crate::{ 11use crate::{
12 syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, RaTypes, SyntaxToken}, 12 syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, SyntaxToken},
13 SmolStr, 13 SmolStr,
14}; 14};
15 15
@@ -26,7 +26,7 @@ pub use self::{
26/// the same representation: a pointer to the tree root and a pointer to the 26/// the same representation: a pointer to the tree root and a pointer to the
27/// node itself. 27/// node itself.
28pub trait AstNode: 28pub trait AstNode:
29 rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> + ToOwned<Owned = TreeArc<Self>> 29 rowan::TransparentNewType<Repr = rowan::SyntaxNode> + ToOwned<Owned = TreeArc<Self>>
30{ 30{
31 fn cast(syntax: &SyntaxNode) -> Option<&Self> 31 fn cast(syntax: &SyntaxNode) -> Option<&Self>
32 where 32 where
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 0376c91c8..774d9bcc8 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -13,7 +13,7 @@ use rowan::TransparentNewType;
13 13
14use crate::{ 14use crate::{
15 SyntaxNode, SyntaxKind::*, 15 SyntaxNode, SyntaxKind::*,
16 syntax_node::{RaTypes, TreeArc}, 16 syntax_node::{TreeArc},
17 ast::{self, AstNode}, 17 ast::{self, AstNode},
18}; 18};
19 19
@@ -24,7 +24,7 @@ pub struct Alias {
24 pub(crate) syntax: SyntaxNode, 24 pub(crate) syntax: SyntaxNode,
25} 25}
26unsafe impl TransparentNewType for Alias { 26unsafe impl TransparentNewType for Alias {
27 type Repr = rowan::SyntaxNode<RaTypes>; 27 type Repr = rowan::SyntaxNode;
28} 28}
29 29
30impl AstNode for Alias { 30impl AstNode for Alias {
@@ -53,7 +53,7 @@ pub struct ArgList {
53 pub(crate) syntax: SyntaxNode, 53 pub(crate) syntax: SyntaxNode,
54} 54}
55unsafe impl TransparentNewType for ArgList { 55unsafe impl TransparentNewType for ArgList {
56 type Repr = rowan::SyntaxNode<RaTypes>; 56 type Repr = rowan::SyntaxNode;
57} 57}
58 58
59impl AstNode for ArgList { 59impl AstNode for ArgList {
@@ -85,7 +85,7 @@ pub struct ArrayExpr {
85 pub(crate) syntax: SyntaxNode, 85 pub(crate) syntax: SyntaxNode,
86} 86}
87unsafe impl TransparentNewType for ArrayExpr { 87unsafe impl TransparentNewType for ArrayExpr {
88 type Repr = rowan::SyntaxNode<RaTypes>; 88 type Repr = rowan::SyntaxNode;
89} 89}
90 90
91impl AstNode for ArrayExpr { 91impl AstNode for ArrayExpr {
@@ -117,7 +117,7 @@ pub struct ArrayType {
117 pub(crate) syntax: SyntaxNode, 117 pub(crate) syntax: SyntaxNode,
118} 118}
119unsafe impl TransparentNewType for ArrayType { 119unsafe impl TransparentNewType for ArrayType {
120 type Repr = rowan::SyntaxNode<RaTypes>; 120 type Repr = rowan::SyntaxNode;
121} 121}
122 122
123impl AstNode for ArrayType { 123impl AstNode for ArrayType {
@@ -153,7 +153,7 @@ pub struct AssocTypeArg {
153 pub(crate) syntax: SyntaxNode, 153 pub(crate) syntax: SyntaxNode,
154} 154}
155unsafe impl TransparentNewType for AssocTypeArg { 155unsafe impl TransparentNewType for AssocTypeArg {
156 type Repr = rowan::SyntaxNode<RaTypes>; 156 type Repr = rowan::SyntaxNode;
157} 157}
158 158
159impl AstNode for AssocTypeArg { 159impl AstNode for AssocTypeArg {
@@ -189,7 +189,7 @@ pub struct Attr {
189 pub(crate) syntax: SyntaxNode, 189 pub(crate) syntax: SyntaxNode,
190} 190}
191unsafe impl TransparentNewType for Attr { 191unsafe impl TransparentNewType for Attr {
192 type Repr = rowan::SyntaxNode<RaTypes>; 192 type Repr = rowan::SyntaxNode;
193} 193}
194 194
195impl AstNode for Attr { 195impl AstNode for Attr {
@@ -221,7 +221,7 @@ pub struct BinExpr {
221 pub(crate) syntax: SyntaxNode, 221 pub(crate) syntax: SyntaxNode,
222} 222}
223unsafe impl TransparentNewType for BinExpr { 223unsafe impl TransparentNewType for BinExpr {
224 type Repr = rowan::SyntaxNode<RaTypes>; 224 type Repr = rowan::SyntaxNode;
225} 225}
226 226
227impl AstNode for BinExpr { 227impl AstNode for BinExpr {
@@ -249,7 +249,7 @@ pub struct BindPat {
249 pub(crate) syntax: SyntaxNode, 249 pub(crate) syntax: SyntaxNode,
250} 250}
251unsafe impl TransparentNewType for BindPat { 251unsafe impl TransparentNewType for BindPat {
252 type Repr = rowan::SyntaxNode<RaTypes>; 252 type Repr = rowan::SyntaxNode;
253} 253}
254 254
255impl AstNode for BindPat { 255impl AstNode for BindPat {
@@ -282,7 +282,7 @@ pub struct Block {
282 pub(crate) syntax: SyntaxNode, 282 pub(crate) syntax: SyntaxNode,
283} 283}
284unsafe impl TransparentNewType for Block { 284unsafe impl TransparentNewType for Block {
285 type Repr = rowan::SyntaxNode<RaTypes>; 285 type Repr = rowan::SyntaxNode;
286} 286}
287 287
288impl AstNode for Block { 288impl AstNode for Block {
@@ -319,7 +319,7 @@ pub struct BlockExpr {
319 pub(crate) syntax: SyntaxNode, 319 pub(crate) syntax: SyntaxNode,
320} 320}
321unsafe impl TransparentNewType for BlockExpr { 321unsafe impl TransparentNewType for BlockExpr {
322 type Repr = rowan::SyntaxNode<RaTypes>; 322 type Repr = rowan::SyntaxNode;
323} 323}
324 324
325impl AstNode for BlockExpr { 325impl AstNode for BlockExpr {
@@ -351,7 +351,7 @@ pub struct BreakExpr {
351 pub(crate) syntax: SyntaxNode, 351 pub(crate) syntax: SyntaxNode,
352} 352}
353unsafe impl TransparentNewType for BreakExpr { 353unsafe impl TransparentNewType for BreakExpr {
354 type Repr = rowan::SyntaxNode<RaTypes>; 354 type Repr = rowan::SyntaxNode;
355} 355}
356 356
357impl AstNode for BreakExpr { 357impl AstNode for BreakExpr {
@@ -383,7 +383,7 @@ pub struct CallExpr {
383 pub(crate) syntax: SyntaxNode, 383 pub(crate) syntax: SyntaxNode,
384} 384}
385unsafe impl TransparentNewType for CallExpr { 385unsafe impl TransparentNewType for CallExpr {
386 type Repr = rowan::SyntaxNode<RaTypes>; 386 type Repr = rowan::SyntaxNode;
387} 387}
388 388
389impl AstNode for CallExpr { 389impl AstNode for CallExpr {
@@ -416,7 +416,7 @@ pub struct CastExpr {
416 pub(crate) syntax: SyntaxNode, 416 pub(crate) syntax: SyntaxNode,
417} 417}
418unsafe impl TransparentNewType for CastExpr { 418unsafe impl TransparentNewType for CastExpr {
419 type Repr = rowan::SyntaxNode<RaTypes>; 419 type Repr = rowan::SyntaxNode;
420} 420}
421 421
422impl AstNode for CastExpr { 422impl AstNode for CastExpr {
@@ -452,7 +452,7 @@ pub struct Condition {
452 pub(crate) syntax: SyntaxNode, 452 pub(crate) syntax: SyntaxNode,
453} 453}
454unsafe impl TransparentNewType for Condition { 454unsafe impl TransparentNewType for Condition {
455 type Repr = rowan::SyntaxNode<RaTypes>; 455 type Repr = rowan::SyntaxNode;
456} 456}
457 457
458impl AstNode for Condition { 458impl AstNode for Condition {
@@ -488,7 +488,7 @@ pub struct ConstDef {
488 pub(crate) syntax: SyntaxNode, 488 pub(crate) syntax: SyntaxNode,
489} 489}
490unsafe impl TransparentNewType for ConstDef { 490unsafe impl TransparentNewType for ConstDef {
491 type Repr = rowan::SyntaxNode<RaTypes>; 491 type Repr = rowan::SyntaxNode;
492} 492}
493 493
494impl AstNode for ConstDef { 494impl AstNode for ConstDef {
@@ -526,7 +526,7 @@ pub struct ContinueExpr {
526 pub(crate) syntax: SyntaxNode, 526 pub(crate) syntax: SyntaxNode,
527} 527}
528unsafe impl TransparentNewType for ContinueExpr { 528unsafe impl TransparentNewType for ContinueExpr {
529 type Repr = rowan::SyntaxNode<RaTypes>; 529 type Repr = rowan::SyntaxNode;
530} 530}
531 531
532impl AstNode for ContinueExpr { 532impl AstNode for ContinueExpr {
@@ -554,7 +554,7 @@ pub struct DynTraitType {
554 pub(crate) syntax: SyntaxNode, 554 pub(crate) syntax: SyntaxNode,
555} 555}
556unsafe impl TransparentNewType for DynTraitType { 556unsafe impl TransparentNewType for DynTraitType {
557 type Repr = rowan::SyntaxNode<RaTypes>; 557 type Repr = rowan::SyntaxNode;
558} 558}
559 559
560impl AstNode for DynTraitType { 560impl AstNode for DynTraitType {
@@ -583,7 +583,7 @@ pub struct EnumDef {
583 pub(crate) syntax: SyntaxNode, 583 pub(crate) syntax: SyntaxNode,
584} 584}
585unsafe impl TransparentNewType for EnumDef { 585unsafe impl TransparentNewType for EnumDef {
586 type Repr = rowan::SyntaxNode<RaTypes>; 586 type Repr = rowan::SyntaxNode;
587} 587}
588 588
589impl AstNode for EnumDef { 589impl AstNode for EnumDef {
@@ -620,7 +620,7 @@ pub struct EnumVariant {
620 pub(crate) syntax: SyntaxNode, 620 pub(crate) syntax: SyntaxNode,
621} 621}
622unsafe impl TransparentNewType for EnumVariant { 622unsafe impl TransparentNewType for EnumVariant {
623 type Repr = rowan::SyntaxNode<RaTypes>; 623 type Repr = rowan::SyntaxNode;
624} 624}
625 625
626impl AstNode for EnumVariant { 626impl AstNode for EnumVariant {
@@ -655,7 +655,7 @@ pub struct EnumVariantList {
655 pub(crate) syntax: SyntaxNode, 655 pub(crate) syntax: SyntaxNode,
656} 656}
657unsafe impl TransparentNewType for EnumVariantList { 657unsafe impl TransparentNewType for EnumVariantList {
658 type Repr = rowan::SyntaxNode<RaTypes>; 658 type Repr = rowan::SyntaxNode;
659} 659}
660 660
661impl AstNode for EnumVariantList { 661impl AstNode for EnumVariantList {
@@ -687,7 +687,7 @@ pub struct Expr {
687 pub(crate) syntax: SyntaxNode, 687 pub(crate) syntax: SyntaxNode,
688} 688}
689unsafe impl TransparentNewType for Expr { 689unsafe impl TransparentNewType for Expr {
690 type Repr = rowan::SyntaxNode<RaTypes>; 690 type Repr = rowan::SyntaxNode;
691} 691}
692 692
693#[derive(Debug, Clone, Copy, PartialEq, Eq)] 693#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -950,7 +950,7 @@ pub struct ExprStmt {
950 pub(crate) syntax: SyntaxNode, 950 pub(crate) syntax: SyntaxNode,
951} 951}
952unsafe impl TransparentNewType for ExprStmt { 952unsafe impl TransparentNewType for ExprStmt {
953 type Repr = rowan::SyntaxNode<RaTypes>; 953 type Repr = rowan::SyntaxNode;
954} 954}
955 955
956impl AstNode for ExprStmt { 956impl AstNode for ExprStmt {
@@ -982,7 +982,7 @@ pub struct ExternCrateItem {
982 pub(crate) syntax: SyntaxNode, 982 pub(crate) syntax: SyntaxNode,
983} 983}
984unsafe impl TransparentNewType for ExternCrateItem { 984unsafe impl TransparentNewType for ExternCrateItem {
985 type Repr = rowan::SyntaxNode<RaTypes>; 985 type Repr = rowan::SyntaxNode;
986} 986}
987 987
988impl AstNode for ExternCrateItem { 988impl AstNode for ExternCrateItem {
@@ -1018,7 +1018,7 @@ pub struct FieldExpr {
1018 pub(crate) syntax: SyntaxNode, 1018 pub(crate) syntax: SyntaxNode,
1019} 1019}
1020unsafe impl TransparentNewType for FieldExpr { 1020unsafe impl TransparentNewType for FieldExpr {
1021 type Repr = rowan::SyntaxNode<RaTypes>; 1021 type Repr = rowan::SyntaxNode;
1022} 1022}
1023 1023
1024impl AstNode for FieldExpr { 1024impl AstNode for FieldExpr {
@@ -1054,7 +1054,7 @@ pub struct FieldPat {
1054 pub(crate) syntax: SyntaxNode, 1054 pub(crate) syntax: SyntaxNode,
1055} 1055}
1056unsafe impl TransparentNewType for FieldPat { 1056unsafe impl TransparentNewType for FieldPat {
1057 type Repr = rowan::SyntaxNode<RaTypes>; 1057 type Repr = rowan::SyntaxNode;
1058} 1058}
1059 1059
1060impl AstNode for FieldPat { 1060impl AstNode for FieldPat {
@@ -1087,7 +1087,7 @@ pub struct FieldPatList {
1087 pub(crate) syntax: SyntaxNode, 1087 pub(crate) syntax: SyntaxNode,
1088} 1088}
1089unsafe impl TransparentNewType for FieldPatList { 1089unsafe impl TransparentNewType for FieldPatList {
1090 type Repr = rowan::SyntaxNode<RaTypes>; 1090 type Repr = rowan::SyntaxNode;
1091} 1091}
1092 1092
1093impl AstNode for FieldPatList { 1093impl AstNode for FieldPatList {
@@ -1123,7 +1123,7 @@ pub struct FnDef {
1123 pub(crate) syntax: SyntaxNode, 1123 pub(crate) syntax: SyntaxNode,
1124} 1124}
1125unsafe impl TransparentNewType for FnDef { 1125unsafe impl TransparentNewType for FnDef {
1126 type Repr = rowan::SyntaxNode<RaTypes>; 1126 type Repr = rowan::SyntaxNode;
1127} 1127}
1128 1128
1129impl AstNode for FnDef { 1129impl AstNode for FnDef {
@@ -1168,7 +1168,7 @@ pub struct FnPointerType {
1168 pub(crate) syntax: SyntaxNode, 1168 pub(crate) syntax: SyntaxNode,
1169} 1169}
1170unsafe impl TransparentNewType for FnPointerType { 1170unsafe impl TransparentNewType for FnPointerType {
1171 type Repr = rowan::SyntaxNode<RaTypes>; 1171 type Repr = rowan::SyntaxNode;
1172} 1172}
1173 1173
1174impl AstNode for FnPointerType { 1174impl AstNode for FnPointerType {
@@ -1204,7 +1204,7 @@ pub struct ForExpr {
1204 pub(crate) syntax: SyntaxNode, 1204 pub(crate) syntax: SyntaxNode,
1205} 1205}
1206unsafe impl TransparentNewType for ForExpr { 1206unsafe impl TransparentNewType for ForExpr {
1207 type Repr = rowan::SyntaxNode<RaTypes>; 1207 type Repr = rowan::SyntaxNode;
1208} 1208}
1209 1209
1210impl AstNode for ForExpr { 1210impl AstNode for ForExpr {
@@ -1241,7 +1241,7 @@ pub struct ForType {
1241 pub(crate) syntax: SyntaxNode, 1241 pub(crate) syntax: SyntaxNode,
1242} 1242}
1243unsafe impl TransparentNewType for ForType { 1243unsafe impl TransparentNewType for ForType {
1244 type Repr = rowan::SyntaxNode<RaTypes>; 1244 type Repr = rowan::SyntaxNode;
1245} 1245}
1246 1246
1247impl AstNode for ForType { 1247impl AstNode for ForType {
@@ -1273,7 +1273,7 @@ pub struct IfExpr {
1273 pub(crate) syntax: SyntaxNode, 1273 pub(crate) syntax: SyntaxNode,
1274} 1274}
1275unsafe impl TransparentNewType for IfExpr { 1275unsafe impl TransparentNewType for IfExpr {
1276 type Repr = rowan::SyntaxNode<RaTypes>; 1276 type Repr = rowan::SyntaxNode;
1277} 1277}
1278 1278
1279impl AstNode for IfExpr { 1279impl AstNode for IfExpr {
@@ -1305,7 +1305,7 @@ pub struct ImplBlock {
1305 pub(crate) syntax: SyntaxNode, 1305 pub(crate) syntax: SyntaxNode,
1306} 1306}
1307unsafe impl TransparentNewType for ImplBlock { 1307unsafe impl TransparentNewType for ImplBlock {
1308 type Repr = rowan::SyntaxNode<RaTypes>; 1308 type Repr = rowan::SyntaxNode;
1309} 1309}
1310 1310
1311impl AstNode for ImplBlock { 1311impl AstNode for ImplBlock {
@@ -1338,7 +1338,7 @@ pub struct ImplItem {
1338 pub(crate) syntax: SyntaxNode, 1338 pub(crate) syntax: SyntaxNode,
1339} 1339}
1340unsafe impl TransparentNewType for ImplItem { 1340unsafe impl TransparentNewType for ImplItem {
1341 type Repr = rowan::SyntaxNode<RaTypes>; 1341 type Repr = rowan::SyntaxNode;
1342} 1342}
1343 1343
1344#[derive(Debug, Clone, Copy, PartialEq, Eq)] 1344#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -1401,7 +1401,7 @@ pub struct ImplTraitType {
1401 pub(crate) syntax: SyntaxNode, 1401 pub(crate) syntax: SyntaxNode,
1402} 1402}
1403unsafe impl TransparentNewType for ImplTraitType { 1403unsafe impl TransparentNewType for ImplTraitType {
1404 type Repr = rowan::SyntaxNode<RaTypes>; 1404 type Repr = rowan::SyntaxNode;
1405} 1405}
1406 1406
1407impl AstNode for ImplTraitType { 1407impl AstNode for ImplTraitType {
@@ -1430,7 +1430,7 @@ pub struct IndexExpr {
1430 pub(crate) syntax: SyntaxNode, 1430 pub(crate) syntax: SyntaxNode,
1431} 1431}
1432unsafe impl TransparentNewType for IndexExpr { 1432unsafe impl TransparentNewType for IndexExpr {
1433 type Repr = rowan::SyntaxNode<RaTypes>; 1433 type Repr = rowan::SyntaxNode;
1434} 1434}
1435 1435
1436impl AstNode for IndexExpr { 1436impl AstNode for IndexExpr {
@@ -1458,7 +1458,7 @@ pub struct ItemList {
1458 pub(crate) syntax: SyntaxNode, 1458 pub(crate) syntax: SyntaxNode,
1459} 1459}
1460unsafe impl TransparentNewType for ItemList { 1460unsafe impl TransparentNewType for ItemList {
1461 type Repr = rowan::SyntaxNode<RaTypes>; 1461 type Repr = rowan::SyntaxNode;
1462} 1462}
1463 1463
1464impl AstNode for ItemList { 1464impl AstNode for ItemList {
@@ -1492,7 +1492,7 @@ pub struct Label {
1492 pub(crate) syntax: SyntaxNode, 1492 pub(crate) syntax: SyntaxNode,
1493} 1493}
1494unsafe impl TransparentNewType for Label { 1494unsafe impl TransparentNewType for Label {
1495 type Repr = rowan::SyntaxNode<RaTypes>; 1495 type Repr = rowan::SyntaxNode;
1496} 1496}
1497 1497
1498impl AstNode for Label { 1498impl AstNode for Label {
@@ -1520,7 +1520,7 @@ pub struct LambdaExpr {
1520 pub(crate) syntax: SyntaxNode, 1520 pub(crate) syntax: SyntaxNode,
1521} 1521}
1522unsafe impl TransparentNewType for LambdaExpr { 1522unsafe impl TransparentNewType for LambdaExpr {
1523 type Repr = rowan::SyntaxNode<RaTypes>; 1523 type Repr = rowan::SyntaxNode;
1524} 1524}
1525 1525
1526impl AstNode for LambdaExpr { 1526impl AstNode for LambdaExpr {
@@ -1556,7 +1556,7 @@ pub struct LetStmt {
1556 pub(crate) syntax: SyntaxNode, 1556 pub(crate) syntax: SyntaxNode,
1557} 1557}
1558unsafe impl TransparentNewType for LetStmt { 1558unsafe impl TransparentNewType for LetStmt {
1559 type Repr = rowan::SyntaxNode<RaTypes>; 1559 type Repr = rowan::SyntaxNode;
1560} 1560}
1561 1561
1562impl AstNode for LetStmt { 1562impl AstNode for LetStmt {
@@ -1593,7 +1593,7 @@ pub struct LifetimeArg {
1593 pub(crate) syntax: SyntaxNode, 1593 pub(crate) syntax: SyntaxNode,
1594} 1594}
1595unsafe impl TransparentNewType for LifetimeArg { 1595unsafe impl TransparentNewType for LifetimeArg {
1596 type Repr = rowan::SyntaxNode<RaTypes>; 1596 type Repr = rowan::SyntaxNode;
1597} 1597}
1598 1598
1599impl AstNode for LifetimeArg { 1599impl AstNode for LifetimeArg {
@@ -1621,7 +1621,7 @@ pub struct LifetimeParam {
1621 pub(crate) syntax: SyntaxNode, 1621 pub(crate) syntax: SyntaxNode,
1622} 1622}
1623unsafe impl TransparentNewType for LifetimeParam { 1623unsafe impl TransparentNewType for LifetimeParam {
1624 type Repr = rowan::SyntaxNode<RaTypes>; 1624 type Repr = rowan::SyntaxNode;
1625} 1625}
1626 1626
1627impl AstNode for LifetimeParam { 1627impl AstNode for LifetimeParam {
@@ -1650,7 +1650,7 @@ pub struct Literal {
1650 pub(crate) syntax: SyntaxNode, 1650 pub(crate) syntax: SyntaxNode,
1651} 1651}
1652unsafe impl TransparentNewType for Literal { 1652unsafe impl TransparentNewType for Literal {
1653 type Repr = rowan::SyntaxNode<RaTypes>; 1653 type Repr = rowan::SyntaxNode;
1654} 1654}
1655 1655
1656impl AstNode for Literal { 1656impl AstNode for Literal {
@@ -1678,7 +1678,7 @@ pub struct LiteralPat {
1678 pub(crate) syntax: SyntaxNode, 1678 pub(crate) syntax: SyntaxNode,
1679} 1679}
1680unsafe impl TransparentNewType for LiteralPat { 1680unsafe impl TransparentNewType for LiteralPat {
1681 type Repr = rowan::SyntaxNode<RaTypes>; 1681 type Repr = rowan::SyntaxNode;
1682} 1682}
1683 1683
1684impl AstNode for LiteralPat { 1684impl AstNode for LiteralPat {
@@ -1710,7 +1710,7 @@ pub struct LoopExpr {
1710 pub(crate) syntax: SyntaxNode, 1710 pub(crate) syntax: SyntaxNode,
1711} 1711}
1712unsafe impl TransparentNewType for LoopExpr { 1712unsafe impl TransparentNewType for LoopExpr {
1713 type Repr = rowan::SyntaxNode<RaTypes>; 1713 type Repr = rowan::SyntaxNode;
1714} 1714}
1715 1715
1716impl AstNode for LoopExpr { 1716impl AstNode for LoopExpr {
@@ -1739,7 +1739,7 @@ pub struct MacroCall {
1739 pub(crate) syntax: SyntaxNode, 1739 pub(crate) syntax: SyntaxNode,
1740} 1740}
1741unsafe impl TransparentNewType for MacroCall { 1741unsafe impl TransparentNewType for MacroCall {
1742 type Repr = rowan::SyntaxNode<RaTypes>; 1742 type Repr = rowan::SyntaxNode;
1743} 1743}
1744 1744
1745impl AstNode for MacroCall { 1745impl AstNode for MacroCall {
@@ -1777,7 +1777,7 @@ pub struct MatchArm {
1777 pub(crate) syntax: SyntaxNode, 1777 pub(crate) syntax: SyntaxNode,
1778} 1778}
1779unsafe impl TransparentNewType for MatchArm { 1779unsafe impl TransparentNewType for MatchArm {
1780 type Repr = rowan::SyntaxNode<RaTypes>; 1780 type Repr = rowan::SyntaxNode;
1781} 1781}
1782 1782
1783impl AstNode for MatchArm { 1783impl AstNode for MatchArm {
@@ -1818,7 +1818,7 @@ pub struct MatchArmList {
1818 pub(crate) syntax: SyntaxNode, 1818 pub(crate) syntax: SyntaxNode,
1819} 1819}
1820unsafe impl TransparentNewType for MatchArmList { 1820unsafe impl TransparentNewType for MatchArmList {
1821 type Repr = rowan::SyntaxNode<RaTypes>; 1821 type Repr = rowan::SyntaxNode;
1822} 1822}
1823 1823
1824impl AstNode for MatchArmList { 1824impl AstNode for MatchArmList {
@@ -1851,7 +1851,7 @@ pub struct MatchExpr {
1851 pub(crate) syntax: SyntaxNode, 1851 pub(crate) syntax: SyntaxNode,
1852} 1852}
1853unsafe impl TransparentNewType for MatchExpr { 1853unsafe impl TransparentNewType for MatchExpr {
1854 type Repr = rowan::SyntaxNode<RaTypes>; 1854 type Repr = rowan::SyntaxNode;
1855} 1855}
1856 1856
1857impl AstNode for MatchExpr { 1857impl AstNode for MatchExpr {
@@ -1887,7 +1887,7 @@ pub struct MatchGuard {
1887 pub(crate) syntax: SyntaxNode, 1887 pub(crate) syntax: SyntaxNode,
1888} 1888}
1889unsafe impl TransparentNewType for MatchGuard { 1889unsafe impl TransparentNewType for MatchGuard {
1890 type Repr = rowan::SyntaxNode<RaTypes>; 1890 type Repr = rowan::SyntaxNode;
1891} 1891}
1892 1892
1893impl AstNode for MatchGuard { 1893impl AstNode for MatchGuard {
@@ -1919,7 +1919,7 @@ pub struct MethodCallExpr {
1919 pub(crate) syntax: SyntaxNode, 1919 pub(crate) syntax: SyntaxNode,
1920} 1920}
1921unsafe impl TransparentNewType for MethodCallExpr { 1921unsafe impl TransparentNewType for MethodCallExpr {
1922 type Repr = rowan::SyntaxNode<RaTypes>; 1922 type Repr = rowan::SyntaxNode;
1923} 1923}
1924 1924
1925impl AstNode for MethodCallExpr { 1925impl AstNode for MethodCallExpr {
@@ -1960,7 +1960,7 @@ pub struct Module {
1960 pub(crate) syntax: SyntaxNode, 1960 pub(crate) syntax: SyntaxNode,
1961} 1961}
1962unsafe impl TransparentNewType for Module { 1962unsafe impl TransparentNewType for Module {
1963 type Repr = rowan::SyntaxNode<RaTypes>; 1963 type Repr = rowan::SyntaxNode;
1964} 1964}
1965 1965
1966impl AstNode for Module { 1966impl AstNode for Module {
@@ -1996,7 +1996,7 @@ pub struct ModuleItem {
1996 pub(crate) syntax: SyntaxNode, 1996 pub(crate) syntax: SyntaxNode,
1997} 1997}
1998unsafe impl TransparentNewType for ModuleItem { 1998unsafe impl TransparentNewType for ModuleItem {
1999 type Repr = rowan::SyntaxNode<RaTypes>; 1999 type Repr = rowan::SyntaxNode;
2000} 2000}
2001 2001
2002#[derive(Debug, Clone, Copy, PartialEq, Eq)] 2002#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -2123,7 +2123,7 @@ pub struct Name {
2123 pub(crate) syntax: SyntaxNode, 2123 pub(crate) syntax: SyntaxNode,
2124} 2124}
2125unsafe impl TransparentNewType for Name { 2125unsafe impl TransparentNewType for Name {
2126 type Repr = rowan::SyntaxNode<RaTypes>; 2126 type Repr = rowan::SyntaxNode;
2127} 2127}
2128 2128
2129impl AstNode for Name { 2129impl AstNode for Name {
@@ -2151,7 +2151,7 @@ pub struct NameRef {
2151 pub(crate) syntax: SyntaxNode, 2151 pub(crate) syntax: SyntaxNode,
2152} 2152}
2153unsafe impl TransparentNewType for NameRef { 2153unsafe impl TransparentNewType for NameRef {
2154 type Repr = rowan::SyntaxNode<RaTypes>; 2154 type Repr = rowan::SyntaxNode;
2155} 2155}
2156 2156
2157impl AstNode for NameRef { 2157impl AstNode for NameRef {
@@ -2179,7 +2179,7 @@ pub struct NamedField {
2179 pub(crate) syntax: SyntaxNode, 2179 pub(crate) syntax: SyntaxNode,
2180} 2180}
2181unsafe impl TransparentNewType for NamedField { 2181unsafe impl TransparentNewType for NamedField {
2182 type Repr = rowan::SyntaxNode<RaTypes>; 2182 type Repr = rowan::SyntaxNode;
2183} 2183}
2184 2184
2185impl AstNode for NamedField { 2185impl AstNode for NamedField {
@@ -2215,7 +2215,7 @@ pub struct NamedFieldDef {
2215 pub(crate) syntax: SyntaxNode, 2215 pub(crate) syntax: SyntaxNode,
2216} 2216}
2217unsafe impl TransparentNewType for NamedFieldDef { 2217unsafe impl TransparentNewType for NamedFieldDef {
2218 type Repr = rowan::SyntaxNode<RaTypes>; 2218 type Repr = rowan::SyntaxNode;
2219} 2219}
2220 2220
2221impl AstNode for NamedFieldDef { 2221impl AstNode for NamedFieldDef {
@@ -2248,7 +2248,7 @@ pub struct NamedFieldDefList {
2248 pub(crate) syntax: SyntaxNode, 2248 pub(crate) syntax: SyntaxNode,
2249} 2249}
2250unsafe impl TransparentNewType for NamedFieldDefList { 2250unsafe impl TransparentNewType for NamedFieldDefList {
2251 type Repr = rowan::SyntaxNode<RaTypes>; 2251 type Repr = rowan::SyntaxNode;
2252} 2252}
2253 2253
2254impl AstNode for NamedFieldDefList { 2254impl AstNode for NamedFieldDefList {
@@ -2280,7 +2280,7 @@ pub struct NamedFieldList {
2280 pub(crate) syntax: SyntaxNode, 2280 pub(crate) syntax: SyntaxNode,
2281} 2281}
2282unsafe impl TransparentNewType for NamedFieldList { 2282unsafe impl TransparentNewType for NamedFieldList {
2283 type Repr = rowan::SyntaxNode<RaTypes>; 2283 type Repr = rowan::SyntaxNode;
2284} 2284}
2285 2285
2286impl AstNode for NamedFieldList { 2286impl AstNode for NamedFieldList {
@@ -2312,7 +2312,7 @@ pub struct NeverType {
2312 pub(crate) syntax: SyntaxNode, 2312 pub(crate) syntax: SyntaxNode,
2313} 2313}
2314unsafe impl TransparentNewType for NeverType { 2314unsafe impl TransparentNewType for NeverType {
2315 type Repr = rowan::SyntaxNode<RaTypes>; 2315 type Repr = rowan::SyntaxNode;
2316} 2316}
2317 2317
2318impl AstNode for NeverType { 2318impl AstNode for NeverType {
@@ -2340,7 +2340,7 @@ pub struct NominalDef {
2340 pub(crate) syntax: SyntaxNode, 2340 pub(crate) syntax: SyntaxNode,
2341} 2341}
2342unsafe impl TransparentNewType for NominalDef { 2342unsafe impl TransparentNewType for NominalDef {
2343 type Repr = rowan::SyntaxNode<RaTypes>; 2343 type Repr = rowan::SyntaxNode;
2344} 2344}
2345 2345
2346#[derive(Debug, Clone, Copy, PartialEq, Eq)] 2346#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -2398,7 +2398,7 @@ pub struct Param {
2398 pub(crate) syntax: SyntaxNode, 2398 pub(crate) syntax: SyntaxNode,
2399} 2399}
2400unsafe impl TransparentNewType for Param { 2400unsafe impl TransparentNewType for Param {
2401 type Repr = rowan::SyntaxNode<RaTypes>; 2401 type Repr = rowan::SyntaxNode;
2402} 2402}
2403 2403
2404impl AstNode for Param { 2404impl AstNode for Param {
@@ -2431,7 +2431,7 @@ pub struct ParamList {
2431 pub(crate) syntax: SyntaxNode, 2431 pub(crate) syntax: SyntaxNode,
2432} 2432}
2433unsafe impl TransparentNewType for ParamList { 2433unsafe impl TransparentNewType for ParamList {
2434 type Repr = rowan::SyntaxNode<RaTypes>; 2434 type Repr = rowan::SyntaxNode;
2435} 2435}
2436 2436
2437impl AstNode for ParamList { 2437impl AstNode for ParamList {
@@ -2467,7 +2467,7 @@ pub struct ParenExpr {
2467 pub(crate) syntax: SyntaxNode, 2467 pub(crate) syntax: SyntaxNode,
2468} 2468}
2469unsafe impl TransparentNewType for ParenExpr { 2469unsafe impl TransparentNewType for ParenExpr {
2470 type Repr = rowan::SyntaxNode<RaTypes>; 2470 type Repr = rowan::SyntaxNode;
2471} 2471}
2472 2472
2473impl AstNode for ParenExpr { 2473impl AstNode for ParenExpr {
@@ -2499,7 +2499,7 @@ pub struct ParenType {
2499 pub(crate) syntax: SyntaxNode, 2499 pub(crate) syntax: SyntaxNode,
2500} 2500}
2501unsafe impl TransparentNewType for ParenType { 2501unsafe impl TransparentNewType for ParenType {
2502 type Repr = rowan::SyntaxNode<RaTypes>; 2502 type Repr = rowan::SyntaxNode;
2503} 2503}
2504 2504
2505impl AstNode for ParenType { 2505impl AstNode for ParenType {
@@ -2531,7 +2531,7 @@ pub struct Pat {
2531 pub(crate) syntax: SyntaxNode, 2531 pub(crate) syntax: SyntaxNode,
2532} 2532}
2533unsafe impl TransparentNewType for Pat { 2533unsafe impl TransparentNewType for Pat {
2534 type Repr = rowan::SyntaxNode<RaTypes>; 2534 type Repr = rowan::SyntaxNode;
2535} 2535}
2536 2536
2537#[derive(Debug, Clone, Copy, PartialEq, Eq)] 2537#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -2650,7 +2650,7 @@ pub struct Path {
2650 pub(crate) syntax: SyntaxNode, 2650 pub(crate) syntax: SyntaxNode,
2651} 2651}
2652unsafe impl TransparentNewType for Path { 2652unsafe impl TransparentNewType for Path {
2653 type Repr = rowan::SyntaxNode<RaTypes>; 2653 type Repr = rowan::SyntaxNode;
2654} 2654}
2655 2655
2656impl AstNode for Path { 2656impl AstNode for Path {
@@ -2686,7 +2686,7 @@ pub struct PathExpr {
2686 pub(crate) syntax: SyntaxNode, 2686 pub(crate) syntax: SyntaxNode,
2687} 2687}
2688unsafe impl TransparentNewType for PathExpr { 2688unsafe impl TransparentNewType for PathExpr {
2689 type Repr = rowan::SyntaxNode<RaTypes>; 2689 type Repr = rowan::SyntaxNode;
2690} 2690}
2691 2691
2692impl AstNode for PathExpr { 2692impl AstNode for PathExpr {
@@ -2718,7 +2718,7 @@ pub struct PathPat {
2718 pub(crate) syntax: SyntaxNode, 2718 pub(crate) syntax: SyntaxNode,
2719} 2719}
2720unsafe impl TransparentNewType for PathPat { 2720unsafe impl TransparentNewType for PathPat {
2721 type Repr = rowan::SyntaxNode<RaTypes>; 2721 type Repr = rowan::SyntaxNode;
2722} 2722}
2723 2723
2724impl AstNode for PathPat { 2724impl AstNode for PathPat {
@@ -2750,7 +2750,7 @@ pub struct PathSegment {
2750 pub(crate) syntax: SyntaxNode, 2750 pub(crate) syntax: SyntaxNode,
2751} 2751}
2752unsafe impl TransparentNewType for PathSegment { 2752unsafe impl TransparentNewType for PathSegment {
2753 type Repr = rowan::SyntaxNode<RaTypes>; 2753 type Repr = rowan::SyntaxNode;
2754} 2754}
2755 2755
2756impl AstNode for PathSegment { 2756impl AstNode for PathSegment {
@@ -2786,7 +2786,7 @@ pub struct PathType {
2786 pub(crate) syntax: SyntaxNode, 2786 pub(crate) syntax: SyntaxNode,
2787} 2787}
2788unsafe impl TransparentNewType for PathType { 2788unsafe impl TransparentNewType for PathType {
2789 type Repr = rowan::SyntaxNode<RaTypes>; 2789 type Repr = rowan::SyntaxNode;
2790} 2790}
2791 2791
2792impl AstNode for PathType { 2792impl AstNode for PathType {
@@ -2818,7 +2818,7 @@ pub struct PlaceholderPat {
2818 pub(crate) syntax: SyntaxNode, 2818 pub(crate) syntax: SyntaxNode,
2819} 2819}
2820unsafe impl TransparentNewType for PlaceholderPat { 2820unsafe impl TransparentNewType for PlaceholderPat {
2821 type Repr = rowan::SyntaxNode<RaTypes>; 2821 type Repr = rowan::SyntaxNode;
2822} 2822}
2823 2823
2824impl AstNode for PlaceholderPat { 2824impl AstNode for PlaceholderPat {
@@ -2846,7 +2846,7 @@ pub struct PlaceholderType {
2846 pub(crate) syntax: SyntaxNode, 2846 pub(crate) syntax: SyntaxNode,
2847} 2847}
2848unsafe impl TransparentNewType for PlaceholderType { 2848unsafe impl TransparentNewType for PlaceholderType {
2849 type Repr = rowan::SyntaxNode<RaTypes>; 2849 type Repr = rowan::SyntaxNode;
2850} 2850}
2851 2851
2852impl AstNode for PlaceholderType { 2852impl AstNode for PlaceholderType {
@@ -2874,7 +2874,7 @@ pub struct PointerType {
2874 pub(crate) syntax: SyntaxNode, 2874 pub(crate) syntax: SyntaxNode,
2875} 2875}
2876unsafe impl TransparentNewType for PointerType { 2876unsafe impl TransparentNewType for PointerType {
2877 type Repr = rowan::SyntaxNode<RaTypes>; 2877 type Repr = rowan::SyntaxNode;
2878} 2878}
2879 2879
2880impl AstNode for PointerType { 2880impl AstNode for PointerType {
@@ -2906,7 +2906,7 @@ pub struct PosFieldDef {
2906 pub(crate) syntax: SyntaxNode, 2906 pub(crate) syntax: SyntaxNode,
2907} 2907}
2908unsafe impl TransparentNewType for PosFieldDef { 2908unsafe impl TransparentNewType for PosFieldDef {
2909 type Repr = rowan::SyntaxNode<RaTypes>; 2909 type Repr = rowan::SyntaxNode;
2910} 2910}
2911 2911
2912impl AstNode for PosFieldDef { 2912impl AstNode for PosFieldDef {
@@ -2940,7 +2940,7 @@ pub struct PosFieldDefList {
2940 pub(crate) syntax: SyntaxNode, 2940 pub(crate) syntax: SyntaxNode,
2941} 2941}
2942unsafe impl TransparentNewType for PosFieldDefList { 2942unsafe impl TransparentNewType for PosFieldDefList {
2943 type Repr = rowan::SyntaxNode<RaTypes>; 2943 type Repr = rowan::SyntaxNode;
2944} 2944}
2945 2945
2946impl AstNode for PosFieldDefList { 2946impl AstNode for PosFieldDefList {
@@ -2972,7 +2972,7 @@ pub struct PrefixExpr {
2972 pub(crate) syntax: SyntaxNode, 2972 pub(crate) syntax: SyntaxNode,
2973} 2973}
2974unsafe impl TransparentNewType for PrefixExpr { 2974unsafe impl TransparentNewType for PrefixExpr {
2975 type Repr = rowan::SyntaxNode<RaTypes>; 2975 type Repr = rowan::SyntaxNode;
2976} 2976}
2977 2977
2978impl AstNode for PrefixExpr { 2978impl AstNode for PrefixExpr {
@@ -3004,7 +3004,7 @@ pub struct RangeExpr {
3004 pub(crate) syntax: SyntaxNode, 3004 pub(crate) syntax: SyntaxNode,
3005} 3005}
3006unsafe impl TransparentNewType for RangeExpr { 3006unsafe impl TransparentNewType for RangeExpr {
3007 type Repr = rowan::SyntaxNode<RaTypes>; 3007 type Repr = rowan::SyntaxNode;
3008} 3008}
3009 3009
3010impl AstNode for RangeExpr { 3010impl AstNode for RangeExpr {
@@ -3032,7 +3032,7 @@ pub struct RangePat {
3032 pub(crate) syntax: SyntaxNode, 3032 pub(crate) syntax: SyntaxNode,
3033} 3033}
3034unsafe impl TransparentNewType for RangePat { 3034unsafe impl TransparentNewType for RangePat {
3035 type Repr = rowan::SyntaxNode<RaTypes>; 3035 type Repr = rowan::SyntaxNode;
3036} 3036}
3037 3037
3038impl AstNode for RangePat { 3038impl AstNode for RangePat {
@@ -3060,7 +3060,7 @@ pub struct RefExpr {
3060 pub(crate) syntax: SyntaxNode, 3060 pub(crate) syntax: SyntaxNode,
3061} 3061}
3062unsafe impl TransparentNewType for RefExpr { 3062unsafe impl TransparentNewType for RefExpr {
3063 type Repr = rowan::SyntaxNode<RaTypes>; 3063 type Repr = rowan::SyntaxNode;
3064} 3064}
3065 3065
3066impl AstNode for RefExpr { 3066impl AstNode for RefExpr {
@@ -3092,7 +3092,7 @@ pub struct RefPat {
3092 pub(crate) syntax: SyntaxNode, 3092 pub(crate) syntax: SyntaxNode,
3093} 3093}
3094unsafe impl TransparentNewType for RefPat { 3094unsafe impl TransparentNewType for RefPat {
3095 type Repr = rowan::SyntaxNode<RaTypes>; 3095 type Repr = rowan::SyntaxNode;
3096} 3096}
3097 3097
3098impl AstNode for RefPat { 3098impl AstNode for RefPat {
@@ -3124,7 +3124,7 @@ pub struct ReferenceType {
3124 pub(crate) syntax: SyntaxNode, 3124 pub(crate) syntax: SyntaxNode,
3125} 3125}
3126unsafe impl TransparentNewType for ReferenceType { 3126unsafe impl TransparentNewType for ReferenceType {
3127 type Repr = rowan::SyntaxNode<RaTypes>; 3127 type Repr = rowan::SyntaxNode;
3128} 3128}
3129 3129
3130impl AstNode for ReferenceType { 3130impl AstNode for ReferenceType {
@@ -3156,7 +3156,7 @@ pub struct RetType {
3156 pub(crate) syntax: SyntaxNode, 3156 pub(crate) syntax: SyntaxNode,
3157} 3157}
3158unsafe impl TransparentNewType for RetType { 3158unsafe impl TransparentNewType for RetType {
3159 type Repr = rowan::SyntaxNode<RaTypes>; 3159 type Repr = rowan::SyntaxNode;
3160} 3160}
3161 3161
3162impl AstNode for RetType { 3162impl AstNode for RetType {
@@ -3188,7 +3188,7 @@ pub struct ReturnExpr {
3188 pub(crate) syntax: SyntaxNode, 3188 pub(crate) syntax: SyntaxNode,
3189} 3189}
3190unsafe impl TransparentNewType for ReturnExpr { 3190unsafe impl TransparentNewType for ReturnExpr {
3191 type Repr = rowan::SyntaxNode<RaTypes>; 3191 type Repr = rowan::SyntaxNode;
3192} 3192}
3193 3193
3194impl AstNode for ReturnExpr { 3194impl AstNode for ReturnExpr {
@@ -3220,7 +3220,7 @@ pub struct SelfParam {
3220 pub(crate) syntax: SyntaxNode, 3220 pub(crate) syntax: SyntaxNode,
3221} 3221}
3222unsafe impl TransparentNewType for SelfParam { 3222unsafe impl TransparentNewType for SelfParam {
3223 type Repr = rowan::SyntaxNode<RaTypes>; 3223 type Repr = rowan::SyntaxNode;
3224} 3224}
3225 3225
3226impl AstNode for SelfParam { 3226impl AstNode for SelfParam {
@@ -3249,7 +3249,7 @@ pub struct SlicePat {
3249 pub(crate) syntax: SyntaxNode, 3249 pub(crate) syntax: SyntaxNode,
3250} 3250}
3251unsafe impl TransparentNewType for SlicePat { 3251unsafe impl TransparentNewType for SlicePat {
3252 type Repr = rowan::SyntaxNode<RaTypes>; 3252 type Repr = rowan::SyntaxNode;
3253} 3253}
3254 3254
3255impl AstNode for SlicePat { 3255impl AstNode for SlicePat {
@@ -3277,7 +3277,7 @@ pub struct SliceType {
3277 pub(crate) syntax: SyntaxNode, 3277 pub(crate) syntax: SyntaxNode,
3278} 3278}
3279unsafe impl TransparentNewType for SliceType { 3279unsafe impl TransparentNewType for SliceType {
3280 type Repr = rowan::SyntaxNode<RaTypes>; 3280 type Repr = rowan::SyntaxNode;
3281} 3281}
3282 3282
3283impl AstNode for SliceType { 3283impl AstNode for SliceType {
@@ -3309,7 +3309,7 @@ pub struct SourceFile {
3309 pub(crate) syntax: SyntaxNode, 3309 pub(crate) syntax: SyntaxNode,
3310} 3310}
3311unsafe impl TransparentNewType for SourceFile { 3311unsafe impl TransparentNewType for SourceFile {
3312 type Repr = rowan::SyntaxNode<RaTypes>; 3312 type Repr = rowan::SyntaxNode;
3313} 3313}
3314 3314
3315impl AstNode for SourceFile { 3315impl AstNode for SourceFile {
@@ -3343,7 +3343,7 @@ pub struct StaticDef {
3343 pub(crate) syntax: SyntaxNode, 3343 pub(crate) syntax: SyntaxNode,
3344} 3344}
3345unsafe impl TransparentNewType for StaticDef { 3345unsafe impl TransparentNewType for StaticDef {
3346 type Repr = rowan::SyntaxNode<RaTypes>; 3346 type Repr = rowan::SyntaxNode;
3347} 3347}
3348 3348
3349impl AstNode for StaticDef { 3349impl AstNode for StaticDef {
@@ -3381,7 +3381,7 @@ pub struct Stmt {
3381 pub(crate) syntax: SyntaxNode, 3381 pub(crate) syntax: SyntaxNode,
3382} 3382}
3383unsafe impl TransparentNewType for Stmt { 3383unsafe impl TransparentNewType for Stmt {
3384 type Repr = rowan::SyntaxNode<RaTypes>; 3384 type Repr = rowan::SyntaxNode;
3385} 3385}
3386 3386
3387#[derive(Debug, Clone, Copy, PartialEq, Eq)] 3387#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -3436,7 +3436,7 @@ pub struct StructDef {
3436 pub(crate) syntax: SyntaxNode, 3436 pub(crate) syntax: SyntaxNode,
3437} 3437}
3438unsafe impl TransparentNewType for StructDef { 3438unsafe impl TransparentNewType for StructDef {
3439 type Repr = rowan::SyntaxNode<RaTypes>; 3439 type Repr = rowan::SyntaxNode;
3440} 3440}
3441 3441
3442impl AstNode for StructDef { 3442impl AstNode for StructDef {
@@ -3469,7 +3469,7 @@ pub struct StructLit {
3469 pub(crate) syntax: SyntaxNode, 3469 pub(crate) syntax: SyntaxNode,
3470} 3470}
3471unsafe impl TransparentNewType for StructLit { 3471unsafe impl TransparentNewType for StructLit {
3472 type Repr = rowan::SyntaxNode<RaTypes>; 3472 type Repr = rowan::SyntaxNode;
3473} 3473}
3474 3474
3475impl AstNode for StructLit { 3475impl AstNode for StructLit {
@@ -3509,7 +3509,7 @@ pub struct StructPat {
3509 pub(crate) syntax: SyntaxNode, 3509 pub(crate) syntax: SyntaxNode,
3510} 3510}
3511unsafe impl TransparentNewType for StructPat { 3511unsafe impl TransparentNewType for StructPat {
3512 type Repr = rowan::SyntaxNode<RaTypes>; 3512 type Repr = rowan::SyntaxNode;
3513} 3513}
3514 3514
3515impl AstNode for StructPat { 3515impl AstNode for StructPat {
@@ -3545,7 +3545,7 @@ pub struct TokenTree {
3545 pub(crate) syntax: SyntaxNode, 3545 pub(crate) syntax: SyntaxNode,
3546} 3546}
3547unsafe impl TransparentNewType for TokenTree { 3547unsafe impl TransparentNewType for TokenTree {
3548 type Repr = rowan::SyntaxNode<RaTypes>; 3548 type Repr = rowan::SyntaxNode;
3549} 3549}
3550 3550
3551impl AstNode for TokenTree { 3551impl AstNode for TokenTree {
@@ -3573,7 +3573,7 @@ pub struct TraitDef {
3573 pub(crate) syntax: SyntaxNode, 3573 pub(crate) syntax: SyntaxNode,
3574} 3574}
3575unsafe impl TransparentNewType for TraitDef { 3575unsafe impl TransparentNewType for TraitDef {
3576 type Repr = rowan::SyntaxNode<RaTypes>; 3576 type Repr = rowan::SyntaxNode;
3577} 3577}
3578 3578
3579impl AstNode for TraitDef { 3579impl AstNode for TraitDef {
@@ -3611,7 +3611,7 @@ pub struct TryExpr {
3611 pub(crate) syntax: SyntaxNode, 3611 pub(crate) syntax: SyntaxNode,
3612} 3612}
3613unsafe impl TransparentNewType for TryExpr { 3613unsafe impl TransparentNewType for TryExpr {
3614 type Repr = rowan::SyntaxNode<RaTypes>; 3614 type Repr = rowan::SyntaxNode;
3615} 3615}
3616 3616
3617impl AstNode for TryExpr { 3617impl AstNode for TryExpr {
@@ -3643,7 +3643,7 @@ pub struct TupleExpr {
3643 pub(crate) syntax: SyntaxNode, 3643 pub(crate) syntax: SyntaxNode,
3644} 3644}
3645unsafe impl TransparentNewType for TupleExpr { 3645unsafe impl TransparentNewType for TupleExpr {
3646 type Repr = rowan::SyntaxNode<RaTypes>; 3646 type Repr = rowan::SyntaxNode;
3647} 3647}
3648 3648
3649impl AstNode for TupleExpr { 3649impl AstNode for TupleExpr {
@@ -3675,7 +3675,7 @@ pub struct TuplePat {
3675 pub(crate) syntax: SyntaxNode, 3675 pub(crate) syntax: SyntaxNode,
3676} 3676}
3677unsafe impl TransparentNewType for TuplePat { 3677unsafe impl TransparentNewType for TuplePat {
3678 type Repr = rowan::SyntaxNode<RaTypes>; 3678 type Repr = rowan::SyntaxNode;
3679} 3679}
3680 3680
3681impl AstNode for TuplePat { 3681impl AstNode for TuplePat {
@@ -3707,7 +3707,7 @@ pub struct TupleStructPat {
3707 pub(crate) syntax: SyntaxNode, 3707 pub(crate) syntax: SyntaxNode,
3708} 3708}
3709unsafe impl TransparentNewType for TupleStructPat { 3709unsafe impl TransparentNewType for TupleStructPat {
3710 type Repr = rowan::SyntaxNode<RaTypes>; 3710 type Repr = rowan::SyntaxNode;
3711} 3711}
3712 3712
3713impl AstNode for TupleStructPat { 3713impl AstNode for TupleStructPat {
@@ -3743,7 +3743,7 @@ pub struct TupleType {
3743 pub(crate) syntax: SyntaxNode, 3743 pub(crate) syntax: SyntaxNode,
3744} 3744}
3745unsafe impl TransparentNewType for TupleType { 3745unsafe impl TransparentNewType for TupleType {
3746 type Repr = rowan::SyntaxNode<RaTypes>; 3746 type Repr = rowan::SyntaxNode;
3747} 3747}
3748 3748
3749impl AstNode for TupleType { 3749impl AstNode for TupleType {
@@ -3775,7 +3775,7 @@ pub struct TypeAliasDef {
3775 pub(crate) syntax: SyntaxNode, 3775 pub(crate) syntax: SyntaxNode,
3776} 3776}
3777unsafe impl TransparentNewType for TypeAliasDef { 3777unsafe impl TransparentNewType for TypeAliasDef {
3778 type Repr = rowan::SyntaxNode<RaTypes>; 3778 type Repr = rowan::SyntaxNode;
3779} 3779}
3780 3780
3781impl AstNode for TypeAliasDef { 3781impl AstNode for TypeAliasDef {
@@ -3813,7 +3813,7 @@ pub struct TypeArg {
3813 pub(crate) syntax: SyntaxNode, 3813 pub(crate) syntax: SyntaxNode,
3814} 3814}
3815unsafe impl TransparentNewType for TypeArg { 3815unsafe impl TransparentNewType for TypeArg {
3816 type Repr = rowan::SyntaxNode<RaTypes>; 3816 type Repr = rowan::SyntaxNode;
3817} 3817}
3818 3818
3819impl AstNode for TypeArg { 3819impl AstNode for TypeArg {
@@ -3845,7 +3845,7 @@ pub struct TypeArgList {
3845 pub(crate) syntax: SyntaxNode, 3845 pub(crate) syntax: SyntaxNode,
3846} 3846}
3847unsafe impl TransparentNewType for TypeArgList { 3847unsafe impl TransparentNewType for TypeArgList {
3848 type Repr = rowan::SyntaxNode<RaTypes>; 3848 type Repr = rowan::SyntaxNode;
3849} 3849}
3850 3850
3851impl AstNode for TypeArgList { 3851impl AstNode for TypeArgList {
@@ -3885,7 +3885,7 @@ pub struct TypeBound {
3885 pub(crate) syntax: SyntaxNode, 3885 pub(crate) syntax: SyntaxNode,
3886} 3886}
3887unsafe impl TransparentNewType for TypeBound { 3887unsafe impl TransparentNewType for TypeBound {
3888 type Repr = rowan::SyntaxNode<RaTypes>; 3888 type Repr = rowan::SyntaxNode;
3889} 3889}
3890 3890
3891impl AstNode for TypeBound { 3891impl AstNode for TypeBound {
@@ -3917,7 +3917,7 @@ pub struct TypeBoundList {
3917 pub(crate) syntax: SyntaxNode, 3917 pub(crate) syntax: SyntaxNode,
3918} 3918}
3919unsafe impl TransparentNewType for TypeBoundList { 3919unsafe impl TransparentNewType for TypeBoundList {
3920 type Repr = rowan::SyntaxNode<RaTypes>; 3920 type Repr = rowan::SyntaxNode;
3921} 3921}
3922 3922
3923impl AstNode for TypeBoundList { 3923impl AstNode for TypeBoundList {
@@ -3949,7 +3949,7 @@ pub struct TypeParam {
3949 pub(crate) syntax: SyntaxNode, 3949 pub(crate) syntax: SyntaxNode,
3950} 3950}
3951unsafe impl TransparentNewType for TypeParam { 3951unsafe impl TransparentNewType for TypeParam {
3952 type Repr = rowan::SyntaxNode<RaTypes>; 3952 type Repr = rowan::SyntaxNode;
3953} 3953}
3954 3954
3955impl AstNode for TypeParam { 3955impl AstNode for TypeParam {
@@ -3980,7 +3980,7 @@ pub struct TypeParamList {
3980 pub(crate) syntax: SyntaxNode, 3980 pub(crate) syntax: SyntaxNode,
3981} 3981}
3982unsafe impl TransparentNewType for TypeParamList { 3982unsafe impl TransparentNewType for TypeParamList {
3983 type Repr = rowan::SyntaxNode<RaTypes>; 3983 type Repr = rowan::SyntaxNode;
3984} 3984}
3985 3985
3986impl AstNode for TypeParamList { 3986impl AstNode for TypeParamList {
@@ -4016,7 +4016,7 @@ pub struct TypeRef {
4016 pub(crate) syntax: SyntaxNode, 4016 pub(crate) syntax: SyntaxNode,
4017} 4017}
4018unsafe impl TransparentNewType for TypeRef { 4018unsafe impl TransparentNewType for TypeRef {
4019 type Repr = rowan::SyntaxNode<RaTypes>; 4019 type Repr = rowan::SyntaxNode;
4020} 4020}
4021 4021
4022#[derive(Debug, Clone, Copy, PartialEq, Eq)] 4022#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -4159,7 +4159,7 @@ pub struct UseItem {
4159 pub(crate) syntax: SyntaxNode, 4159 pub(crate) syntax: SyntaxNode,
4160} 4160}
4161unsafe impl TransparentNewType for UseItem { 4161unsafe impl TransparentNewType for UseItem {
4162 type Repr = rowan::SyntaxNode<RaTypes>; 4162 type Repr = rowan::SyntaxNode;
4163} 4163}
4164 4164
4165impl AstNode for UseItem { 4165impl AstNode for UseItem {
@@ -4192,7 +4192,7 @@ pub struct UseTree {
4192 pub(crate) syntax: SyntaxNode, 4192 pub(crate) syntax: SyntaxNode,
4193} 4193}
4194unsafe impl TransparentNewType for UseTree { 4194unsafe impl TransparentNewType for UseTree {
4195 type Repr = rowan::SyntaxNode<RaTypes>; 4195 type Repr = rowan::SyntaxNode;
4196} 4196}
4197 4197
4198impl AstNode for UseTree { 4198impl AstNode for UseTree {
@@ -4232,7 +4232,7 @@ pub struct UseTreeList {
4232 pub(crate) syntax: SyntaxNode, 4232 pub(crate) syntax: SyntaxNode,
4233} 4233}
4234unsafe impl TransparentNewType for UseTreeList { 4234unsafe impl TransparentNewType for UseTreeList {
4235 type Repr = rowan::SyntaxNode<RaTypes>; 4235 type Repr = rowan::SyntaxNode;
4236} 4236}
4237 4237
4238impl AstNode for UseTreeList { 4238impl AstNode for UseTreeList {
@@ -4264,7 +4264,7 @@ pub struct Visibility {
4264 pub(crate) syntax: SyntaxNode, 4264 pub(crate) syntax: SyntaxNode,
4265} 4265}
4266unsafe impl TransparentNewType for Visibility { 4266unsafe impl TransparentNewType for Visibility {
4267 type Repr = rowan::SyntaxNode<RaTypes>; 4267 type Repr = rowan::SyntaxNode;
4268} 4268}
4269 4269
4270impl AstNode for Visibility { 4270impl AstNode for Visibility {
@@ -4292,7 +4292,7 @@ pub struct WhereClause {
4292 pub(crate) syntax: SyntaxNode, 4292 pub(crate) syntax: SyntaxNode,
4293} 4293}
4294unsafe impl TransparentNewType for WhereClause { 4294unsafe impl TransparentNewType for WhereClause {
4295 type Repr = rowan::SyntaxNode<RaTypes>; 4295 type Repr = rowan::SyntaxNode;
4296} 4296}
4297 4297
4298impl AstNode for WhereClause { 4298impl AstNode for WhereClause {
@@ -4324,7 +4324,7 @@ pub struct WherePred {
4324 pub(crate) syntax: SyntaxNode, 4324 pub(crate) syntax: SyntaxNode,
4325} 4325}
4326unsafe impl TransparentNewType for WherePred { 4326unsafe impl TransparentNewType for WherePred {
4327 type Repr = rowan::SyntaxNode<RaTypes>; 4327 type Repr = rowan::SyntaxNode;
4328} 4328}
4329 4329
4330impl AstNode for WherePred { 4330impl AstNode for WherePred {
@@ -4357,7 +4357,7 @@ pub struct WhileExpr {
4357 pub(crate) syntax: SyntaxNode, 4357 pub(crate) syntax: SyntaxNode,
4358} 4358}
4359unsafe impl TransparentNewType for WhileExpr { 4359unsafe impl TransparentNewType for WhileExpr {
4360 type Repr = rowan::SyntaxNode<RaTypes>; 4360 type Repr = rowan::SyntaxNode;
4361} 4361}
4362 4362
4363impl AstNode for WhileExpr { 4363impl AstNode for WhileExpr {
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index e2d4856cf..c8a13fc5f 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -15,7 +15,7 @@ use rowan::TransparentNewType;
15 15
16use crate::{ 16use crate::{
17 SyntaxNode, SyntaxKind::*, 17 SyntaxNode, SyntaxKind::*,
18 syntax_node::{RaTypes, TreeArc}, 18 syntax_node::{TreeArc},
19 ast::{self, AstNode}, 19 ast::{self, AstNode},
20}; 20};
21{% for node, methods in ast %} 21{% for node, methods in ast %}
@@ -28,7 +28,7 @@ pub struct {{ node }} {
28 pub(crate) syntax: SyntaxNode, 28 pub(crate) syntax: SyntaxNode,
29} 29}
30unsafe impl TransparentNewType for {{ node }} { 30unsafe impl TransparentNewType for {{ node }} {
31 type Repr = rowan::SyntaxNode<RaTypes>; 31 type Repr = rowan::SyntaxNode;
32} 32}
33 33
34#[derive(Debug, Clone, Copy, PartialEq, Eq)] 34#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -81,7 +81,7 @@ pub struct {{ node }} {
81 pub(crate) syntax: SyntaxNode, 81 pub(crate) syntax: SyntaxNode,
82} 82}
83unsafe impl TransparentNewType for {{ node }} { 83unsafe impl TransparentNewType for {{ node }} {
84 type Repr = rowan::SyntaxNode<RaTypes>; 84 type Repr = rowan::SyntaxNode;
85} 85}
86 86
87impl AstNode for {{ node }} { 87impl AstNode for {{ node }} {
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index c56bc9f16..a6ce14f06 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -79,7 +79,7 @@ impl SourceFile {
79 } 79 }
80 80
81 pub fn errors(&self) -> Vec<SyntaxError> { 81 pub fn errors(&self) -> Vec<SyntaxError> {
82 let mut errors = self.syntax.root_data().clone(); 82 let mut errors = self.syntax.root_data().to_vec();
83 errors.extend(validation::validate(self)); 83 errors.extend(validation::validate(self));
84 errors 84 errors
85 } 85 }
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index 69887f500..434f850d1 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -67,7 +67,7 @@ fn reparse_token<'node>(
67 } 67 }
68 } 68 }
69 69
70 let new_token = GreenToken::new(token.kind(), text.into()); 70 let new_token = GreenToken::new(rowan::SyntaxKind(token.kind().into()), text.into());
71 Some((token.replace_with(new_token), token.range())) 71 Some((token.replace_with(new_token), token.range()))
72 } 72 }
73 _ => None, 73 _ => None,
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs
index a88a348ad..64d884287 100644
--- a/crates/ra_syntax/src/syntax_node.rs
+++ b/crates/ra_syntax/src/syntax_node.rs
@@ -8,11 +8,12 @@
8 8
9use std::{ 9use std::{
10 fmt::{self, Write}, 10 fmt::{self, Write},
11 any::Any,
11 borrow::Borrow, 12 borrow::Borrow,
12}; 13};
13 14
14use ra_parser::ParseError; 15use ra_parser::ParseError;
15use rowan::{Types, TransparentNewType, GreenNodeBuilder}; 16use rowan::{TransparentNewType, GreenNodeBuilder};
16 17
17use crate::{ 18use crate::{
18 SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode, 19 SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode,
@@ -20,26 +21,15 @@ use crate::{
20}; 21};
21 22
22pub use rowan::WalkEvent; 23pub use rowan::WalkEvent;
23 24pub(crate) use rowan::{GreenNode, GreenToken};
24#[derive(Debug, Clone, Copy)]
25pub enum RaTypes {}
26impl Types for RaTypes {
27 type Kind = SyntaxKind;
28 type RootData = Vec<SyntaxError>;
29}
30
31pub(crate) type GreenNode = rowan::GreenNode<RaTypes>;
32pub(crate) type GreenToken = rowan::GreenToken<RaTypes>;
33#[allow(unused)]
34pub(crate) type GreenElement = rowan::GreenElement<RaTypes>;
35 25
36/// Marker trait for CST and AST nodes 26/// Marker trait for CST and AST nodes
37pub trait SyntaxNodeWrapper: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> {} 27pub trait SyntaxNodeWrapper: TransparentNewType<Repr = rowan::SyntaxNode> {}
38impl<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>> SyntaxNodeWrapper for T {} 28impl<T: TransparentNewType<Repr = rowan::SyntaxNode>> SyntaxNodeWrapper for T {}
39 29
40/// An owning smart pointer for CST or AST node. 30/// An owning smart pointer for CST or AST node.
41#[derive(PartialEq, Eq, Hash)] 31#[derive(PartialEq, Eq, Hash)]
42pub struct TreeArc<T: SyntaxNodeWrapper>(pub(crate) rowan::TreeArc<RaTypes, T>); 32pub struct TreeArc<T: SyntaxNodeWrapper>(pub(crate) rowan::TreeArc<T>);
43 33
44impl<T: SyntaxNodeWrapper> Borrow<T> for TreeArc<T> { 34impl<T: SyntaxNodeWrapper> Borrow<T> for TreeArc<T> {
45 fn borrow(&self) -> &T { 35 fn borrow(&self) -> &T {
@@ -101,9 +91,9 @@ where
101 91
102#[derive(PartialEq, Eq, Hash)] 92#[derive(PartialEq, Eq, Hash)]
103#[repr(transparent)] 93#[repr(transparent)]
104pub struct SyntaxNode(pub(crate) rowan::SyntaxNode<RaTypes>); 94pub struct SyntaxNode(pub(crate) rowan::SyntaxNode);
105unsafe impl TransparentNewType for SyntaxNode { 95unsafe impl TransparentNewType for SyntaxNode {
106 type Repr = rowan::SyntaxNode<RaTypes>; 96 type Repr = rowan::SyntaxNode;
107} 97}
108 98
109impl ToOwned for SyntaxNode { 99impl ToOwned for SyntaxNode {
@@ -134,12 +124,14 @@ pub enum Direction {
134 124
135impl SyntaxNode { 125impl SyntaxNode {
136 pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SyntaxNode> { 126 pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> TreeArc<SyntaxNode> {
127 let errors: Option<Box<Any + Send + Sync>> =
128 if errors.is_empty() { None } else { Some(Box::new(errors)) };
137 let ptr = TreeArc(rowan::SyntaxNode::new(green, errors)); 129 let ptr = TreeArc(rowan::SyntaxNode::new(green, errors));
138 TreeArc::cast(ptr) 130 TreeArc::cast(ptr)
139 } 131 }
140 132
141 pub fn kind(&self) -> SyntaxKind { 133 pub fn kind(&self) -> SyntaxKind {
142 self.0.kind() 134 self.0.kind().0.into()
143 } 135 }
144 136
145 pub fn range(&self) -> TextRange { 137 pub fn range(&self) -> TextRange {
@@ -303,8 +295,14 @@ impl SyntaxNode {
303 buf 295 buf
304 } 296 }
305 297
306 pub(crate) fn root_data(&self) -> &Vec<SyntaxError> { 298 pub(crate) fn root_data(&self) -> &[SyntaxError] {
307 self.0.root_data() 299 match self.0.root_data() {
300 None => &[],
301 Some(data) => {
302 let data: &Vec<SyntaxError> = std::any::Any::downcast_ref(data).unwrap();
303 data.as_slice()
304 }
305 }
308 } 306 }
309 307
310 pub(crate) fn replace_with(&self, replacement: GreenNode) -> GreenNode { 308 pub(crate) fn replace_with(&self, replacement: GreenNode) -> GreenNode {
@@ -313,7 +311,7 @@ impl SyntaxNode {
313} 311}
314 312
315#[derive(Clone, Copy, PartialEq, Eq, Hash)] 313#[derive(Clone, Copy, PartialEq, Eq, Hash)]
316pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a, RaTypes>); 314pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a>);
317 315
318//FIXME: always output text 316//FIXME: always output text
319impl<'a> fmt::Debug for SyntaxToken<'a> { 317impl<'a> fmt::Debug for SyntaxToken<'a> {
@@ -339,15 +337,15 @@ impl<'a> fmt::Display for SyntaxToken<'a> {
339 } 337 }
340} 338}
341 339
342impl<'a> From<rowan::SyntaxToken<'a, RaTypes>> for SyntaxToken<'a> { 340impl<'a> From<rowan::SyntaxToken<'a>> for SyntaxToken<'a> {
343 fn from(t: rowan::SyntaxToken<'a, RaTypes>) -> Self { 341 fn from(t: rowan::SyntaxToken<'a>) -> Self {
344 SyntaxToken(t) 342 SyntaxToken(t)
345 } 343 }
346} 344}
347 345
348impl<'a> SyntaxToken<'a> { 346impl<'a> SyntaxToken<'a> {
349 pub fn kind(&self) -> SyntaxKind { 347 pub fn kind(&self) -> SyntaxKind {
350 self.0.kind() 348 self.0.kind().0.into()
351 } 349 }
352 350
353 pub fn text(&self) -> &'a SmolStr { 351 pub fn text(&self) -> &'a SmolStr {
@@ -454,8 +452,8 @@ impl<'a> SyntaxElement<'a> {
454 } 452 }
455} 453}
456 454
457impl<'a> From<rowan::SyntaxElement<'a, RaTypes>> for SyntaxElement<'a> { 455impl<'a> From<rowan::SyntaxElement<'a>> for SyntaxElement<'a> {
458 fn from(el: rowan::SyntaxElement<'a, RaTypes>) -> Self { 456 fn from(el: rowan::SyntaxElement<'a>) -> Self {
459 match el { 457 match el {
460 rowan::SyntaxElement::Node(n) => SyntaxElement::Node(SyntaxNode::from_repr(n)), 458 rowan::SyntaxElement::Node(n) => SyntaxElement::Node(SyntaxNode::from_repr(n)),
461 rowan::SyntaxElement::Token(t) => SyntaxElement::Token(t.into()), 459 rowan::SyntaxElement::Token(t) => SyntaxElement::Token(t.into()),
@@ -485,7 +483,7 @@ impl<'a> SyntaxElement<'a> {
485} 483}
486 484
487#[derive(Debug)] 485#[derive(Debug)]
488pub struct SyntaxNodeChildren<'a>(rowan::SyntaxNodeChildren<'a, RaTypes>); 486pub struct SyntaxNodeChildren<'a>(rowan::SyntaxNodeChildren<'a>);
489 487
490impl<'a> Iterator for SyntaxNodeChildren<'a> { 488impl<'a> Iterator for SyntaxNodeChildren<'a> {
491 type Item = &'a SyntaxNode; 489 type Item = &'a SyntaxNode;
@@ -496,7 +494,7 @@ impl<'a> Iterator for SyntaxNodeChildren<'a> {
496} 494}
497 495
498#[derive(Debug)] 496#[derive(Debug)]
499pub struct SyntaxElementChildren<'a>(rowan::SyntaxElementChildren<'a, RaTypes>); 497pub struct SyntaxElementChildren<'a>(rowan::SyntaxElementChildren<'a>);
500 498
501impl<'a> Iterator for SyntaxElementChildren<'a> { 499impl<'a> Iterator for SyntaxElementChildren<'a> {
502 type Item = SyntaxElement<'a>; 500 type Item = SyntaxElement<'a>;
@@ -508,7 +506,7 @@ impl<'a> Iterator for SyntaxElementChildren<'a> {
508 506
509pub struct SyntaxTreeBuilder { 507pub struct SyntaxTreeBuilder {
510 errors: Vec<SyntaxError>, 508 errors: Vec<SyntaxError>,
511 inner: GreenNodeBuilder<RaTypes>, 509 inner: GreenNodeBuilder,
512} 510}
513 511
514impl Default for SyntaxTreeBuilder { 512impl Default for SyntaxTreeBuilder {
@@ -533,11 +531,11 @@ impl SyntaxTreeBuilder {
533 } 531 }
534 532
535 pub fn token(&mut self, kind: SyntaxKind, text: SmolStr) { 533 pub fn token(&mut self, kind: SyntaxKind, text: SmolStr) {
536 self.inner.token(kind, text) 534 self.inner.token(rowan::SyntaxKind(kind.into()), text)
537 } 535 }
538 536
539 pub fn start_node(&mut self, kind: SyntaxKind) { 537 pub fn start_node(&mut self, kind: SyntaxKind) {
540 self.inner.start_node(kind) 538 self.inner.start_node(rowan::SyntaxKind(kind.into()))
541 } 539 }
542 540
543 pub fn finish_node(&mut self) { 541 pub fn finish_node(&mut self) {