diff options
26 files changed, 583 insertions, 389 deletions
diff --git a/Cargo.lock b/Cargo.lock index 0400c6a94..843183d18 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1088,7 +1088,7 @@ dependencies = [ | |||
1088 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1088 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1089 | "ra_parser 0.1.0", | 1089 | "ra_parser 0.1.0", |
1090 | "ra_text_edit 0.1.0", | 1090 | "ra_text_edit 0.1.0", |
1091 | "rowan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1091 | "rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1092 | "smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", | 1092 | "smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", |
1093 | "test_utils 0.1.0", | 1093 | "test_utils 0.1.0", |
1094 | "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1094 | "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1309,7 +1309,7 @@ dependencies = [ | |||
1309 | 1309 | ||
1310 | [[package]] | 1310 | [[package]] |
1311 | name = "rowan" | 1311 | name = "rowan" |
1312 | version = "0.4.0" | 1312 | version = "0.5.0" |
1313 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1313 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1314 | dependencies = [ | 1314 | dependencies = [ |
1315 | "colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1315 | "colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1975,7 +1975,7 @@ dependencies = [ | |||
1975 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" | 1975 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" |
1976 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" | 1976 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" |
1977 | "checksum ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17f52a24414403f81528b67488cf8edc4eda977d3af1646bb6b106a600ead78f" | 1977 | "checksum ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17f52a24414403f81528b67488cf8edc4eda977d3af1646bb6b106a600ead78f" |
1978 | "checksum rowan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "397cd19c109641f10f3c66433440285e232d8cbd37406cf8f944a15ab1e63a8e" | 1978 | "checksum rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91237e0f16ac1073139acd696d9d386c3225ba1d6eafc09b105984905994068d" |
1979 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" | 1979 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" |
1980 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 1980 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
1981 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1981 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
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 | }; |
9 | use hir::Docs; | ||
10 | 9 | ||
11 | use crate::{FilePosition, CallInfo, db::RootDatabase}; | 10 | use 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. |
14 | pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { | 13 | pub(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 | ||
109 | impl CallInfo { | 108 | impl 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 | |||
118 | fn 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 { | |||
151 | fn bar() { foo(<|>3, ); }"#, | 148 | fn 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, ); }"#, | |||
162 | fn bar() { foo(3, <|>); }"#, | 159 | fn 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, <|>); }"#, | |||
173 | fn bar() { foo(<|>); }"#, | 170 | fn 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} | ||
181 | fn bar() { foo(<|>3, ); }"#, | ||
182 | ); | ||
183 | |||
184 | assert_eq!(info.parameters(), ["x: T", "y: U"]); | ||
185 | assert_eq!( | ||
186 | info.label(), | ||
187 | r#" | ||
188 | fn foo<T, U: Copy + Display>(x: T, y: U) -> u32 | ||
189 | where 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 {} | ||
201 | fn bar() { foo(<|>); }"#, | ||
202 | ); | ||
203 | |||
204 | assert!(info.parameters().is_empty()); | ||
205 | assert_eq!( | ||
206 | info.label(), | ||
207 | r#" | ||
208 | fn foo<T>() -> T | ||
209 | where 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{}} } |
184 | fn bar() {let _ : F = F::new(<|>);}"#, | 220 | fn 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; | |||
13 | mod complete_postfix; | 13 | mod complete_postfix; |
14 | 14 | ||
15 | use ra_db::SourceDatabase; | 15 | use ra_db::SourceDatabase; |
16 | use ra_syntax::{ast::{self, AstNode}, SyntaxKind::{ATTR, COMMENT}}; | ||
17 | 16 | ||
18 | use crate::{ | 17 | use 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 | |||
74 | pub 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 | |||
92 | pub 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 | |||
103 | pub 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 | ||
7 | use crate::completion::{ | 7 | use crate::completion::{ |
8 | Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, | 8 | Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, |
9 | }; | ||
10 | |||
11 | use 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 | --- |
2 | created: "2019-02-18T09:22:24.188564584Z" | 2 | created: "2019-04-04T14:52:24.531844100Z" |
3 | creator: insta@0.6.2 | 3 | creator: insta@0.7.4 |
4 | source: crates/ra_ide_api/src/completion/completion_item.rs | 4 | source: crates/ra_ide_api/src/completion/completion_item.rs |
5 | expression: kind_completions | 5 | expression: 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 | --- |
2 | created: "2019-02-18T09:22:24.182964414Z" | 2 | created: "2019-04-04T14:52:24.525395600Z" |
3 | creator: insta@0.6.2 | 3 | creator: insta@0.7.4 |
4 | source: crates/ra_ide_api/src/completion/completion_item.rs | 4 | source: crates/ra_ide_api/src/completion/completion_item.rs |
5 | expression: kind_completions | 5 | expression: 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 | |||
4 | mod function_signature; | ||
5 | mod navigation_target; | ||
6 | mod structure; | ||
7 | |||
8 | use crate::db::RootDatabase; | ||
9 | use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}}; | ||
10 | |||
11 | pub use navigation_target::NavigationTarget; | ||
12 | pub use structure::{StructureNode, file_structure}; | ||
13 | pub use function_signature::FunctionSignature; | ||
14 | |||
15 | pub(crate) fn function_label(node: &ast::FnDef) -> String { | ||
16 | FunctionSignature::from(node).to_string() | ||
17 | } | ||
18 | |||
19 | pub(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 | |||
30 | pub(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 | |||
41 | pub(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 | |||
50 | pub(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 | |||
58 | pub(crate) fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String { | ||
59 | rust_code_markup_with_doc::<_, &str>(val, None) | ||
60 | } | ||
61 | |||
62 | pub(crate) fn rust_code_markup_with_doc<CODE, DOC>(val: CODE, doc: Option<DOC>) -> String | ||
63 | where | ||
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`. | ||
76 | pub(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 @@ | |||
1 | use super::{where_predicates, generic_parameters}; | ||
2 | use crate::db; | ||
3 | use std::fmt::{self, Display}; | ||
4 | use join_to_string::join; | ||
5 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; | ||
6 | use std::convert::From; | ||
7 | use hir::{Docs, Documentation}; | ||
8 | |||
9 | /// Contains information about a function signature | ||
10 | #[derive(Debug)] | ||
11 | pub 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 | |||
28 | impl 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 | |||
41 | impl 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 | |||
71 | impl 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 @@ | |||
1 | use ra_db::FileId; | 1 | use ra_db::{FileId, SourceDatabase}; |
2 | use ra_syntax::{ | 2 | use 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 | }; |
6 | use hir::{ModuleSource, FieldSource, Name, ImplItem}; | 8 | use 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 | --- |
2 | created: "2019-02-05T22:03:50.763530100Z" | 2 | created: "2019-04-08T09:44:50.196004400Z" |
3 | creator: insta@0.6.1 | 3 | creator: insta@0.7.4 |
4 | source: crates/ra_ide_api/src/structure.rs | 4 | source: crates/ra_ide_api/src/display/structure.rs |
5 | expression: structure | 5 | expression: 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 @@ | |||
1 | use ra_db::SourceDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use 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 | }; |
6 | use hir::HirDisplay; | 6 | use hir::HirDisplay; |
7 | 7 | ||
8 | use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget}; | 8 | use 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 | ||
148 | fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String { | ||
149 | rust_code_markup_with_doc::<_, &str>(val, None) | ||
150 | } | ||
151 | |||
152 | fn rust_code_markup_with_doc<CODE, DOC>(val: CODE, doc: Option<DOC>) -> String | ||
153 | where | ||
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`. | ||
166 | fn 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 | |||
174 | impl 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)] |
253 | mod tests { | 149 | mod 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 @@ | |||
13 | mod db; | 13 | mod db; |
14 | pub mod mock_analysis; | 14 | pub mod mock_analysis; |
15 | mod symbol_index; | 15 | mod symbol_index; |
16 | mod navigation_target; | ||
17 | mod change; | 16 | mod change; |
18 | 17 | ||
19 | mod status; | 18 | mod status; |
@@ -34,9 +33,9 @@ mod folding_ranges; | |||
34 | mod line_index; | 33 | mod line_index; |
35 | mod line_index_utils; | 34 | mod line_index_utils; |
36 | mod join_lines; | 35 | mod join_lines; |
37 | mod structure; | ||
38 | mod typing; | 36 | mod typing; |
39 | mod matching_brace; | 37 | mod matching_brace; |
38 | mod display; | ||
40 | 39 | ||
41 | #[cfg(test)] | 40 | #[cfg(test)] |
42 | mod marks; | 41 | mod 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 | ||
77 | pub use ra_db::{ | 75 | pub use ra_db::{ |
@@ -243,9 +241,7 @@ impl<T> RangeInfo<T> { | |||
243 | 241 | ||
244 | #[derive(Debug)] | 242 | #[derive(Debug)] |
245 | pub struct CallInfo { | 243 | pub 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> { | |||
275 | mod tests { | 275 | mod 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 | ||
177 | impl 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 | |||
177 | impl ConvWith for TextEdit { | 199 | impl 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 | }; |
10 | use ra_ide_api::{ | 10 | use 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)] | ||
10 | pub enum SyntaxKind { | 11 | pub 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 | } |
234 | use self::SyntaxKind::*; | 238 | use self::SyntaxKind::*; |
235 | 239 | ||
240 | impl 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 | |||
247 | impl From<SyntaxKind> for u16 { | ||
248 | fn from(k: SyntaxKind) -> u16 { | ||
249 | k as u16 | ||
250 | } | ||
251 | } | ||
252 | |||
236 | impl SyntaxKind { | 253 | impl 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)] | ||
12 | pub enum SyntaxKind { | 13 | pub 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 | } |
30 | use self::SyntaxKind::*; | 34 | use self::SyntaxKind::*; |
31 | 35 | ||
36 | impl 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 | |||
43 | impl From<SyntaxKind> for u16 { | ||
44 | fn from(k: SyntaxKind) -> u16 { | ||
45 | k as u16 | ||
46 | } | ||
47 | } | ||
48 | |||
32 | impl SyntaxKind { | 49 | impl 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" | |||
13 | itertools = "0.8.0" | 13 | itertools = "0.8.0" |
14 | drop_bomb = "0.1.4" | 14 | drop_bomb = "0.1.4" |
15 | parking_lot = "0.7.0" | 15 | parking_lot = "0.7.0" |
16 | rowan = "0.4.0" | 16 | rowan = "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; | |||
9 | use std::marker::PhantomData; | 9 | use std::marker::PhantomData; |
10 | 10 | ||
11 | use crate::{ | 11 | use 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. |
28 | pub trait AstNode: | 28 | pub 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 | ||
14 | use crate::{ | 14 | use 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 | } |
26 | unsafe impl TransparentNewType for Alias { | 26 | unsafe impl TransparentNewType for Alias { |
27 | type Repr = rowan::SyntaxNode<RaTypes>; | 27 | type Repr = rowan::SyntaxNode; |
28 | } | 28 | } |
29 | 29 | ||
30 | impl AstNode for Alias { | 30 | impl AstNode for Alias { |
@@ -53,7 +53,7 @@ pub struct ArgList { | |||
53 | pub(crate) syntax: SyntaxNode, | 53 | pub(crate) syntax: SyntaxNode, |
54 | } | 54 | } |
55 | unsafe impl TransparentNewType for ArgList { | 55 | unsafe impl TransparentNewType for ArgList { |
56 | type Repr = rowan::SyntaxNode<RaTypes>; | 56 | type Repr = rowan::SyntaxNode; |
57 | } | 57 | } |
58 | 58 | ||
59 | impl AstNode for ArgList { | 59 | impl AstNode for ArgList { |
@@ -85,7 +85,7 @@ pub struct ArrayExpr { | |||
85 | pub(crate) syntax: SyntaxNode, | 85 | pub(crate) syntax: SyntaxNode, |
86 | } | 86 | } |
87 | unsafe impl TransparentNewType for ArrayExpr { | 87 | unsafe impl TransparentNewType for ArrayExpr { |
88 | type Repr = rowan::SyntaxNode<RaTypes>; | 88 | type Repr = rowan::SyntaxNode; |
89 | } | 89 | } |
90 | 90 | ||
91 | impl AstNode for ArrayExpr { | 91 | impl AstNode for ArrayExpr { |
@@ -117,7 +117,7 @@ pub struct ArrayType { | |||
117 | pub(crate) syntax: SyntaxNode, | 117 | pub(crate) syntax: SyntaxNode, |
118 | } | 118 | } |
119 | unsafe impl TransparentNewType for ArrayType { | 119 | unsafe impl TransparentNewType for ArrayType { |
120 | type Repr = rowan::SyntaxNode<RaTypes>; | 120 | type Repr = rowan::SyntaxNode; |
121 | } | 121 | } |
122 | 122 | ||
123 | impl AstNode for ArrayType { | 123 | impl AstNode for ArrayType { |
@@ -153,7 +153,7 @@ pub struct AssocTypeArg { | |||
153 | pub(crate) syntax: SyntaxNode, | 153 | pub(crate) syntax: SyntaxNode, |
154 | } | 154 | } |
155 | unsafe impl TransparentNewType for AssocTypeArg { | 155 | unsafe impl TransparentNewType for AssocTypeArg { |
156 | type Repr = rowan::SyntaxNode<RaTypes>; | 156 | type Repr = rowan::SyntaxNode; |
157 | } | 157 | } |
158 | 158 | ||
159 | impl AstNode for AssocTypeArg { | 159 | impl AstNode for AssocTypeArg { |
@@ -189,7 +189,7 @@ pub struct Attr { | |||
189 | pub(crate) syntax: SyntaxNode, | 189 | pub(crate) syntax: SyntaxNode, |
190 | } | 190 | } |
191 | unsafe impl TransparentNewType for Attr { | 191 | unsafe impl TransparentNewType for Attr { |
192 | type Repr = rowan::SyntaxNode<RaTypes>; | 192 | type Repr = rowan::SyntaxNode; |
193 | } | 193 | } |
194 | 194 | ||
195 | impl AstNode for Attr { | 195 | impl AstNode for Attr { |
@@ -221,7 +221,7 @@ pub struct BinExpr { | |||
221 | pub(crate) syntax: SyntaxNode, | 221 | pub(crate) syntax: SyntaxNode, |
222 | } | 222 | } |
223 | unsafe impl TransparentNewType for BinExpr { | 223 | unsafe impl TransparentNewType for BinExpr { |
224 | type Repr = rowan::SyntaxNode<RaTypes>; | 224 | type Repr = rowan::SyntaxNode; |
225 | } | 225 | } |
226 | 226 | ||
227 | impl AstNode for BinExpr { | 227 | impl AstNode for BinExpr { |
@@ -249,7 +249,7 @@ pub struct BindPat { | |||
249 | pub(crate) syntax: SyntaxNode, | 249 | pub(crate) syntax: SyntaxNode, |
250 | } | 250 | } |
251 | unsafe impl TransparentNewType for BindPat { | 251 | unsafe impl TransparentNewType for BindPat { |
252 | type Repr = rowan::SyntaxNode<RaTypes>; | 252 | type Repr = rowan::SyntaxNode; |
253 | } | 253 | } |
254 | 254 | ||
255 | impl AstNode for BindPat { | 255 | impl AstNode for BindPat { |
@@ -282,7 +282,7 @@ pub struct Block { | |||
282 | pub(crate) syntax: SyntaxNode, | 282 | pub(crate) syntax: SyntaxNode, |
283 | } | 283 | } |
284 | unsafe impl TransparentNewType for Block { | 284 | unsafe impl TransparentNewType for Block { |
285 | type Repr = rowan::SyntaxNode<RaTypes>; | 285 | type Repr = rowan::SyntaxNode; |
286 | } | 286 | } |
287 | 287 | ||
288 | impl AstNode for Block { | 288 | impl AstNode for Block { |
@@ -319,7 +319,7 @@ pub struct BlockExpr { | |||
319 | pub(crate) syntax: SyntaxNode, | 319 | pub(crate) syntax: SyntaxNode, |
320 | } | 320 | } |
321 | unsafe impl TransparentNewType for BlockExpr { | 321 | unsafe impl TransparentNewType for BlockExpr { |
322 | type Repr = rowan::SyntaxNode<RaTypes>; | 322 | type Repr = rowan::SyntaxNode; |
323 | } | 323 | } |
324 | 324 | ||
325 | impl AstNode for BlockExpr { | 325 | impl AstNode for BlockExpr { |
@@ -351,7 +351,7 @@ pub struct BreakExpr { | |||
351 | pub(crate) syntax: SyntaxNode, | 351 | pub(crate) syntax: SyntaxNode, |
352 | } | 352 | } |
353 | unsafe impl TransparentNewType for BreakExpr { | 353 | unsafe impl TransparentNewType for BreakExpr { |
354 | type Repr = rowan::SyntaxNode<RaTypes>; | 354 | type Repr = rowan::SyntaxNode; |
355 | } | 355 | } |
356 | 356 | ||
357 | impl AstNode for BreakExpr { | 357 | impl AstNode for BreakExpr { |
@@ -383,7 +383,7 @@ pub struct CallExpr { | |||
383 | pub(crate) syntax: SyntaxNode, | 383 | pub(crate) syntax: SyntaxNode, |
384 | } | 384 | } |
385 | unsafe impl TransparentNewType for CallExpr { | 385 | unsafe impl TransparentNewType for CallExpr { |
386 | type Repr = rowan::SyntaxNode<RaTypes>; | 386 | type Repr = rowan::SyntaxNode; |
387 | } | 387 | } |
388 | 388 | ||
389 | impl AstNode for CallExpr { | 389 | impl AstNode for CallExpr { |
@@ -416,7 +416,7 @@ pub struct CastExpr { | |||
416 | pub(crate) syntax: SyntaxNode, | 416 | pub(crate) syntax: SyntaxNode, |
417 | } | 417 | } |
418 | unsafe impl TransparentNewType for CastExpr { | 418 | unsafe impl TransparentNewType for CastExpr { |
419 | type Repr = rowan::SyntaxNode<RaTypes>; | 419 | type Repr = rowan::SyntaxNode; |
420 | } | 420 | } |
421 | 421 | ||
422 | impl AstNode for CastExpr { | 422 | impl AstNode for CastExpr { |
@@ -452,7 +452,7 @@ pub struct Condition { | |||
452 | pub(crate) syntax: SyntaxNode, | 452 | pub(crate) syntax: SyntaxNode, |
453 | } | 453 | } |
454 | unsafe impl TransparentNewType for Condition { | 454 | unsafe impl TransparentNewType for Condition { |
455 | type Repr = rowan::SyntaxNode<RaTypes>; | 455 | type Repr = rowan::SyntaxNode; |
456 | } | 456 | } |
457 | 457 | ||
458 | impl AstNode for Condition { | 458 | impl AstNode for Condition { |
@@ -488,7 +488,7 @@ pub struct ConstDef { | |||
488 | pub(crate) syntax: SyntaxNode, | 488 | pub(crate) syntax: SyntaxNode, |
489 | } | 489 | } |
490 | unsafe impl TransparentNewType for ConstDef { | 490 | unsafe impl TransparentNewType for ConstDef { |
491 | type Repr = rowan::SyntaxNode<RaTypes>; | 491 | type Repr = rowan::SyntaxNode; |
492 | } | 492 | } |
493 | 493 | ||
494 | impl AstNode for ConstDef { | 494 | impl AstNode for ConstDef { |
@@ -526,7 +526,7 @@ pub struct ContinueExpr { | |||
526 | pub(crate) syntax: SyntaxNode, | 526 | pub(crate) syntax: SyntaxNode, |
527 | } | 527 | } |
528 | unsafe impl TransparentNewType for ContinueExpr { | 528 | unsafe impl TransparentNewType for ContinueExpr { |
529 | type Repr = rowan::SyntaxNode<RaTypes>; | 529 | type Repr = rowan::SyntaxNode; |
530 | } | 530 | } |
531 | 531 | ||
532 | impl AstNode for ContinueExpr { | 532 | impl AstNode for ContinueExpr { |
@@ -554,7 +554,7 @@ pub struct DynTraitType { | |||
554 | pub(crate) syntax: SyntaxNode, | 554 | pub(crate) syntax: SyntaxNode, |
555 | } | 555 | } |
556 | unsafe impl TransparentNewType for DynTraitType { | 556 | unsafe impl TransparentNewType for DynTraitType { |
557 | type Repr = rowan::SyntaxNode<RaTypes>; | 557 | type Repr = rowan::SyntaxNode; |
558 | } | 558 | } |
559 | 559 | ||
560 | impl AstNode for DynTraitType { | 560 | impl AstNode for DynTraitType { |
@@ -583,7 +583,7 @@ pub struct EnumDef { | |||
583 | pub(crate) syntax: SyntaxNode, | 583 | pub(crate) syntax: SyntaxNode, |
584 | } | 584 | } |
585 | unsafe impl TransparentNewType for EnumDef { | 585 | unsafe impl TransparentNewType for EnumDef { |
586 | type Repr = rowan::SyntaxNode<RaTypes>; | 586 | type Repr = rowan::SyntaxNode; |
587 | } | 587 | } |
588 | 588 | ||
589 | impl AstNode for EnumDef { | 589 | impl AstNode for EnumDef { |
@@ -620,7 +620,7 @@ pub struct EnumVariant { | |||
620 | pub(crate) syntax: SyntaxNode, | 620 | pub(crate) syntax: SyntaxNode, |
621 | } | 621 | } |
622 | unsafe impl TransparentNewType for EnumVariant { | 622 | unsafe impl TransparentNewType for EnumVariant { |
623 | type Repr = rowan::SyntaxNode<RaTypes>; | 623 | type Repr = rowan::SyntaxNode; |
624 | } | 624 | } |
625 | 625 | ||
626 | impl AstNode for EnumVariant { | 626 | impl AstNode for EnumVariant { |
@@ -655,7 +655,7 @@ pub struct EnumVariantList { | |||
655 | pub(crate) syntax: SyntaxNode, | 655 | pub(crate) syntax: SyntaxNode, |
656 | } | 656 | } |
657 | unsafe impl TransparentNewType for EnumVariantList { | 657 | unsafe impl TransparentNewType for EnumVariantList { |
658 | type Repr = rowan::SyntaxNode<RaTypes>; | 658 | type Repr = rowan::SyntaxNode; |
659 | } | 659 | } |
660 | 660 | ||
661 | impl AstNode for EnumVariantList { | 661 | impl AstNode for EnumVariantList { |
@@ -687,7 +687,7 @@ pub struct Expr { | |||
687 | pub(crate) syntax: SyntaxNode, | 687 | pub(crate) syntax: SyntaxNode, |
688 | } | 688 | } |
689 | unsafe impl TransparentNewType for Expr { | 689 | unsafe 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 | } |
952 | unsafe impl TransparentNewType for ExprStmt { | 952 | unsafe impl TransparentNewType for ExprStmt { |
953 | type Repr = rowan::SyntaxNode<RaTypes>; | 953 | type Repr = rowan::SyntaxNode; |
954 | } | 954 | } |
955 | 955 | ||
956 | impl AstNode for ExprStmt { | 956 | impl AstNode for ExprStmt { |
@@ -982,7 +982,7 @@ pub struct ExternCrateItem { | |||
982 | pub(crate) syntax: SyntaxNode, | 982 | pub(crate) syntax: SyntaxNode, |
983 | } | 983 | } |
984 | unsafe impl TransparentNewType for ExternCrateItem { | 984 | unsafe impl TransparentNewType for ExternCrateItem { |
985 | type Repr = rowan::SyntaxNode<RaTypes>; | 985 | type Repr = rowan::SyntaxNode; |
986 | } | 986 | } |
987 | 987 | ||
988 | impl AstNode for ExternCrateItem { | 988 | impl AstNode for ExternCrateItem { |
@@ -1018,7 +1018,7 @@ pub struct FieldExpr { | |||
1018 | pub(crate) syntax: SyntaxNode, | 1018 | pub(crate) syntax: SyntaxNode, |
1019 | } | 1019 | } |
1020 | unsafe impl TransparentNewType for FieldExpr { | 1020 | unsafe impl TransparentNewType for FieldExpr { |
1021 | type Repr = rowan::SyntaxNode<RaTypes>; | 1021 | type Repr = rowan::SyntaxNode; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | impl AstNode for FieldExpr { | 1024 | impl AstNode for FieldExpr { |
@@ -1054,7 +1054,7 @@ pub struct FieldPat { | |||
1054 | pub(crate) syntax: SyntaxNode, | 1054 | pub(crate) syntax: SyntaxNode, |
1055 | } | 1055 | } |
1056 | unsafe impl TransparentNewType for FieldPat { | 1056 | unsafe impl TransparentNewType for FieldPat { |
1057 | type Repr = rowan::SyntaxNode<RaTypes>; | 1057 | type Repr = rowan::SyntaxNode; |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | impl AstNode for FieldPat { | 1060 | impl AstNode for FieldPat { |
@@ -1087,7 +1087,7 @@ pub struct FieldPatList { | |||
1087 | pub(crate) syntax: SyntaxNode, | 1087 | pub(crate) syntax: SyntaxNode, |
1088 | } | 1088 | } |
1089 | unsafe impl TransparentNewType for FieldPatList { | 1089 | unsafe impl TransparentNewType for FieldPatList { |
1090 | type Repr = rowan::SyntaxNode<RaTypes>; | 1090 | type Repr = rowan::SyntaxNode; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | impl AstNode for FieldPatList { | 1093 | impl AstNode for FieldPatList { |
@@ -1123,7 +1123,7 @@ pub struct FnDef { | |||
1123 | pub(crate) syntax: SyntaxNode, | 1123 | pub(crate) syntax: SyntaxNode, |
1124 | } | 1124 | } |
1125 | unsafe impl TransparentNewType for FnDef { | 1125 | unsafe impl TransparentNewType for FnDef { |
1126 | type Repr = rowan::SyntaxNode<RaTypes>; | 1126 | type Repr = rowan::SyntaxNode; |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | impl AstNode for FnDef { | 1129 | impl AstNode for FnDef { |
@@ -1168,7 +1168,7 @@ pub struct FnPointerType { | |||
1168 | pub(crate) syntax: SyntaxNode, | 1168 | pub(crate) syntax: SyntaxNode, |
1169 | } | 1169 | } |
1170 | unsafe impl TransparentNewType for FnPointerType { | 1170 | unsafe impl TransparentNewType for FnPointerType { |
1171 | type Repr = rowan::SyntaxNode<RaTypes>; | 1171 | type Repr = rowan::SyntaxNode; |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | impl AstNode for FnPointerType { | 1174 | impl AstNode for FnPointerType { |
@@ -1204,7 +1204,7 @@ pub struct ForExpr { | |||
1204 | pub(crate) syntax: SyntaxNode, | 1204 | pub(crate) syntax: SyntaxNode, |
1205 | } | 1205 | } |
1206 | unsafe impl TransparentNewType for ForExpr { | 1206 | unsafe impl TransparentNewType for ForExpr { |
1207 | type Repr = rowan::SyntaxNode<RaTypes>; | 1207 | type Repr = rowan::SyntaxNode; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | impl AstNode for ForExpr { | 1210 | impl AstNode for ForExpr { |
@@ -1241,7 +1241,7 @@ pub struct ForType { | |||
1241 | pub(crate) syntax: SyntaxNode, | 1241 | pub(crate) syntax: SyntaxNode, |
1242 | } | 1242 | } |
1243 | unsafe impl TransparentNewType for ForType { | 1243 | unsafe impl TransparentNewType for ForType { |
1244 | type Repr = rowan::SyntaxNode<RaTypes>; | 1244 | type Repr = rowan::SyntaxNode; |
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | impl AstNode for ForType { | 1247 | impl AstNode for ForType { |
@@ -1273,7 +1273,7 @@ pub struct IfExpr { | |||
1273 | pub(crate) syntax: SyntaxNode, | 1273 | pub(crate) syntax: SyntaxNode, |
1274 | } | 1274 | } |
1275 | unsafe impl TransparentNewType for IfExpr { | 1275 | unsafe impl TransparentNewType for IfExpr { |
1276 | type Repr = rowan::SyntaxNode<RaTypes>; | 1276 | type Repr = rowan::SyntaxNode; |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | impl AstNode for IfExpr { | 1279 | impl AstNode for IfExpr { |
@@ -1305,7 +1305,7 @@ pub struct ImplBlock { | |||
1305 | pub(crate) syntax: SyntaxNode, | 1305 | pub(crate) syntax: SyntaxNode, |
1306 | } | 1306 | } |
1307 | unsafe impl TransparentNewType for ImplBlock { | 1307 | unsafe impl TransparentNewType for ImplBlock { |
1308 | type Repr = rowan::SyntaxNode<RaTypes>; | 1308 | type Repr = rowan::SyntaxNode; |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | impl AstNode for ImplBlock { | 1311 | impl AstNode for ImplBlock { |
@@ -1338,7 +1338,7 @@ pub struct ImplItem { | |||
1338 | pub(crate) syntax: SyntaxNode, | 1338 | pub(crate) syntax: SyntaxNode, |
1339 | } | 1339 | } |
1340 | unsafe impl TransparentNewType for ImplItem { | 1340 | unsafe 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 | } |
1403 | unsafe impl TransparentNewType for ImplTraitType { | 1403 | unsafe impl TransparentNewType for ImplTraitType { |
1404 | type Repr = rowan::SyntaxNode<RaTypes>; | 1404 | type Repr = rowan::SyntaxNode; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | impl AstNode for ImplTraitType { | 1407 | impl AstNode for ImplTraitType { |
@@ -1430,7 +1430,7 @@ pub struct IndexExpr { | |||
1430 | pub(crate) syntax: SyntaxNode, | 1430 | pub(crate) syntax: SyntaxNode, |
1431 | } | 1431 | } |
1432 | unsafe impl TransparentNewType for IndexExpr { | 1432 | unsafe impl TransparentNewType for IndexExpr { |
1433 | type Repr = rowan::SyntaxNode<RaTypes>; | 1433 | type Repr = rowan::SyntaxNode; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | impl AstNode for IndexExpr { | 1436 | impl AstNode for IndexExpr { |
@@ -1458,7 +1458,7 @@ pub struct ItemList { | |||
1458 | pub(crate) syntax: SyntaxNode, | 1458 | pub(crate) syntax: SyntaxNode, |
1459 | } | 1459 | } |
1460 | unsafe impl TransparentNewType for ItemList { | 1460 | unsafe impl TransparentNewType for ItemList { |
1461 | type Repr = rowan::SyntaxNode<RaTypes>; | 1461 | type Repr = rowan::SyntaxNode; |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | impl AstNode for ItemList { | 1464 | impl AstNode for ItemList { |
@@ -1492,7 +1492,7 @@ pub struct Label { | |||
1492 | pub(crate) syntax: SyntaxNode, | 1492 | pub(crate) syntax: SyntaxNode, |
1493 | } | 1493 | } |
1494 | unsafe impl TransparentNewType for Label { | 1494 | unsafe impl TransparentNewType for Label { |
1495 | type Repr = rowan::SyntaxNode<RaTypes>; | 1495 | type Repr = rowan::SyntaxNode; |
1496 | } | 1496 | } |
1497 | 1497 | ||
1498 | impl AstNode for Label { | 1498 | impl AstNode for Label { |
@@ -1520,7 +1520,7 @@ pub struct LambdaExpr { | |||
1520 | pub(crate) syntax: SyntaxNode, | 1520 | pub(crate) syntax: SyntaxNode, |
1521 | } | 1521 | } |
1522 | unsafe impl TransparentNewType for LambdaExpr { | 1522 | unsafe impl TransparentNewType for LambdaExpr { |
1523 | type Repr = rowan::SyntaxNode<RaTypes>; | 1523 | type Repr = rowan::SyntaxNode; |
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | impl AstNode for LambdaExpr { | 1526 | impl AstNode for LambdaExpr { |
@@ -1556,7 +1556,7 @@ pub struct LetStmt { | |||
1556 | pub(crate) syntax: SyntaxNode, | 1556 | pub(crate) syntax: SyntaxNode, |
1557 | } | 1557 | } |
1558 | unsafe impl TransparentNewType for LetStmt { | 1558 | unsafe impl TransparentNewType for LetStmt { |
1559 | type Repr = rowan::SyntaxNode<RaTypes>; | 1559 | type Repr = rowan::SyntaxNode; |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | impl AstNode for LetStmt { | 1562 | impl AstNode for LetStmt { |
@@ -1593,7 +1593,7 @@ pub struct LifetimeArg { | |||
1593 | pub(crate) syntax: SyntaxNode, | 1593 | pub(crate) syntax: SyntaxNode, |
1594 | } | 1594 | } |
1595 | unsafe impl TransparentNewType for LifetimeArg { | 1595 | unsafe impl TransparentNewType for LifetimeArg { |
1596 | type Repr = rowan::SyntaxNode<RaTypes>; | 1596 | type Repr = rowan::SyntaxNode; |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | impl AstNode for LifetimeArg { | 1599 | impl AstNode for LifetimeArg { |
@@ -1621,7 +1621,7 @@ pub struct LifetimeParam { | |||
1621 | pub(crate) syntax: SyntaxNode, | 1621 | pub(crate) syntax: SyntaxNode, |
1622 | } | 1622 | } |
1623 | unsafe impl TransparentNewType for LifetimeParam { | 1623 | unsafe impl TransparentNewType for LifetimeParam { |
1624 | type Repr = rowan::SyntaxNode<RaTypes>; | 1624 | type Repr = rowan::SyntaxNode; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | impl AstNode for LifetimeParam { | 1627 | impl AstNode for LifetimeParam { |
@@ -1650,7 +1650,7 @@ pub struct Literal { | |||
1650 | pub(crate) syntax: SyntaxNode, | 1650 | pub(crate) syntax: SyntaxNode, |
1651 | } | 1651 | } |
1652 | unsafe impl TransparentNewType for Literal { | 1652 | unsafe impl TransparentNewType for Literal { |
1653 | type Repr = rowan::SyntaxNode<RaTypes>; | 1653 | type Repr = rowan::SyntaxNode; |
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | impl AstNode for Literal { | 1656 | impl AstNode for Literal { |
@@ -1678,7 +1678,7 @@ pub struct LiteralPat { | |||
1678 | pub(crate) syntax: SyntaxNode, | 1678 | pub(crate) syntax: SyntaxNode, |
1679 | } | 1679 | } |
1680 | unsafe impl TransparentNewType for LiteralPat { | 1680 | unsafe impl TransparentNewType for LiteralPat { |
1681 | type Repr = rowan::SyntaxNode<RaTypes>; | 1681 | type Repr = rowan::SyntaxNode; |
1682 | } | 1682 | } |
1683 | 1683 | ||
1684 | impl AstNode for LiteralPat { | 1684 | impl AstNode for LiteralPat { |
@@ -1710,7 +1710,7 @@ pub struct LoopExpr { | |||
1710 | pub(crate) syntax: SyntaxNode, | 1710 | pub(crate) syntax: SyntaxNode, |
1711 | } | 1711 | } |
1712 | unsafe impl TransparentNewType for LoopExpr { | 1712 | unsafe impl TransparentNewType for LoopExpr { |
1713 | type Repr = rowan::SyntaxNode<RaTypes>; | 1713 | type Repr = rowan::SyntaxNode; |
1714 | } | 1714 | } |
1715 | 1715 | ||
1716 | impl AstNode for LoopExpr { | 1716 | impl AstNode for LoopExpr { |
@@ -1739,7 +1739,7 @@ pub struct MacroCall { | |||
1739 | pub(crate) syntax: SyntaxNode, | 1739 | pub(crate) syntax: SyntaxNode, |
1740 | } | 1740 | } |
1741 | unsafe impl TransparentNewType for MacroCall { | 1741 | unsafe impl TransparentNewType for MacroCall { |
1742 | type Repr = rowan::SyntaxNode<RaTypes>; | 1742 | type Repr = rowan::SyntaxNode; |
1743 | } | 1743 | } |
1744 | 1744 | ||
1745 | impl AstNode for MacroCall { | 1745 | impl AstNode for MacroCall { |
@@ -1777,7 +1777,7 @@ pub struct MatchArm { | |||
1777 | pub(crate) syntax: SyntaxNode, | 1777 | pub(crate) syntax: SyntaxNode, |
1778 | } | 1778 | } |
1779 | unsafe impl TransparentNewType for MatchArm { | 1779 | unsafe impl TransparentNewType for MatchArm { |
1780 | type Repr = rowan::SyntaxNode<RaTypes>; | 1780 | type Repr = rowan::SyntaxNode; |
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | impl AstNode for MatchArm { | 1783 | impl AstNode for MatchArm { |
@@ -1818,7 +1818,7 @@ pub struct MatchArmList { | |||
1818 | pub(crate) syntax: SyntaxNode, | 1818 | pub(crate) syntax: SyntaxNode, |
1819 | } | 1819 | } |
1820 | unsafe impl TransparentNewType for MatchArmList { | 1820 | unsafe impl TransparentNewType for MatchArmList { |
1821 | type Repr = rowan::SyntaxNode<RaTypes>; | 1821 | type Repr = rowan::SyntaxNode; |
1822 | } | 1822 | } |
1823 | 1823 | ||
1824 | impl AstNode for MatchArmList { | 1824 | impl AstNode for MatchArmList { |
@@ -1851,7 +1851,7 @@ pub struct MatchExpr { | |||
1851 | pub(crate) syntax: SyntaxNode, | 1851 | pub(crate) syntax: SyntaxNode, |
1852 | } | 1852 | } |
1853 | unsafe impl TransparentNewType for MatchExpr { | 1853 | unsafe impl TransparentNewType for MatchExpr { |
1854 | type Repr = rowan::SyntaxNode<RaTypes>; | 1854 | type Repr = rowan::SyntaxNode; |
1855 | } | 1855 | } |
1856 | 1856 | ||
1857 | impl AstNode for MatchExpr { | 1857 | impl AstNode for MatchExpr { |
@@ -1887,7 +1887,7 @@ pub struct MatchGuard { | |||
1887 | pub(crate) syntax: SyntaxNode, | 1887 | pub(crate) syntax: SyntaxNode, |
1888 | } | 1888 | } |
1889 | unsafe impl TransparentNewType for MatchGuard { | 1889 | unsafe impl TransparentNewType for MatchGuard { |
1890 | type Repr = rowan::SyntaxNode<RaTypes>; | 1890 | type Repr = rowan::SyntaxNode; |
1891 | } | 1891 | } |
1892 | 1892 | ||
1893 | impl AstNode for MatchGuard { | 1893 | impl AstNode for MatchGuard { |
@@ -1919,7 +1919,7 @@ pub struct MethodCallExpr { | |||
1919 | pub(crate) syntax: SyntaxNode, | 1919 | pub(crate) syntax: SyntaxNode, |
1920 | } | 1920 | } |
1921 | unsafe impl TransparentNewType for MethodCallExpr { | 1921 | unsafe impl TransparentNewType for MethodCallExpr { |
1922 | type Repr = rowan::SyntaxNode<RaTypes>; | 1922 | type Repr = rowan::SyntaxNode; |
1923 | } | 1923 | } |
1924 | 1924 | ||
1925 | impl AstNode for MethodCallExpr { | 1925 | impl AstNode for MethodCallExpr { |
@@ -1960,7 +1960,7 @@ pub struct Module { | |||
1960 | pub(crate) syntax: SyntaxNode, | 1960 | pub(crate) syntax: SyntaxNode, |
1961 | } | 1961 | } |
1962 | unsafe impl TransparentNewType for Module { | 1962 | unsafe impl TransparentNewType for Module { |
1963 | type Repr = rowan::SyntaxNode<RaTypes>; | 1963 | type Repr = rowan::SyntaxNode; |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | impl AstNode for Module { | 1966 | impl AstNode for Module { |
@@ -1996,7 +1996,7 @@ pub struct ModuleItem { | |||
1996 | pub(crate) syntax: SyntaxNode, | 1996 | pub(crate) syntax: SyntaxNode, |
1997 | } | 1997 | } |
1998 | unsafe impl TransparentNewType for ModuleItem { | 1998 | unsafe 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 | } |
2125 | unsafe impl TransparentNewType for Name { | 2125 | unsafe impl TransparentNewType for Name { |
2126 | type Repr = rowan::SyntaxNode<RaTypes>; | 2126 | type Repr = rowan::SyntaxNode; |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | impl AstNode for Name { | 2129 | impl AstNode for Name { |
@@ -2151,7 +2151,7 @@ pub struct NameRef { | |||
2151 | pub(crate) syntax: SyntaxNode, | 2151 | pub(crate) syntax: SyntaxNode, |
2152 | } | 2152 | } |
2153 | unsafe impl TransparentNewType for NameRef { | 2153 | unsafe impl TransparentNewType for NameRef { |
2154 | type Repr = rowan::SyntaxNode<RaTypes>; | 2154 | type Repr = rowan::SyntaxNode; |
2155 | } | 2155 | } |
2156 | 2156 | ||
2157 | impl AstNode for NameRef { | 2157 | impl AstNode for NameRef { |
@@ -2179,7 +2179,7 @@ pub struct NamedField { | |||
2179 | pub(crate) syntax: SyntaxNode, | 2179 | pub(crate) syntax: SyntaxNode, |
2180 | } | 2180 | } |
2181 | unsafe impl TransparentNewType for NamedField { | 2181 | unsafe impl TransparentNewType for NamedField { |
2182 | type Repr = rowan::SyntaxNode<RaTypes>; | 2182 | type Repr = rowan::SyntaxNode; |
2183 | } | 2183 | } |
2184 | 2184 | ||
2185 | impl AstNode for NamedField { | 2185 | impl AstNode for NamedField { |
@@ -2215,7 +2215,7 @@ pub struct NamedFieldDef { | |||
2215 | pub(crate) syntax: SyntaxNode, | 2215 | pub(crate) syntax: SyntaxNode, |
2216 | } | 2216 | } |
2217 | unsafe impl TransparentNewType for NamedFieldDef { | 2217 | unsafe impl TransparentNewType for NamedFieldDef { |
2218 | type Repr = rowan::SyntaxNode<RaTypes>; | 2218 | type Repr = rowan::SyntaxNode; |
2219 | } | 2219 | } |
2220 | 2220 | ||
2221 | impl AstNode for NamedFieldDef { | 2221 | impl AstNode for NamedFieldDef { |
@@ -2248,7 +2248,7 @@ pub struct NamedFieldDefList { | |||
2248 | pub(crate) syntax: SyntaxNode, | 2248 | pub(crate) syntax: SyntaxNode, |
2249 | } | 2249 | } |
2250 | unsafe impl TransparentNewType for NamedFieldDefList { | 2250 | unsafe impl TransparentNewType for NamedFieldDefList { |
2251 | type Repr = rowan::SyntaxNode<RaTypes>; | 2251 | type Repr = rowan::SyntaxNode; |
2252 | } | 2252 | } |
2253 | 2253 | ||
2254 | impl AstNode for NamedFieldDefList { | 2254 | impl AstNode for NamedFieldDefList { |
@@ -2280,7 +2280,7 @@ pub struct NamedFieldList { | |||
2280 | pub(crate) syntax: SyntaxNode, | 2280 | pub(crate) syntax: SyntaxNode, |
2281 | } | 2281 | } |
2282 | unsafe impl TransparentNewType for NamedFieldList { | 2282 | unsafe impl TransparentNewType for NamedFieldList { |
2283 | type Repr = rowan::SyntaxNode<RaTypes>; | 2283 | type Repr = rowan::SyntaxNode; |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | impl AstNode for NamedFieldList { | 2286 | impl AstNode for NamedFieldList { |
@@ -2312,7 +2312,7 @@ pub struct NeverType { | |||
2312 | pub(crate) syntax: SyntaxNode, | 2312 | pub(crate) syntax: SyntaxNode, |
2313 | } | 2313 | } |
2314 | unsafe impl TransparentNewType for NeverType { | 2314 | unsafe impl TransparentNewType for NeverType { |
2315 | type Repr = rowan::SyntaxNode<RaTypes>; | 2315 | type Repr = rowan::SyntaxNode; |
2316 | } | 2316 | } |
2317 | 2317 | ||
2318 | impl AstNode for NeverType { | 2318 | impl AstNode for NeverType { |
@@ -2340,7 +2340,7 @@ pub struct NominalDef { | |||
2340 | pub(crate) syntax: SyntaxNode, | 2340 | pub(crate) syntax: SyntaxNode, |
2341 | } | 2341 | } |
2342 | unsafe impl TransparentNewType for NominalDef { | 2342 | unsafe 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 | } |
2400 | unsafe impl TransparentNewType for Param { | 2400 | unsafe impl TransparentNewType for Param { |
2401 | type Repr = rowan::SyntaxNode<RaTypes>; | 2401 | type Repr = rowan::SyntaxNode; |
2402 | } | 2402 | } |
2403 | 2403 | ||
2404 | impl AstNode for Param { | 2404 | impl AstNode for Param { |
@@ -2431,7 +2431,7 @@ pub struct ParamList { | |||
2431 | pub(crate) syntax: SyntaxNode, | 2431 | pub(crate) syntax: SyntaxNode, |
2432 | } | 2432 | } |
2433 | unsafe impl TransparentNewType for ParamList { | 2433 | unsafe impl TransparentNewType for ParamList { |
2434 | type Repr = rowan::SyntaxNode<RaTypes>; | 2434 | type Repr = rowan::SyntaxNode; |
2435 | } | 2435 | } |
2436 | 2436 | ||
2437 | impl AstNode for ParamList { | 2437 | impl AstNode for ParamList { |
@@ -2467,7 +2467,7 @@ pub struct ParenExpr { | |||
2467 | pub(crate) syntax: SyntaxNode, | 2467 | pub(crate) syntax: SyntaxNode, |
2468 | } | 2468 | } |
2469 | unsafe impl TransparentNewType for ParenExpr { | 2469 | unsafe impl TransparentNewType for ParenExpr { |
2470 | type Repr = rowan::SyntaxNode<RaTypes>; | 2470 | type Repr = rowan::SyntaxNode; |
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | impl AstNode for ParenExpr { | 2473 | impl AstNode for ParenExpr { |
@@ -2499,7 +2499,7 @@ pub struct ParenType { | |||
2499 | pub(crate) syntax: SyntaxNode, | 2499 | pub(crate) syntax: SyntaxNode, |
2500 | } | 2500 | } |
2501 | unsafe impl TransparentNewType for ParenType { | 2501 | unsafe impl TransparentNewType for ParenType { |
2502 | type Repr = rowan::SyntaxNode<RaTypes>; | 2502 | type Repr = rowan::SyntaxNode; |
2503 | } | 2503 | } |
2504 | 2504 | ||
2505 | impl AstNode for ParenType { | 2505 | impl AstNode for ParenType { |
@@ -2531,7 +2531,7 @@ pub struct Pat { | |||
2531 | pub(crate) syntax: SyntaxNode, | 2531 | pub(crate) syntax: SyntaxNode, |
2532 | } | 2532 | } |
2533 | unsafe impl TransparentNewType for Pat { | 2533 | unsafe 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 | } |
2652 | unsafe impl TransparentNewType for Path { | 2652 | unsafe impl TransparentNewType for Path { |
2653 | type Repr = rowan::SyntaxNode<RaTypes>; | 2653 | type Repr = rowan::SyntaxNode; |
2654 | } | 2654 | } |
2655 | 2655 | ||
2656 | impl AstNode for Path { | 2656 | impl AstNode for Path { |
@@ -2686,7 +2686,7 @@ pub struct PathExpr { | |||
2686 | pub(crate) syntax: SyntaxNode, | 2686 | pub(crate) syntax: SyntaxNode, |
2687 | } | 2687 | } |
2688 | unsafe impl TransparentNewType for PathExpr { | 2688 | unsafe impl TransparentNewType for PathExpr { |
2689 | type Repr = rowan::SyntaxNode<RaTypes>; | 2689 | type Repr = rowan::SyntaxNode; |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | impl AstNode for PathExpr { | 2692 | impl AstNode for PathExpr { |
@@ -2718,7 +2718,7 @@ pub struct PathPat { | |||
2718 | pub(crate) syntax: SyntaxNode, | 2718 | pub(crate) syntax: SyntaxNode, |
2719 | } | 2719 | } |
2720 | unsafe impl TransparentNewType for PathPat { | 2720 | unsafe impl TransparentNewType for PathPat { |
2721 | type Repr = rowan::SyntaxNode<RaTypes>; | 2721 | type Repr = rowan::SyntaxNode; |
2722 | } | 2722 | } |
2723 | 2723 | ||
2724 | impl AstNode for PathPat { | 2724 | impl AstNode for PathPat { |
@@ -2750,7 +2750,7 @@ pub struct PathSegment { | |||
2750 | pub(crate) syntax: SyntaxNode, | 2750 | pub(crate) syntax: SyntaxNode, |
2751 | } | 2751 | } |
2752 | unsafe impl TransparentNewType for PathSegment { | 2752 | unsafe impl TransparentNewType for PathSegment { |
2753 | type Repr = rowan::SyntaxNode<RaTypes>; | 2753 | type Repr = rowan::SyntaxNode; |
2754 | } | 2754 | } |
2755 | 2755 | ||
2756 | impl AstNode for PathSegment { | 2756 | impl AstNode for PathSegment { |
@@ -2786,7 +2786,7 @@ pub struct PathType { | |||
2786 | pub(crate) syntax: SyntaxNode, | 2786 | pub(crate) syntax: SyntaxNode, |
2787 | } | 2787 | } |
2788 | unsafe impl TransparentNewType for PathType { | 2788 | unsafe impl TransparentNewType for PathType { |
2789 | type Repr = rowan::SyntaxNode<RaTypes>; | 2789 | type Repr = rowan::SyntaxNode; |
2790 | } | 2790 | } |
2791 | 2791 | ||
2792 | impl AstNode for PathType { | 2792 | impl AstNode for PathType { |
@@ -2818,7 +2818,7 @@ pub struct PlaceholderPat { | |||
2818 | pub(crate) syntax: SyntaxNode, | 2818 | pub(crate) syntax: SyntaxNode, |
2819 | } | 2819 | } |
2820 | unsafe impl TransparentNewType for PlaceholderPat { | 2820 | unsafe impl TransparentNewType for PlaceholderPat { |
2821 | type Repr = rowan::SyntaxNode<RaTypes>; | 2821 | type Repr = rowan::SyntaxNode; |
2822 | } | 2822 | } |
2823 | 2823 | ||
2824 | impl AstNode for PlaceholderPat { | 2824 | impl AstNode for PlaceholderPat { |
@@ -2846,7 +2846,7 @@ pub struct PlaceholderType { | |||
2846 | pub(crate) syntax: SyntaxNode, | 2846 | pub(crate) syntax: SyntaxNode, |
2847 | } | 2847 | } |
2848 | unsafe impl TransparentNewType for PlaceholderType { | 2848 | unsafe impl TransparentNewType for PlaceholderType { |
2849 | type Repr = rowan::SyntaxNode<RaTypes>; | 2849 | type Repr = rowan::SyntaxNode; |
2850 | } | 2850 | } |
2851 | 2851 | ||
2852 | impl AstNode for PlaceholderType { | 2852 | impl AstNode for PlaceholderType { |
@@ -2874,7 +2874,7 @@ pub struct PointerType { | |||
2874 | pub(crate) syntax: SyntaxNode, | 2874 | pub(crate) syntax: SyntaxNode, |
2875 | } | 2875 | } |
2876 | unsafe impl TransparentNewType for PointerType { | 2876 | unsafe impl TransparentNewType for PointerType { |
2877 | type Repr = rowan::SyntaxNode<RaTypes>; | 2877 | type Repr = rowan::SyntaxNode; |
2878 | } | 2878 | } |
2879 | 2879 | ||
2880 | impl AstNode for PointerType { | 2880 | impl AstNode for PointerType { |
@@ -2906,7 +2906,7 @@ pub struct PosFieldDef { | |||
2906 | pub(crate) syntax: SyntaxNode, | 2906 | pub(crate) syntax: SyntaxNode, |
2907 | } | 2907 | } |
2908 | unsafe impl TransparentNewType for PosFieldDef { | 2908 | unsafe impl TransparentNewType for PosFieldDef { |
2909 | type Repr = rowan::SyntaxNode<RaTypes>; | 2909 | type Repr = rowan::SyntaxNode; |
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | impl AstNode for PosFieldDef { | 2912 | impl AstNode for PosFieldDef { |
@@ -2940,7 +2940,7 @@ pub struct PosFieldDefList { | |||
2940 | pub(crate) syntax: SyntaxNode, | 2940 | pub(crate) syntax: SyntaxNode, |
2941 | } | 2941 | } |
2942 | unsafe impl TransparentNewType for PosFieldDefList { | 2942 | unsafe impl TransparentNewType for PosFieldDefList { |
2943 | type Repr = rowan::SyntaxNode<RaTypes>; | 2943 | type Repr = rowan::SyntaxNode; |
2944 | } | 2944 | } |
2945 | 2945 | ||
2946 | impl AstNode for PosFieldDefList { | 2946 | impl AstNode for PosFieldDefList { |
@@ -2972,7 +2972,7 @@ pub struct PrefixExpr { | |||
2972 | pub(crate) syntax: SyntaxNode, | 2972 | pub(crate) syntax: SyntaxNode, |
2973 | } | 2973 | } |
2974 | unsafe impl TransparentNewType for PrefixExpr { | 2974 | unsafe impl TransparentNewType for PrefixExpr { |
2975 | type Repr = rowan::SyntaxNode<RaTypes>; | 2975 | type Repr = rowan::SyntaxNode; |
2976 | } | 2976 | } |
2977 | 2977 | ||
2978 | impl AstNode for PrefixExpr { | 2978 | impl AstNode for PrefixExpr { |
@@ -3004,7 +3004,7 @@ pub struct RangeExpr { | |||
3004 | pub(crate) syntax: SyntaxNode, | 3004 | pub(crate) syntax: SyntaxNode, |
3005 | } | 3005 | } |
3006 | unsafe impl TransparentNewType for RangeExpr { | 3006 | unsafe impl TransparentNewType for RangeExpr { |
3007 | type Repr = rowan::SyntaxNode<RaTypes>; | 3007 | type Repr = rowan::SyntaxNode; |
3008 | } | 3008 | } |
3009 | 3009 | ||
3010 | impl AstNode for RangeExpr { | 3010 | impl AstNode for RangeExpr { |
@@ -3032,7 +3032,7 @@ pub struct RangePat { | |||
3032 | pub(crate) syntax: SyntaxNode, | 3032 | pub(crate) syntax: SyntaxNode, |
3033 | } | 3033 | } |
3034 | unsafe impl TransparentNewType for RangePat { | 3034 | unsafe impl TransparentNewType for RangePat { |
3035 | type Repr = rowan::SyntaxNode<RaTypes>; | 3035 | type Repr = rowan::SyntaxNode; |
3036 | } | 3036 | } |
3037 | 3037 | ||
3038 | impl AstNode for RangePat { | 3038 | impl AstNode for RangePat { |
@@ -3060,7 +3060,7 @@ pub struct RefExpr { | |||
3060 | pub(crate) syntax: SyntaxNode, | 3060 | pub(crate) syntax: SyntaxNode, |
3061 | } | 3061 | } |
3062 | unsafe impl TransparentNewType for RefExpr { | 3062 | unsafe impl TransparentNewType for RefExpr { |
3063 | type Repr = rowan::SyntaxNode<RaTypes>; | 3063 | type Repr = rowan::SyntaxNode; |
3064 | } | 3064 | } |
3065 | 3065 | ||
3066 | impl AstNode for RefExpr { | 3066 | impl AstNode for RefExpr { |
@@ -3092,7 +3092,7 @@ pub struct RefPat { | |||
3092 | pub(crate) syntax: SyntaxNode, | 3092 | pub(crate) syntax: SyntaxNode, |
3093 | } | 3093 | } |
3094 | unsafe impl TransparentNewType for RefPat { | 3094 | unsafe impl TransparentNewType for RefPat { |
3095 | type Repr = rowan::SyntaxNode<RaTypes>; | 3095 | type Repr = rowan::SyntaxNode; |
3096 | } | 3096 | } |
3097 | 3097 | ||
3098 | impl AstNode for RefPat { | 3098 | impl AstNode for RefPat { |
@@ -3124,7 +3124,7 @@ pub struct ReferenceType { | |||
3124 | pub(crate) syntax: SyntaxNode, | 3124 | pub(crate) syntax: SyntaxNode, |
3125 | } | 3125 | } |
3126 | unsafe impl TransparentNewType for ReferenceType { | 3126 | unsafe impl TransparentNewType for ReferenceType { |
3127 | type Repr = rowan::SyntaxNode<RaTypes>; | 3127 | type Repr = rowan::SyntaxNode; |
3128 | } | 3128 | } |
3129 | 3129 | ||
3130 | impl AstNode for ReferenceType { | 3130 | impl AstNode for ReferenceType { |
@@ -3156,7 +3156,7 @@ pub struct RetType { | |||
3156 | pub(crate) syntax: SyntaxNode, | 3156 | pub(crate) syntax: SyntaxNode, |
3157 | } | 3157 | } |
3158 | unsafe impl TransparentNewType for RetType { | 3158 | unsafe impl TransparentNewType for RetType { |
3159 | type Repr = rowan::SyntaxNode<RaTypes>; | 3159 | type Repr = rowan::SyntaxNode; |
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | impl AstNode for RetType { | 3162 | impl AstNode for RetType { |
@@ -3188,7 +3188,7 @@ pub struct ReturnExpr { | |||
3188 | pub(crate) syntax: SyntaxNode, | 3188 | pub(crate) syntax: SyntaxNode, |
3189 | } | 3189 | } |
3190 | unsafe impl TransparentNewType for ReturnExpr { | 3190 | unsafe impl TransparentNewType for ReturnExpr { |
3191 | type Repr = rowan::SyntaxNode<RaTypes>; | 3191 | type Repr = rowan::SyntaxNode; |
3192 | } | 3192 | } |
3193 | 3193 | ||
3194 | impl AstNode for ReturnExpr { | 3194 | impl AstNode for ReturnExpr { |
@@ -3220,7 +3220,7 @@ pub struct SelfParam { | |||
3220 | pub(crate) syntax: SyntaxNode, | 3220 | pub(crate) syntax: SyntaxNode, |
3221 | } | 3221 | } |
3222 | unsafe impl TransparentNewType for SelfParam { | 3222 | unsafe impl TransparentNewType for SelfParam { |
3223 | type Repr = rowan::SyntaxNode<RaTypes>; | 3223 | type Repr = rowan::SyntaxNode; |
3224 | } | 3224 | } |
3225 | 3225 | ||
3226 | impl AstNode for SelfParam { | 3226 | impl AstNode for SelfParam { |
@@ -3249,7 +3249,7 @@ pub struct SlicePat { | |||
3249 | pub(crate) syntax: SyntaxNode, | 3249 | pub(crate) syntax: SyntaxNode, |
3250 | } | 3250 | } |
3251 | unsafe impl TransparentNewType for SlicePat { | 3251 | unsafe impl TransparentNewType for SlicePat { |
3252 | type Repr = rowan::SyntaxNode<RaTypes>; | 3252 | type Repr = rowan::SyntaxNode; |
3253 | } | 3253 | } |
3254 | 3254 | ||
3255 | impl AstNode for SlicePat { | 3255 | impl AstNode for SlicePat { |
@@ -3277,7 +3277,7 @@ pub struct SliceType { | |||
3277 | pub(crate) syntax: SyntaxNode, | 3277 | pub(crate) syntax: SyntaxNode, |
3278 | } | 3278 | } |
3279 | unsafe impl TransparentNewType for SliceType { | 3279 | unsafe impl TransparentNewType for SliceType { |
3280 | type Repr = rowan::SyntaxNode<RaTypes>; | 3280 | type Repr = rowan::SyntaxNode; |
3281 | } | 3281 | } |
3282 | 3282 | ||
3283 | impl AstNode for SliceType { | 3283 | impl AstNode for SliceType { |
@@ -3309,7 +3309,7 @@ pub struct SourceFile { | |||
3309 | pub(crate) syntax: SyntaxNode, | 3309 | pub(crate) syntax: SyntaxNode, |
3310 | } | 3310 | } |
3311 | unsafe impl TransparentNewType for SourceFile { | 3311 | unsafe impl TransparentNewType for SourceFile { |
3312 | type Repr = rowan::SyntaxNode<RaTypes>; | 3312 | type Repr = rowan::SyntaxNode; |
3313 | } | 3313 | } |
3314 | 3314 | ||
3315 | impl AstNode for SourceFile { | 3315 | impl AstNode for SourceFile { |
@@ -3343,7 +3343,7 @@ pub struct StaticDef { | |||
3343 | pub(crate) syntax: SyntaxNode, | 3343 | pub(crate) syntax: SyntaxNode, |
3344 | } | 3344 | } |
3345 | unsafe impl TransparentNewType for StaticDef { | 3345 | unsafe impl TransparentNewType for StaticDef { |
3346 | type Repr = rowan::SyntaxNode<RaTypes>; | 3346 | type Repr = rowan::SyntaxNode; |
3347 | } | 3347 | } |
3348 | 3348 | ||
3349 | impl AstNode for StaticDef { | 3349 | impl AstNode for StaticDef { |
@@ -3381,7 +3381,7 @@ pub struct Stmt { | |||
3381 | pub(crate) syntax: SyntaxNode, | 3381 | pub(crate) syntax: SyntaxNode, |
3382 | } | 3382 | } |
3383 | unsafe impl TransparentNewType for Stmt { | 3383 | unsafe 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 | } |
3438 | unsafe impl TransparentNewType for StructDef { | 3438 | unsafe impl TransparentNewType for StructDef { |
3439 | type Repr = rowan::SyntaxNode<RaTypes>; | 3439 | type Repr = rowan::SyntaxNode; |
3440 | } | 3440 | } |
3441 | 3441 | ||
3442 | impl AstNode for StructDef { | 3442 | impl AstNode for StructDef { |
@@ -3469,7 +3469,7 @@ pub struct StructLit { | |||
3469 | pub(crate) syntax: SyntaxNode, | 3469 | pub(crate) syntax: SyntaxNode, |
3470 | } | 3470 | } |
3471 | unsafe impl TransparentNewType for StructLit { | 3471 | unsafe impl TransparentNewType for StructLit { |
3472 | type Repr = rowan::SyntaxNode<RaTypes>; | 3472 | type Repr = rowan::SyntaxNode; |
3473 | } | 3473 | } |
3474 | 3474 | ||
3475 | impl AstNode for StructLit { | 3475 | impl AstNode for StructLit { |
@@ -3509,7 +3509,7 @@ pub struct StructPat { | |||
3509 | pub(crate) syntax: SyntaxNode, | 3509 | pub(crate) syntax: SyntaxNode, |
3510 | } | 3510 | } |
3511 | unsafe impl TransparentNewType for StructPat { | 3511 | unsafe impl TransparentNewType for StructPat { |
3512 | type Repr = rowan::SyntaxNode<RaTypes>; | 3512 | type Repr = rowan::SyntaxNode; |
3513 | } | 3513 | } |
3514 | 3514 | ||
3515 | impl AstNode for StructPat { | 3515 | impl AstNode for StructPat { |
@@ -3545,7 +3545,7 @@ pub struct TokenTree { | |||
3545 | pub(crate) syntax: SyntaxNode, | 3545 | pub(crate) syntax: SyntaxNode, |
3546 | } | 3546 | } |
3547 | unsafe impl TransparentNewType for TokenTree { | 3547 | unsafe impl TransparentNewType for TokenTree { |
3548 | type Repr = rowan::SyntaxNode<RaTypes>; | 3548 | type Repr = rowan::SyntaxNode; |
3549 | } | 3549 | } |
3550 | 3550 | ||
3551 | impl AstNode for TokenTree { | 3551 | impl AstNode for TokenTree { |
@@ -3573,7 +3573,7 @@ pub struct TraitDef { | |||
3573 | pub(crate) syntax: SyntaxNode, | 3573 | pub(crate) syntax: SyntaxNode, |
3574 | } | 3574 | } |
3575 | unsafe impl TransparentNewType for TraitDef { | 3575 | unsafe impl TransparentNewType for TraitDef { |
3576 | type Repr = rowan::SyntaxNode<RaTypes>; | 3576 | type Repr = rowan::SyntaxNode; |
3577 | } | 3577 | } |
3578 | 3578 | ||
3579 | impl AstNode for TraitDef { | 3579 | impl AstNode for TraitDef { |
@@ -3611,7 +3611,7 @@ pub struct TryExpr { | |||
3611 | pub(crate) syntax: SyntaxNode, | 3611 | pub(crate) syntax: SyntaxNode, |
3612 | } | 3612 | } |
3613 | unsafe impl TransparentNewType for TryExpr { | 3613 | unsafe impl TransparentNewType for TryExpr { |
3614 | type Repr = rowan::SyntaxNode<RaTypes>; | 3614 | type Repr = rowan::SyntaxNode; |
3615 | } | 3615 | } |
3616 | 3616 | ||
3617 | impl AstNode for TryExpr { | 3617 | impl AstNode for TryExpr { |
@@ -3643,7 +3643,7 @@ pub struct TupleExpr { | |||
3643 | pub(crate) syntax: SyntaxNode, | 3643 | pub(crate) syntax: SyntaxNode, |
3644 | } | 3644 | } |
3645 | unsafe impl TransparentNewType for TupleExpr { | 3645 | unsafe impl TransparentNewType for TupleExpr { |
3646 | type Repr = rowan::SyntaxNode<RaTypes>; | 3646 | type Repr = rowan::SyntaxNode; |
3647 | } | 3647 | } |
3648 | 3648 | ||
3649 | impl AstNode for TupleExpr { | 3649 | impl AstNode for TupleExpr { |
@@ -3675,7 +3675,7 @@ pub struct TuplePat { | |||
3675 | pub(crate) syntax: SyntaxNode, | 3675 | pub(crate) syntax: SyntaxNode, |
3676 | } | 3676 | } |
3677 | unsafe impl TransparentNewType for TuplePat { | 3677 | unsafe impl TransparentNewType for TuplePat { |
3678 | type Repr = rowan::SyntaxNode<RaTypes>; | 3678 | type Repr = rowan::SyntaxNode; |
3679 | } | 3679 | } |
3680 | 3680 | ||
3681 | impl AstNode for TuplePat { | 3681 | impl AstNode for TuplePat { |
@@ -3707,7 +3707,7 @@ pub struct TupleStructPat { | |||
3707 | pub(crate) syntax: SyntaxNode, | 3707 | pub(crate) syntax: SyntaxNode, |
3708 | } | 3708 | } |
3709 | unsafe impl TransparentNewType for TupleStructPat { | 3709 | unsafe impl TransparentNewType for TupleStructPat { |
3710 | type Repr = rowan::SyntaxNode<RaTypes>; | 3710 | type Repr = rowan::SyntaxNode; |
3711 | } | 3711 | } |
3712 | 3712 | ||
3713 | impl AstNode for TupleStructPat { | 3713 | impl AstNode for TupleStructPat { |
@@ -3743,7 +3743,7 @@ pub struct TupleType { | |||
3743 | pub(crate) syntax: SyntaxNode, | 3743 | pub(crate) syntax: SyntaxNode, |
3744 | } | 3744 | } |
3745 | unsafe impl TransparentNewType for TupleType { | 3745 | unsafe impl TransparentNewType for TupleType { |
3746 | type Repr = rowan::SyntaxNode<RaTypes>; | 3746 | type Repr = rowan::SyntaxNode; |
3747 | } | 3747 | } |
3748 | 3748 | ||
3749 | impl AstNode for TupleType { | 3749 | impl AstNode for TupleType { |
@@ -3775,7 +3775,7 @@ pub struct TypeAliasDef { | |||
3775 | pub(crate) syntax: SyntaxNode, | 3775 | pub(crate) syntax: SyntaxNode, |
3776 | } | 3776 | } |
3777 | unsafe impl TransparentNewType for TypeAliasDef { | 3777 | unsafe impl TransparentNewType for TypeAliasDef { |
3778 | type Repr = rowan::SyntaxNode<RaTypes>; | 3778 | type Repr = rowan::SyntaxNode; |
3779 | } | 3779 | } |
3780 | 3780 | ||
3781 | impl AstNode for TypeAliasDef { | 3781 | impl AstNode for TypeAliasDef { |
@@ -3813,7 +3813,7 @@ pub struct TypeArg { | |||
3813 | pub(crate) syntax: SyntaxNode, | 3813 | pub(crate) syntax: SyntaxNode, |
3814 | } | 3814 | } |
3815 | unsafe impl TransparentNewType for TypeArg { | 3815 | unsafe impl TransparentNewType for TypeArg { |
3816 | type Repr = rowan::SyntaxNode<RaTypes>; | 3816 | type Repr = rowan::SyntaxNode; |
3817 | } | 3817 | } |
3818 | 3818 | ||
3819 | impl AstNode for TypeArg { | 3819 | impl AstNode for TypeArg { |
@@ -3845,7 +3845,7 @@ pub struct TypeArgList { | |||
3845 | pub(crate) syntax: SyntaxNode, | 3845 | pub(crate) syntax: SyntaxNode, |
3846 | } | 3846 | } |
3847 | unsafe impl TransparentNewType for TypeArgList { | 3847 | unsafe impl TransparentNewType for TypeArgList { |
3848 | type Repr = rowan::SyntaxNode<RaTypes>; | 3848 | type Repr = rowan::SyntaxNode; |
3849 | } | 3849 | } |
3850 | 3850 | ||
3851 | impl AstNode for TypeArgList { | 3851 | impl AstNode for TypeArgList { |
@@ -3885,7 +3885,7 @@ pub struct TypeBound { | |||
3885 | pub(crate) syntax: SyntaxNode, | 3885 | pub(crate) syntax: SyntaxNode, |
3886 | } | 3886 | } |
3887 | unsafe impl TransparentNewType for TypeBound { | 3887 | unsafe impl TransparentNewType for TypeBound { |
3888 | type Repr = rowan::SyntaxNode<RaTypes>; | 3888 | type Repr = rowan::SyntaxNode; |
3889 | } | 3889 | } |
3890 | 3890 | ||
3891 | impl AstNode for TypeBound { | 3891 | impl AstNode for TypeBound { |
@@ -3917,7 +3917,7 @@ pub struct TypeBoundList { | |||
3917 | pub(crate) syntax: SyntaxNode, | 3917 | pub(crate) syntax: SyntaxNode, |
3918 | } | 3918 | } |
3919 | unsafe impl TransparentNewType for TypeBoundList { | 3919 | unsafe impl TransparentNewType for TypeBoundList { |
3920 | type Repr = rowan::SyntaxNode<RaTypes>; | 3920 | type Repr = rowan::SyntaxNode; |
3921 | } | 3921 | } |
3922 | 3922 | ||
3923 | impl AstNode for TypeBoundList { | 3923 | impl AstNode for TypeBoundList { |
@@ -3949,7 +3949,7 @@ pub struct TypeParam { | |||
3949 | pub(crate) syntax: SyntaxNode, | 3949 | pub(crate) syntax: SyntaxNode, |
3950 | } | 3950 | } |
3951 | unsafe impl TransparentNewType for TypeParam { | 3951 | unsafe impl TransparentNewType for TypeParam { |
3952 | type Repr = rowan::SyntaxNode<RaTypes>; | 3952 | type Repr = rowan::SyntaxNode; |
3953 | } | 3953 | } |
3954 | 3954 | ||
3955 | impl AstNode for TypeParam { | 3955 | impl AstNode for TypeParam { |
@@ -3980,7 +3980,7 @@ pub struct TypeParamList { | |||
3980 | pub(crate) syntax: SyntaxNode, | 3980 | pub(crate) syntax: SyntaxNode, |
3981 | } | 3981 | } |
3982 | unsafe impl TransparentNewType for TypeParamList { | 3982 | unsafe impl TransparentNewType for TypeParamList { |
3983 | type Repr = rowan::SyntaxNode<RaTypes>; | 3983 | type Repr = rowan::SyntaxNode; |
3984 | } | 3984 | } |
3985 | 3985 | ||
3986 | impl AstNode for TypeParamList { | 3986 | impl AstNode for TypeParamList { |
@@ -4016,7 +4016,7 @@ pub struct TypeRef { | |||
4016 | pub(crate) syntax: SyntaxNode, | 4016 | pub(crate) syntax: SyntaxNode, |
4017 | } | 4017 | } |
4018 | unsafe impl TransparentNewType for TypeRef { | 4018 | unsafe 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 | } |
4161 | unsafe impl TransparentNewType for UseItem { | 4161 | unsafe impl TransparentNewType for UseItem { |
4162 | type Repr = rowan::SyntaxNode<RaTypes>; | 4162 | type Repr = rowan::SyntaxNode; |
4163 | } | 4163 | } |
4164 | 4164 | ||
4165 | impl AstNode for UseItem { | 4165 | impl AstNode for UseItem { |
@@ -4192,7 +4192,7 @@ pub struct UseTree { | |||
4192 | pub(crate) syntax: SyntaxNode, | 4192 | pub(crate) syntax: SyntaxNode, |
4193 | } | 4193 | } |
4194 | unsafe impl TransparentNewType for UseTree { | 4194 | unsafe impl TransparentNewType for UseTree { |
4195 | type Repr = rowan::SyntaxNode<RaTypes>; | 4195 | type Repr = rowan::SyntaxNode; |
4196 | } | 4196 | } |
4197 | 4197 | ||
4198 | impl AstNode for UseTree { | 4198 | impl AstNode for UseTree { |
@@ -4232,7 +4232,7 @@ pub struct UseTreeList { | |||
4232 | pub(crate) syntax: SyntaxNode, | 4232 | pub(crate) syntax: SyntaxNode, |
4233 | } | 4233 | } |
4234 | unsafe impl TransparentNewType for UseTreeList { | 4234 | unsafe impl TransparentNewType for UseTreeList { |
4235 | type Repr = rowan::SyntaxNode<RaTypes>; | 4235 | type Repr = rowan::SyntaxNode; |
4236 | } | 4236 | } |
4237 | 4237 | ||
4238 | impl AstNode for UseTreeList { | 4238 | impl AstNode for UseTreeList { |
@@ -4264,7 +4264,7 @@ pub struct Visibility { | |||
4264 | pub(crate) syntax: SyntaxNode, | 4264 | pub(crate) syntax: SyntaxNode, |
4265 | } | 4265 | } |
4266 | unsafe impl TransparentNewType for Visibility { | 4266 | unsafe impl TransparentNewType for Visibility { |
4267 | type Repr = rowan::SyntaxNode<RaTypes>; | 4267 | type Repr = rowan::SyntaxNode; |
4268 | } | 4268 | } |
4269 | 4269 | ||
4270 | impl AstNode for Visibility { | 4270 | impl AstNode for Visibility { |
@@ -4292,7 +4292,7 @@ pub struct WhereClause { | |||
4292 | pub(crate) syntax: SyntaxNode, | 4292 | pub(crate) syntax: SyntaxNode, |
4293 | } | 4293 | } |
4294 | unsafe impl TransparentNewType for WhereClause { | 4294 | unsafe impl TransparentNewType for WhereClause { |
4295 | type Repr = rowan::SyntaxNode<RaTypes>; | 4295 | type Repr = rowan::SyntaxNode; |
4296 | } | 4296 | } |
4297 | 4297 | ||
4298 | impl AstNode for WhereClause { | 4298 | impl AstNode for WhereClause { |
@@ -4324,7 +4324,7 @@ pub struct WherePred { | |||
4324 | pub(crate) syntax: SyntaxNode, | 4324 | pub(crate) syntax: SyntaxNode, |
4325 | } | 4325 | } |
4326 | unsafe impl TransparentNewType for WherePred { | 4326 | unsafe impl TransparentNewType for WherePred { |
4327 | type Repr = rowan::SyntaxNode<RaTypes>; | 4327 | type Repr = rowan::SyntaxNode; |
4328 | } | 4328 | } |
4329 | 4329 | ||
4330 | impl AstNode for WherePred { | 4330 | impl AstNode for WherePred { |
@@ -4357,7 +4357,7 @@ pub struct WhileExpr { | |||
4357 | pub(crate) syntax: SyntaxNode, | 4357 | pub(crate) syntax: SyntaxNode, |
4358 | } | 4358 | } |
4359 | unsafe impl TransparentNewType for WhileExpr { | 4359 | unsafe impl TransparentNewType for WhileExpr { |
4360 | type Repr = rowan::SyntaxNode<RaTypes>; | 4360 | type Repr = rowan::SyntaxNode; |
4361 | } | 4361 | } |
4362 | 4362 | ||
4363 | impl AstNode for WhileExpr { | 4363 | impl 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 | ||
16 | use crate::{ | 16 | use 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 | } |
30 | unsafe impl TransparentNewType for {{ node }} { | 30 | unsafe 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 | } |
83 | unsafe impl TransparentNewType for {{ node }} { | 83 | unsafe impl TransparentNewType for {{ node }} { |
84 | type Repr = rowan::SyntaxNode<RaTypes>; | 84 | type Repr = rowan::SyntaxNode; |
85 | } | 85 | } |
86 | 86 | ||
87 | impl AstNode for {{ node }} { | 87 | impl 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 | ||
9 | use std::{ | 9 | use std::{ |
10 | fmt::{self, Write}, | 10 | fmt::{self, Write}, |
11 | any::Any, | ||
11 | borrow::Borrow, | 12 | borrow::Borrow, |
12 | }; | 13 | }; |
13 | 14 | ||
14 | use ra_parser::ParseError; | 15 | use ra_parser::ParseError; |
15 | use rowan::{Types, TransparentNewType, GreenNodeBuilder}; | 16 | use rowan::{TransparentNewType, GreenNodeBuilder}; |
16 | 17 | ||
17 | use crate::{ | 18 | use 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 | ||
22 | pub use rowan::WalkEvent; | 23 | pub use rowan::WalkEvent; |
23 | 24 | pub(crate) use rowan::{GreenNode, GreenToken}; | |
24 | #[derive(Debug, Clone, Copy)] | ||
25 | pub enum RaTypes {} | ||
26 | impl Types for RaTypes { | ||
27 | type Kind = SyntaxKind; | ||
28 | type RootData = Vec<SyntaxError>; | ||
29 | } | ||
30 | |||
31 | pub(crate) type GreenNode = rowan::GreenNode<RaTypes>; | ||
32 | pub(crate) type GreenToken = rowan::GreenToken<RaTypes>; | ||
33 | #[allow(unused)] | ||
34 | pub(crate) type GreenElement = rowan::GreenElement<RaTypes>; | ||
35 | 25 | ||
36 | /// Marker trait for CST and AST nodes | 26 | /// Marker trait for CST and AST nodes |
37 | pub trait SyntaxNodeWrapper: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> {} | 27 | pub trait SyntaxNodeWrapper: TransparentNewType<Repr = rowan::SyntaxNode> {} |
38 | impl<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>> SyntaxNodeWrapper for T {} | 28 | impl<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)] |
42 | pub struct TreeArc<T: SyntaxNodeWrapper>(pub(crate) rowan::TreeArc<RaTypes, T>); | 32 | pub struct TreeArc<T: SyntaxNodeWrapper>(pub(crate) rowan::TreeArc<T>); |
43 | 33 | ||
44 | impl<T: SyntaxNodeWrapper> Borrow<T> for TreeArc<T> { | 34 | impl<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)] |
104 | pub struct SyntaxNode(pub(crate) rowan::SyntaxNode<RaTypes>); | 94 | pub struct SyntaxNode(pub(crate) rowan::SyntaxNode); |
105 | unsafe impl TransparentNewType for SyntaxNode { | 95 | unsafe impl TransparentNewType for SyntaxNode { |
106 | type Repr = rowan::SyntaxNode<RaTypes>; | 96 | type Repr = rowan::SyntaxNode; |
107 | } | 97 | } |
108 | 98 | ||
109 | impl ToOwned for SyntaxNode { | 99 | impl ToOwned for SyntaxNode { |
@@ -134,12 +124,14 @@ pub enum Direction { | |||
134 | 124 | ||
135 | impl SyntaxNode { | 125 | impl 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)] |
316 | pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a, RaTypes>); | 314 | pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a>); |
317 | 315 | ||
318 | //FIXME: always output text | 316 | //FIXME: always output text |
319 | impl<'a> fmt::Debug for SyntaxToken<'a> { | 317 | impl<'a> fmt::Debug for SyntaxToken<'a> { |
@@ -339,15 +337,15 @@ impl<'a> fmt::Display for SyntaxToken<'a> { | |||
339 | } | 337 | } |
340 | } | 338 | } |
341 | 339 | ||
342 | impl<'a> From<rowan::SyntaxToken<'a, RaTypes>> for SyntaxToken<'a> { | 340 | impl<'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 | ||
348 | impl<'a> SyntaxToken<'a> { | 346 | impl<'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 | ||
457 | impl<'a> From<rowan::SyntaxElement<'a, RaTypes>> for SyntaxElement<'a> { | 455 | impl<'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)] |
488 | pub struct SyntaxNodeChildren<'a>(rowan::SyntaxNodeChildren<'a, RaTypes>); | 486 | pub struct SyntaxNodeChildren<'a>(rowan::SyntaxNodeChildren<'a>); |
489 | 487 | ||
490 | impl<'a> Iterator for SyntaxNodeChildren<'a> { | 488 | impl<'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)] |
499 | pub struct SyntaxElementChildren<'a>(rowan::SyntaxElementChildren<'a, RaTypes>); | 497 | pub struct SyntaxElementChildren<'a>(rowan::SyntaxElementChildren<'a>); |
500 | 498 | ||
501 | impl<'a> Iterator for SyntaxElementChildren<'a> { | 499 | impl<'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 | ||
509 | pub struct SyntaxTreeBuilder { | 507 | pub struct SyntaxTreeBuilder { |
510 | errors: Vec<SyntaxError>, | 508 | errors: Vec<SyntaxError>, |
511 | inner: GreenNodeBuilder<RaTypes>, | 509 | inner: GreenNodeBuilder, |
512 | } | 510 | } |
513 | 511 | ||
514 | impl Default for SyntaxTreeBuilder { | 512 | impl 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) { |