diff options
71 files changed, 4076 insertions, 2583 deletions
diff --git a/Cargo.lock b/Cargo.lock index d8838cf2b..b73fb909c 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -168,9 +168,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | |||
168 | 168 | ||
169 | [[package]] | 169 | [[package]] |
170 | name = "chalk-derive" | 170 | name = "chalk-derive" |
171 | version = "0.37.0" | 171 | version = "0.43.0" |
172 | source = "registry+https://github.com/rust-lang/crates.io-index" | 172 | source = "registry+https://github.com/rust-lang/crates.io-index" |
173 | checksum = "564b529b0d620da43dc7ea46fa95b5c602e783e1870aeb07e8cbb6d7ff71bee6" | 173 | checksum = "e2d9e0c8adcced1ab0fea5cb8a38647922893d5b495e363e1814299fd380469b" |
174 | dependencies = [ | 174 | dependencies = [ |
175 | "proc-macro2", | 175 | "proc-macro2", |
176 | "quote", | 176 | "quote", |
@@ -180,9 +180,9 @@ dependencies = [ | |||
180 | 180 | ||
181 | [[package]] | 181 | [[package]] |
182 | name = "chalk-ir" | 182 | name = "chalk-ir" |
183 | version = "0.37.0" | 183 | version = "0.43.0" |
184 | source = "registry+https://github.com/rust-lang/crates.io-index" | 184 | source = "registry+https://github.com/rust-lang/crates.io-index" |
185 | checksum = "e67d29482387f4cbed6d8f1b1f7d24f00ff10612c700c65fe4af220df11e4d24" | 185 | checksum = "c5218266a5709bc4943de997e64d3fab41c9e9f68efd54a898de53135e987bd3" |
186 | dependencies = [ | 186 | dependencies = [ |
187 | "chalk-derive", | 187 | "chalk-derive", |
188 | "lazy_static", | 188 | "lazy_static", |
@@ -190,9 +190,9 @@ dependencies = [ | |||
190 | 190 | ||
191 | [[package]] | 191 | [[package]] |
192 | name = "chalk-recursive" | 192 | name = "chalk-recursive" |
193 | version = "0.37.0" | 193 | version = "0.43.0" |
194 | source = "registry+https://github.com/rust-lang/crates.io-index" | 194 | source = "registry+https://github.com/rust-lang/crates.io-index" |
195 | checksum = "5c52032be6fbdf91b6a7df3cafba3a6683fdabeff88e7ab73eea96e28657d973" | 195 | checksum = "ed8f34f13fd4f30251f9f6f1dc56f80363201390ecbcac2fdfc8e33036cd9c4a" |
196 | dependencies = [ | 196 | dependencies = [ |
197 | "chalk-derive", | 197 | "chalk-derive", |
198 | "chalk-ir", | 198 | "chalk-ir", |
@@ -203,9 +203,9 @@ dependencies = [ | |||
203 | 203 | ||
204 | [[package]] | 204 | [[package]] |
205 | name = "chalk-solve" | 205 | name = "chalk-solve" |
206 | version = "0.37.0" | 206 | version = "0.43.0" |
207 | source = "registry+https://github.com/rust-lang/crates.io-index" | 207 | source = "registry+https://github.com/rust-lang/crates.io-index" |
208 | checksum = "e0378bdfe1547b6fd545f518373b08c1e0c14920f7555a62d049021250a2b89b" | 208 | checksum = "379c9f584488346044709d4c638c38d61a06fe593d4de2ac5f15fd2b0ba4cd9d" |
209 | dependencies = [ | 209 | dependencies = [ |
210 | "chalk-derive", | 210 | "chalk-derive", |
211 | "chalk-ir", | 211 | "chalk-ir", |
@@ -802,9 +802,9 @@ checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" | |||
802 | 802 | ||
803 | [[package]] | 803 | [[package]] |
804 | name = "libloading" | 804 | name = "libloading" |
805 | version = "0.6.5" | 805 | version = "0.6.6" |
806 | source = "registry+https://github.com/rust-lang/crates.io-index" | 806 | source = "registry+https://github.com/rust-lang/crates.io-index" |
807 | checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" | 807 | checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" |
808 | dependencies = [ | 808 | dependencies = [ |
809 | "cfg-if 1.0.0", | 809 | "cfg-if 1.0.0", |
810 | "winapi 0.3.9", | 810 | "winapi 0.3.9", |
@@ -956,9 +956,9 @@ dependencies = [ | |||
956 | 956 | ||
957 | [[package]] | 957 | [[package]] |
958 | name = "mio" | 958 | name = "mio" |
959 | version = "0.6.22" | 959 | version = "0.6.23" |
960 | source = "registry+https://github.com/rust-lang/crates.io-index" | 960 | source = "registry+https://github.com/rust-lang/crates.io-index" |
961 | checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" | 961 | checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" |
962 | dependencies = [ | 962 | dependencies = [ |
963 | "cfg-if 0.1.10", | 963 | "cfg-if 0.1.10", |
964 | "fuchsia-zircon", | 964 | "fuchsia-zircon", |
@@ -1187,6 +1187,7 @@ dependencies = [ | |||
1187 | name = "proc_macro_api" | 1187 | name = "proc_macro_api" |
1188 | version = "0.0.0" | 1188 | version = "0.0.0" |
1189 | dependencies = [ | 1189 | dependencies = [ |
1190 | "base_db", | ||
1190 | "crossbeam-channel 0.5.0", | 1191 | "crossbeam-channel 0.5.0", |
1191 | "jod-thread", | 1192 | "jod-thread", |
1192 | "log", | 1193 | "log", |
@@ -1555,9 +1556,9 @@ dependencies = [ | |||
1555 | 1556 | ||
1556 | [[package]] | 1557 | [[package]] |
1557 | name = "serde_json" | 1558 | name = "serde_json" |
1558 | version = "1.0.59" | 1559 | version = "1.0.60" |
1559 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1560 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1560 | checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" | 1561 | checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" |
1561 | dependencies = [ | 1562 | dependencies = [ |
1562 | "itoa", | 1563 | "itoa", |
1563 | "ryu", | 1564 | "ryu", |
diff --git a/crates/assists/src/handlers/early_return.rs b/crates/assists/src/handlers/early_return.rs index 7fd78e9d4..7bcc318a9 100644 --- a/crates/assists/src/handlers/early_return.rs +++ b/crates/assists/src/handlers/early_return.rs | |||
@@ -112,7 +112,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) | |||
112 | let then_branch = | 112 | let then_branch = |
113 | make::block_expr(once(make::expr_stmt(early_expression).into()), None); | 113 | make::block_expr(once(make::expr_stmt(early_expression).into()), None); |
114 | let cond = invert_boolean_expression(cond_expr); | 114 | let cond = invert_boolean_expression(cond_expr); |
115 | make::expr_if(make::condition(cond, None), then_branch) | 115 | make::expr_if(make::condition(cond, None), then_branch, None) |
116 | .indent(if_indent_level) | 116 | .indent(if_indent_level) |
117 | }; | 117 | }; |
118 | replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) | 118 | replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) |
diff --git a/crates/assists/src/handlers/move_guard.rs b/crates/assists/src/handlers/move_guard.rs index e1855b63d..eaffd80ce 100644 --- a/crates/assists/src/handlers/move_guard.rs +++ b/crates/assists/src/handlers/move_guard.rs | |||
@@ -42,6 +42,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> | |||
42 | let if_expr = make::expr_if( | 42 | let if_expr = make::expr_if( |
43 | make::condition(guard_condition, None), | 43 | make::condition(guard_condition, None), |
44 | make::block_expr(None, Some(arm_expr.clone())), | 44 | make::block_expr(None, Some(arm_expr.clone())), |
45 | None, | ||
45 | ) | 46 | ) |
46 | .indent(arm_expr.indent_level()); | 47 | .indent(arm_expr.indent_level()); |
47 | 48 | ||
diff --git a/crates/assists/src/handlers/replace_if_let_with_match.rs b/crates/assists/src/handlers/replace_if_let_with_match.rs index 9a49c48c1..4a355c66f 100644 --- a/crates/assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/assists/src/handlers/replace_if_let_with_match.rs | |||
@@ -1,3 +1,6 @@ | |||
1 | use std::iter; | ||
2 | |||
3 | use ide_db::{ty_filter::TryEnum, RootDatabase}; | ||
1 | use syntax::{ | 4 | use syntax::{ |
2 | ast::{ | 5 | ast::{ |
3 | self, | 6 | self, |
@@ -8,7 +11,6 @@ use syntax::{ | |||
8 | }; | 11 | }; |
9 | 12 | ||
10 | use crate::{utils::unwrap_trivial_block, AssistContext, AssistId, AssistKind, Assists}; | 13 | use crate::{utils::unwrap_trivial_block, AssistContext, AssistId, AssistKind, Assists}; |
11 | use ide_db::ty_filter::TryEnum; | ||
12 | 14 | ||
13 | // Assist: replace_if_let_with_match | 15 | // Assist: replace_if_let_with_match |
14 | // | 16 | // |
@@ -79,6 +81,91 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext) | |||
79 | ) | 81 | ) |
80 | } | 82 | } |
81 | 83 | ||
84 | // Assist: replace_match_with_if_let | ||
85 | // | ||
86 | // Replaces a binary `match` with a wildcard pattern and no guards with an `if let` expression. | ||
87 | // | ||
88 | // ``` | ||
89 | // enum Action { Move { distance: u32 }, Stop } | ||
90 | // | ||
91 | // fn handle(action: Action) { | ||
92 | // <|>match action { | ||
93 | // Action::Move { distance } => foo(distance), | ||
94 | // _ => bar(), | ||
95 | // } | ||
96 | // } | ||
97 | // ``` | ||
98 | // -> | ||
99 | // ``` | ||
100 | // enum Action { Move { distance: u32 }, Stop } | ||
101 | // | ||
102 | // fn handle(action: Action) { | ||
103 | // if let Action::Move { distance } = action { | ||
104 | // foo(distance) | ||
105 | // } else { | ||
106 | // bar() | ||
107 | // } | ||
108 | // } | ||
109 | // ``` | ||
110 | pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | ||
111 | let match_expr: ast::MatchExpr = ctx.find_node_at_offset()?; | ||
112 | let mut arms = match_expr.match_arm_list()?.arms(); | ||
113 | let first_arm = arms.next()?; | ||
114 | let second_arm = arms.next()?; | ||
115 | if arms.next().is_some() || first_arm.guard().is_some() || second_arm.guard().is_some() { | ||
116 | return None; | ||
117 | } | ||
118 | let condition_expr = match_expr.expr()?; | ||
119 | let (if_let_pat, then_expr, else_expr) = if is_pat_wildcard_or_sad(&ctx.sema, &first_arm.pat()?) | ||
120 | { | ||
121 | (second_arm.pat()?, second_arm.expr()?, first_arm.expr()?) | ||
122 | } else if is_pat_wildcard_or_sad(&ctx.sema, &second_arm.pat()?) { | ||
123 | (first_arm.pat()?, first_arm.expr()?, second_arm.expr()?) | ||
124 | } else { | ||
125 | return None; | ||
126 | }; | ||
127 | |||
128 | let target = match_expr.syntax().text_range(); | ||
129 | acc.add( | ||
130 | AssistId("replace_match_with_if_let", AssistKind::RefactorRewrite), | ||
131 | "Replace with if let", | ||
132 | target, | ||
133 | move |edit| { | ||
134 | let condition = make::condition(condition_expr, Some(if_let_pat)); | ||
135 | let then_block = match then_expr.reset_indent() { | ||
136 | ast::Expr::BlockExpr(block) => block, | ||
137 | expr => make::block_expr(iter::empty(), Some(expr)), | ||
138 | }; | ||
139 | let else_expr = match else_expr { | ||
140 | ast::Expr::BlockExpr(block) | ||
141 | if block.statements().count() == 0 && block.expr().is_none() => | ||
142 | { | ||
143 | None | ||
144 | } | ||
145 | ast::Expr::TupleExpr(tuple) if tuple.fields().count() == 0 => None, | ||
146 | expr => Some(expr), | ||
147 | }; | ||
148 | let if_let_expr = make::expr_if( | ||
149 | condition, | ||
150 | then_block, | ||
151 | else_expr.map(|else_expr| { | ||
152 | ast::ElseBranch::Block(make::block_expr(iter::empty(), Some(else_expr))) | ||
153 | }), | ||
154 | ) | ||
155 | .indent(IndentLevel::from_node(match_expr.syntax())); | ||
156 | |||
157 | edit.replace_ast::<ast::Expr>(match_expr.into(), if_let_expr); | ||
158 | }, | ||
159 | ) | ||
160 | } | ||
161 | |||
162 | fn is_pat_wildcard_or_sad(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool { | ||
163 | sema.type_of_pat(&pat) | ||
164 | .and_then(|ty| TryEnum::from_ty(sema, &ty)) | ||
165 | .map(|it| it.sad_pattern().syntax().text() == pat.syntax().text()) | ||
166 | .unwrap_or_else(|| matches!(pat, ast::Pat::WildcardPat(_))) | ||
167 | } | ||
168 | |||
82 | #[cfg(test)] | 169 | #[cfg(test)] |
83 | mod tests { | 170 | mod tests { |
84 | use super::*; | 171 | use super::*; |
@@ -252,4 +339,192 @@ fn main() { | |||
252 | "#, | 339 | "#, |
253 | ) | 340 | ) |
254 | } | 341 | } |
342 | |||
343 | #[test] | ||
344 | fn test_replace_match_with_if_let_unwraps_simple_expressions() { | ||
345 | check_assist( | ||
346 | replace_match_with_if_let, | ||
347 | r#" | ||
348 | impl VariantData { | ||
349 | pub fn is_struct(&self) -> bool { | ||
350 | <|>match *self { | ||
351 | VariantData::Struct(..) => true, | ||
352 | _ => false, | ||
353 | } | ||
354 | } | ||
355 | } "#, | ||
356 | r#" | ||
357 | impl VariantData { | ||
358 | pub fn is_struct(&self) -> bool { | ||
359 | if let VariantData::Struct(..) = *self { | ||
360 | true | ||
361 | } else { | ||
362 | false | ||
363 | } | ||
364 | } | ||
365 | } "#, | ||
366 | ) | ||
367 | } | ||
368 | |||
369 | #[test] | ||
370 | fn test_replace_match_with_if_let_doesnt_unwrap_multiline_expressions() { | ||
371 | check_assist( | ||
372 | replace_match_with_if_let, | ||
373 | r#" | ||
374 | fn foo() { | ||
375 | <|>match a { | ||
376 | VariantData::Struct(..) => { | ||
377 | bar( | ||
378 | 123 | ||
379 | ) | ||
380 | } | ||
381 | _ => false, | ||
382 | } | ||
383 | } "#, | ||
384 | r#" | ||
385 | fn foo() { | ||
386 | if let VariantData::Struct(..) = a { | ||
387 | bar( | ||
388 | 123 | ||
389 | ) | ||
390 | } else { | ||
391 | false | ||
392 | } | ||
393 | } "#, | ||
394 | ) | ||
395 | } | ||
396 | |||
397 | #[test] | ||
398 | fn replace_match_with_if_let_target() { | ||
399 | check_assist_target( | ||
400 | replace_match_with_if_let, | ||
401 | r#" | ||
402 | impl VariantData { | ||
403 | pub fn is_struct(&self) -> bool { | ||
404 | <|>match *self { | ||
405 | VariantData::Struct(..) => true, | ||
406 | _ => false, | ||
407 | } | ||
408 | } | ||
409 | } "#, | ||
410 | r#"match *self { | ||
411 | VariantData::Struct(..) => true, | ||
412 | _ => false, | ||
413 | }"#, | ||
414 | ); | ||
415 | } | ||
416 | |||
417 | #[test] | ||
418 | fn special_case_option_match_to_if_let() { | ||
419 | check_assist( | ||
420 | replace_match_with_if_let, | ||
421 | r#" | ||
422 | enum Option<T> { Some(T), None } | ||
423 | use Option::*; | ||
424 | |||
425 | fn foo(x: Option<i32>) { | ||
426 | <|>match x { | ||
427 | Some(x) => println!("{}", x), | ||
428 | None => println!("none"), | ||
429 | } | ||
430 | } | ||
431 | "#, | ||
432 | r#" | ||
433 | enum Option<T> { Some(T), None } | ||
434 | use Option::*; | ||
435 | |||
436 | fn foo(x: Option<i32>) { | ||
437 | if let Some(x) = x { | ||
438 | println!("{}", x) | ||
439 | } else { | ||
440 | println!("none") | ||
441 | } | ||
442 | } | ||
443 | "#, | ||
444 | ); | ||
445 | } | ||
446 | |||
447 | #[test] | ||
448 | fn special_case_result_match_to_if_let() { | ||
449 | check_assist( | ||
450 | replace_match_with_if_let, | ||
451 | r#" | ||
452 | enum Result<T, E> { Ok(T), Err(E) } | ||
453 | use Result::*; | ||
454 | |||
455 | fn foo(x: Result<i32, ()>) { | ||
456 | <|>match x { | ||
457 | Ok(x) => println!("{}", x), | ||
458 | Err(_) => println!("none"), | ||
459 | } | ||
460 | } | ||
461 | "#, | ||
462 | r#" | ||
463 | enum Result<T, E> { Ok(T), Err(E) } | ||
464 | use Result::*; | ||
465 | |||
466 | fn foo(x: Result<i32, ()>) { | ||
467 | if let Ok(x) = x { | ||
468 | println!("{}", x) | ||
469 | } else { | ||
470 | println!("none") | ||
471 | } | ||
472 | } | ||
473 | "#, | ||
474 | ); | ||
475 | } | ||
476 | |||
477 | #[test] | ||
478 | fn nested_indent_match_to_if_let() { | ||
479 | check_assist( | ||
480 | replace_match_with_if_let, | ||
481 | r#" | ||
482 | fn main() { | ||
483 | if true { | ||
484 | <|>match path.strip_prefix(root_path) { | ||
485 | Ok(rel_path) => { | ||
486 | let rel_path = RelativePathBuf::from_path(rel_path).ok()?; | ||
487 | Some((*id, rel_path)) | ||
488 | } | ||
489 | _ => None, | ||
490 | } | ||
491 | } | ||
492 | } | ||
493 | "#, | ||
494 | r#" | ||
495 | fn main() { | ||
496 | if true { | ||
497 | if let Ok(rel_path) = path.strip_prefix(root_path) { | ||
498 | let rel_path = RelativePathBuf::from_path(rel_path).ok()?; | ||
499 | Some((*id, rel_path)) | ||
500 | } else { | ||
501 | None | ||
502 | } | ||
503 | } | ||
504 | } | ||
505 | "#, | ||
506 | ) | ||
507 | } | ||
508 | |||
509 | #[test] | ||
510 | fn replace_match_with_if_let_empty_wildcard_expr() { | ||
511 | check_assist( | ||
512 | replace_match_with_if_let, | ||
513 | r#" | ||
514 | fn main() { | ||
515 | <|>match path.strip_prefix(root_path) { | ||
516 | Ok(rel_path) => println!("{}", rel_path), | ||
517 | _ => (), | ||
518 | } | ||
519 | } | ||
520 | "#, | ||
521 | r#" | ||
522 | fn main() { | ||
523 | if let Ok(rel_path) = path.strip_prefix(root_path) { | ||
524 | println!("{}", rel_path) | ||
525 | } | ||
526 | } | ||
527 | "#, | ||
528 | ) | ||
529 | } | ||
255 | } | 530 | } |
diff --git a/crates/assists/src/handlers/replace_let_with_if_let.rs b/crates/assists/src/handlers/replace_let_with_if_let.rs index 69d3b08d3..5970e283c 100644 --- a/crates/assists/src/handlers/replace_let_with_if_let.rs +++ b/crates/assists/src/handlers/replace_let_with_if_let.rs | |||
@@ -60,7 +60,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) -> | |||
60 | }; | 60 | }; |
61 | let block = | 61 | let block = |
62 | make::block_expr(None, None).indent(IndentLevel::from_node(let_stmt.syntax())); | 62 | make::block_expr(None, None).indent(IndentLevel::from_node(let_stmt.syntax())); |
63 | let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block); | 63 | let if_ = make::expr_if(make::condition(init, Some(with_placeholder)), block, None); |
64 | let stmt = make::expr_stmt(if_); | 64 | let stmt = make::expr_stmt(if_); |
65 | 65 | ||
66 | let placeholder = stmt.syntax().descendants().find_map(ast::WildcardPat::cast).unwrap(); | 66 | let placeholder = stmt.syntax().descendants().find_map(ast::WildcardPat::cast).unwrap(); |
diff --git a/crates/assists/src/lib.rs b/crates/assists/src/lib.rs index dfe6c2729..b8ce7418d 100644 --- a/crates/assists/src/lib.rs +++ b/crates/assists/src/lib.rs | |||
@@ -209,6 +209,7 @@ mod handlers { | |||
209 | reorder_fields::reorder_fields, | 209 | reorder_fields::reorder_fields, |
210 | replace_derive_with_manual_impl::replace_derive_with_manual_impl, | 210 | replace_derive_with_manual_impl::replace_derive_with_manual_impl, |
211 | replace_if_let_with_match::replace_if_let_with_match, | 211 | replace_if_let_with_match::replace_if_let_with_match, |
212 | replace_if_let_with_match::replace_match_with_if_let, | ||
212 | replace_impl_trait_with_generic::replace_impl_trait_with_generic, | 213 | replace_impl_trait_with_generic::replace_impl_trait_with_generic, |
213 | replace_let_with_if_let::replace_let_with_if_let, | 214 | replace_let_with_if_let::replace_let_with_if_let, |
214 | replace_qualified_name_with_use::replace_qualified_name_with_use, | 215 | replace_qualified_name_with_use::replace_qualified_name_with_use, |
diff --git a/crates/assists/src/tests/generated.rs b/crates/assists/src/tests/generated.rs index 8d50c8791..853bde09c 100644 --- a/crates/assists/src/tests/generated.rs +++ b/crates/assists/src/tests/generated.rs | |||
@@ -890,6 +890,34 @@ fn compute() -> Option<i32> { None } | |||
890 | } | 890 | } |
891 | 891 | ||
892 | #[test] | 892 | #[test] |
893 | fn doctest_replace_match_with_if_let() { | ||
894 | check_doc_test( | ||
895 | "replace_match_with_if_let", | ||
896 | r#####" | ||
897 | enum Action { Move { distance: u32 }, Stop } | ||
898 | |||
899 | fn handle(action: Action) { | ||
900 | <|>match action { | ||
901 | Action::Move { distance } => foo(distance), | ||
902 | _ => bar(), | ||
903 | } | ||
904 | } | ||
905 | "#####, | ||
906 | r#####" | ||
907 | enum Action { Move { distance: u32 }, Stop } | ||
908 | |||
909 | fn handle(action: Action) { | ||
910 | if let Action::Move { distance } = action { | ||
911 | foo(distance) | ||
912 | } else { | ||
913 | bar() | ||
914 | } | ||
915 | } | ||
916 | "#####, | ||
917 | ) | ||
918 | } | ||
919 | |||
920 | #[test] | ||
893 | fn doctest_replace_qualified_name_with_use() { | 921 | fn doctest_replace_qualified_name_with_use() { |
894 | check_doc_test( | 922 | check_doc_test( |
895 | "replace_qualified_name_with_use", | 923 | "replace_qualified_name_with_use", |
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 98ba372ad..cda5e57dc 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs | |||
@@ -143,9 +143,17 @@ impl CrateDisplayName { | |||
143 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 143 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
144 | pub struct ProcMacroId(pub u32); | 144 | pub struct ProcMacroId(pub u32); |
145 | 145 | ||
146 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | ||
147 | pub enum ProcMacroKind { | ||
148 | CustomDerive, | ||
149 | FuncLike, | ||
150 | Attr, | ||
151 | } | ||
152 | |||
146 | #[derive(Debug, Clone)] | 153 | #[derive(Debug, Clone)] |
147 | pub struct ProcMacro { | 154 | pub struct ProcMacro { |
148 | pub name: SmolStr, | 155 | pub name: SmolStr, |
156 | pub kind: ProcMacroKind, | ||
149 | pub expander: Arc<dyn TokenExpander>, | 157 | pub expander: Arc<dyn TokenExpander>, |
150 | } | 158 | } |
151 | 159 | ||
@@ -198,11 +206,8 @@ impl CrateGraph { | |||
198 | display_name: Option<CrateDisplayName>, | 206 | display_name: Option<CrateDisplayName>, |
199 | cfg_options: CfgOptions, | 207 | cfg_options: CfgOptions, |
200 | env: Env, | 208 | env: Env, |
201 | proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>, | 209 | proc_macro: Vec<ProcMacro>, |
202 | ) -> CrateId { | 210 | ) -> CrateId { |
203 | let proc_macro = | ||
204 | proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect(); | ||
205 | |||
206 | let data = CrateData { | 211 | let data = CrateData { |
207 | root_file_id: file_id, | 212 | root_file_id: file_id, |
208 | edition, | 213 | edition, |
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index ce75a5337..5571af495 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -14,7 +14,7 @@ pub use crate::{ | |||
14 | change::Change, | 14 | change::Change, |
15 | input::{ | 15 | input::{ |
16 | CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, | 16 | CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, |
17 | ProcMacroId, SourceRoot, SourceRootId, | 17 | ProcMacro, ProcMacroId, ProcMacroKind, SourceRoot, SourceRootId, |
18 | }, | 18 | }, |
19 | }; | 19 | }; |
20 | pub use salsa; | 20 | pub use salsa; |
diff --git a/crates/completion/src/completions/attribute.rs b/crates/completion/src/completions/attribute.rs index f3d669458..5404145d5 100644 --- a/crates/completion/src/completions/attribute.rs +++ b/crates/completion/src/completions/attribute.rs | |||
@@ -87,13 +87,23 @@ const fn attr( | |||
87 | AttrCompletion { label, lookup, snippet, prefer_inner: false } | 87 | AttrCompletion { label, lookup, snippet, prefer_inner: false } |
88 | } | 88 | } |
89 | 89 | ||
90 | /// https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index | ||
90 | const ATTRIBUTES: &[AttrCompletion] = &[ | 91 | const ATTRIBUTES: &[AttrCompletion] = &[ |
91 | attr("allow(…)", Some("allow"), Some("allow(${0:lint})")), | 92 | attr("allow(…)", Some("allow"), Some("allow(${0:lint})")), |
93 | attr("automatically_derived", None, None), | ||
92 | attr("cfg_attr(…)", Some("cfg_attr"), Some("cfg_attr(${1:predicate}, ${0:attr})")), | 94 | attr("cfg_attr(…)", Some("cfg_attr"), Some("cfg_attr(${1:predicate}, ${0:attr})")), |
93 | attr("cfg(…)", Some("cfg"), Some("cfg(${0:predicate})")), | 95 | attr("cfg(…)", Some("cfg"), Some("cfg(${0:predicate})")), |
96 | attr("cold", None, None), | ||
97 | attr(r#"crate_name = """#, Some("crate_name"), Some(r#"crate_name = "${0:crate_name}""#)) | ||
98 | .prefer_inner(), | ||
94 | attr("deny(…)", Some("deny"), Some("deny(${0:lint})")), | 99 | attr("deny(…)", Some("deny"), Some("deny(${0:lint})")), |
95 | attr(r#"deprecated = "…""#, Some("deprecated"), Some(r#"deprecated = "${0:reason}""#)), | 100 | attr(r#"deprecated = "…""#, Some("deprecated"), Some(r#"deprecated = "${0:reason}""#)), |
96 | attr("derive(…)", Some("derive"), Some(r#"derive(${0:Debug})"#)), | 101 | attr("derive(…)", Some("derive"), Some(r#"derive(${0:Debug})"#)), |
102 | attr( | ||
103 | r#"export_name = "…""#, | ||
104 | Some("export_name"), | ||
105 | Some(r#"export_name = "${0:exported_symbol_name}""#), | ||
106 | ), | ||
97 | attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)), | 107 | attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)), |
98 | attr("feature(…)", Some("feature"), Some("feature(${0:flag})")).prefer_inner(), | 108 | attr("feature(…)", Some("feature"), Some("feature(${0:flag})")).prefer_inner(), |
99 | attr("forbid(…)", Some("forbid"), Some("forbid(${0:lint})")), | 109 | attr("forbid(…)", Some("forbid"), Some("forbid(${0:lint})")), |
@@ -101,16 +111,24 @@ const ATTRIBUTES: &[AttrCompletion] = &[ | |||
101 | attr("global_allocator", None, None).prefer_inner(), | 111 | attr("global_allocator", None, None).prefer_inner(), |
102 | attr(r#"ignore = "…""#, Some("ignore"), Some(r#"ignore = "${0:reason}""#)), | 112 | attr(r#"ignore = "…""#, Some("ignore"), Some(r#"ignore = "${0:reason}""#)), |
103 | attr("inline(…)", Some("inline"), Some("inline(${0:lint})")), | 113 | attr("inline(…)", Some("inline"), Some("inline(${0:lint})")), |
104 | attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)), | ||
105 | attr("link", None, None), | 114 | attr("link", None, None), |
115 | attr(r#"link_name = "…""#, Some("link_name"), Some(r#"link_name = "${0:symbol_name}""#)), | ||
116 | attr( | ||
117 | r#"link_section = "…""#, | ||
118 | Some("link_section"), | ||
119 | Some(r#"link_section = "${0:section_name}""#), | ||
120 | ), | ||
106 | attr("macro_export", None, None), | 121 | attr("macro_export", None, None), |
107 | attr("macro_use", None, None), | 122 | attr("macro_use", None, None), |
108 | attr(r#"must_use = "…""#, Some("must_use"), Some(r#"must_use = "${0:reason}""#)), | 123 | attr(r#"must_use = "…""#, Some("must_use"), Some(r#"must_use = "${0:reason}""#)), |
124 | attr("no_link", None, None).prefer_inner(), | ||
125 | attr("no_implicit_prelude", None, None).prefer_inner(), | ||
126 | attr("no_main", None, None).prefer_inner(), | ||
109 | attr("no_mangle", None, None), | 127 | attr("no_mangle", None, None), |
110 | attr("no_std", None, None).prefer_inner(), | 128 | attr("no_std", None, None).prefer_inner(), |
111 | attr("non_exhaustive", None, None), | 129 | attr("non_exhaustive", None, None), |
112 | attr("panic_handler", None, None).prefer_inner(), | 130 | attr("panic_handler", None, None).prefer_inner(), |
113 | attr("path = \"…\"", Some("path"), Some("path =\"${0:path}\"")), | 131 | attr(r#"path = "…""#, Some("path"), Some(r#"path ="${0:path}""#)), |
114 | attr("proc_macro", None, None), | 132 | attr("proc_macro", None, None), |
115 | attr("proc_macro_attribute", None, None), | 133 | attr("proc_macro_attribute", None, None), |
116 | attr("proc_macro_derive(…)", Some("proc_macro_derive"), Some("proc_macro_derive(${0:Trait})")), | 134 | attr("proc_macro_derive(…)", Some("proc_macro_derive"), Some("proc_macro_derive(${0:Trait})")), |
@@ -125,9 +143,12 @@ const ATTRIBUTES: &[AttrCompletion] = &[ | |||
125 | attr( | 143 | attr( |
126 | r#"target_feature = "…""#, | 144 | r#"target_feature = "…""#, |
127 | Some("target_feature"), | 145 | Some("target_feature"), |
128 | Some("target_feature = \"${0:feature}\""), | 146 | Some(r#"target_feature = "${0:feature}""#), |
129 | ), | 147 | ), |
130 | attr("test", None, None), | 148 | attr("test", None, None), |
149 | attr("track_caller", None, None), | ||
150 | attr("type_length_limit = …", Some("type_length_limit"), Some("type_length_limit = ${0:128}")) | ||
151 | .prefer_inner(), | ||
131 | attr("used", None, None), | 152 | attr("used", None, None), |
132 | attr("warn(…)", Some("warn"), Some("warn(${0:lint})")), | 153 | attr("warn(…)", Some("warn"), Some("warn(${0:lint})")), |
133 | attr( | 154 | attr( |
@@ -449,17 +470,21 @@ struct Test {} | |||
449 | r#"#[<|>]"#, | 470 | r#"#[<|>]"#, |
450 | expect![[r#" | 471 | expect![[r#" |
451 | at allow(…) | 472 | at allow(…) |
473 | at automatically_derived | ||
452 | at cfg(…) | 474 | at cfg(…) |
453 | at cfg_attr(…) | 475 | at cfg_attr(…) |
476 | at cold | ||
454 | at deny(…) | 477 | at deny(…) |
455 | at deprecated = "…" | 478 | at deprecated = "…" |
456 | at derive(…) | 479 | at derive(…) |
457 | at doc = "…" | 480 | at doc = "…" |
481 | at export_name = "…" | ||
458 | at forbid(…) | 482 | at forbid(…) |
459 | at ignore = "…" | 483 | at ignore = "…" |
460 | at inline(…) | 484 | at inline(…) |
461 | at link | 485 | at link |
462 | at link_name = "…" | 486 | at link_name = "…" |
487 | at link_section = "…" | ||
463 | at macro_export | 488 | at macro_export |
464 | at macro_use | 489 | at macro_use |
465 | at must_use = "…" | 490 | at must_use = "…" |
@@ -473,6 +498,7 @@ struct Test {} | |||
473 | at should_panic(…) | 498 | at should_panic(…) |
474 | at target_feature = "…" | 499 | at target_feature = "…" |
475 | at test | 500 | at test |
501 | at track_caller | ||
476 | at used | 502 | at used |
477 | at warn(…) | 503 | at warn(…) |
478 | "#]], | 504 | "#]], |
@@ -490,12 +516,16 @@ struct Test {} | |||
490 | r"#![<|>]", | 516 | r"#![<|>]", |
491 | expect![[r#" | 517 | expect![[r#" |
492 | at allow(…) | 518 | at allow(…) |
519 | at automatically_derived | ||
493 | at cfg(…) | 520 | at cfg(…) |
494 | at cfg_attr(…) | 521 | at cfg_attr(…) |
522 | at cold | ||
523 | at crate_name = "" | ||
495 | at deny(…) | 524 | at deny(…) |
496 | at deprecated = "…" | 525 | at deprecated = "…" |
497 | at derive(…) | 526 | at derive(…) |
498 | at doc = "…" | 527 | at doc = "…" |
528 | at export_name = "…" | ||
499 | at feature(…) | 529 | at feature(…) |
500 | at forbid(…) | 530 | at forbid(…) |
501 | at global_allocator | 531 | at global_allocator |
@@ -503,9 +533,13 @@ struct Test {} | |||
503 | at inline(…) | 533 | at inline(…) |
504 | at link | 534 | at link |
505 | at link_name = "…" | 535 | at link_name = "…" |
536 | at link_section = "…" | ||
506 | at macro_export | 537 | at macro_export |
507 | at macro_use | 538 | at macro_use |
508 | at must_use = "…" | 539 | at must_use = "…" |
540 | at no_implicit_prelude | ||
541 | at no_link | ||
542 | at no_main | ||
509 | at no_mangle | 543 | at no_mangle |
510 | at no_std | 544 | at no_std |
511 | at non_exhaustive | 545 | at non_exhaustive |
@@ -519,6 +553,8 @@ struct Test {} | |||
519 | at should_panic(…) | 553 | at should_panic(…) |
520 | at target_feature = "…" | 554 | at target_feature = "…" |
521 | at test | 555 | at test |
556 | at track_caller | ||
557 | at type_length_limit = … | ||
522 | at used | 558 | at used |
523 | at warn(…) | 559 | at warn(…) |
524 | at windows_subsystem = "…" | 560 | at windows_subsystem = "…" |
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 4500050f1..9a1e9ba49 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -362,7 +362,9 @@ impl Module { | |||
362 | } | 362 | } |
363 | 363 | ||
364 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { | 364 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { |
365 | let _p = profile::span("Module::diagnostics"); | 365 | let _p = profile::span("Module::diagnostics").detail(|| { |
366 | format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string())) | ||
367 | }); | ||
366 | let crate_def_map = db.crate_def_map(self.id.krate); | 368 | let crate_def_map = db.crate_def_map(self.id.krate); |
367 | crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); | 369 | crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); |
368 | for decl in self.declarations(db) { | 370 | for decl in self.declarations(db) { |
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 33eb5e78c..92bcc1705 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -120,18 +120,24 @@ impl Expander { | |||
120 | self.resolve_path_as_macro(db, &path) | 120 | self.resolve_path_as_macro(db, &path) |
121 | }; | 121 | }; |
122 | 122 | ||
123 | let call_id = match macro_call.as_call_id(db, self.crate_def_map.krate, resolver) { | 123 | let mut err = None; |
124 | let call_id = | ||
125 | macro_call.as_call_id_with_errors(db, self.crate_def_map.krate, resolver, &mut |e| { | ||
126 | err.get_or_insert(e); | ||
127 | }); | ||
128 | let call_id = match call_id { | ||
124 | Some(it) => it, | 129 | Some(it) => it, |
125 | None => { | 130 | None => { |
126 | // FIXME: this can mean other things too, but `as_call_id` doesn't provide enough | 131 | if err.is_none() { |
127 | // info. | 132 | eprintln!("no error despite `as_call_id_with_errors` returning `None`"); |
128 | return ExpandResult::only_err(mbe::ExpandError::Other( | 133 | } |
129 | "failed to parse or resolve macro invocation".into(), | 134 | return ExpandResult { value: None, err }; |
130 | )); | ||
131 | } | 135 | } |
132 | }; | 136 | }; |
133 | 137 | ||
134 | let err = db.macro_expand_error(call_id); | 138 | if err.is_none() { |
139 | err = db.macro_expand_error(call_id); | ||
140 | } | ||
135 | 141 | ||
136 | let file_id = call_id.as_file(); | 142 | let file_id = call_id.as_file(); |
137 | 143 | ||
diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index baf1179f1..6dba9817d 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs | |||
@@ -78,21 +78,41 @@ fn f() { | |||
78 | fn macro_diag_builtin() { | 78 | fn macro_diag_builtin() { |
79 | check_diagnostics( | 79 | check_diagnostics( |
80 | r#" | 80 | r#" |
81 | #[rustc_builtin_macro] | ||
82 | macro_rules! env {} | ||
83 | |||
84 | #[rustc_builtin_macro] | ||
85 | macro_rules! include {} | ||
86 | |||
87 | #[rustc_builtin_macro] | ||
88 | macro_rules! compile_error {} | ||
89 | |||
90 | #[rustc_builtin_macro] | ||
91 | macro_rules! format_args { | ||
92 | () => {} | ||
93 | } | ||
94 | |||
81 | fn f() { | 95 | fn f() { |
82 | // Test a handful of built-in (eager) macros: | 96 | // Test a handful of built-in (eager) macros: |
83 | 97 | ||
84 | include!(invalid); | 98 | include!(invalid); |
85 | //^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 99 | //^^^^^^^^^^^^^^^^^ could not convert tokens |
86 | include!("does not exist"); | 100 | include!("does not exist"); |
87 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 101 | //^^^^^^^^^^^^^^^^^^^^^^^^^^ could not convert tokens |
88 | 102 | ||
89 | env!(invalid); | 103 | env!(invalid); |
90 | //^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 104 | //^^^^^^^^^^^^^ could not convert tokens |
105 | |||
106 | env!("OUT_DIR"); | ||
107 | //^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix | ||
108 | |||
109 | compile_error!("compile_error works"); | ||
110 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compile_error works | ||
91 | 111 | ||
92 | // Lazy: | 112 | // Lazy: |
93 | 113 | ||
94 | format_args!(); | 114 | format_args!(); |
95 | //^^^^^^^^^^^^^^ failed to parse or resolve macro invocation | 115 | //^^^^^^^^^^^^^^ no rule matches input tokens |
96 | } | 116 | } |
97 | "#, | 117 | "#, |
98 | ); | 118 | ); |
diff --git a/crates/hir_def/src/docs.rs b/crates/hir_def/src/docs.rs index e9a02b11b..3e59a8f47 100644 --- a/crates/hir_def/src/docs.rs +++ b/crates/hir_def/src/docs.rs | |||
@@ -6,7 +6,8 @@ | |||
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use either::Either; | 8 | use either::Either; |
9 | use syntax::ast; | 9 | use itertools::Itertools; |
10 | use syntax::{ast, SmolStr}; | ||
10 | 11 | ||
11 | use crate::{ | 12 | use crate::{ |
12 | db::DefDatabase, | 13 | db::DefDatabase, |
@@ -93,7 +94,7 @@ fn merge_doc_comments_and_attrs( | |||
93 | ) -> Option<String> { | 94 | ) -> Option<String> { |
94 | match (doc_comment_text, doc_attr_text) { | 95 | match (doc_comment_text, doc_attr_text) { |
95 | (Some(mut comment_text), Some(attr_text)) => { | 96 | (Some(mut comment_text), Some(attr_text)) => { |
96 | comment_text.push_str("\n\n"); | 97 | comment_text.push_str("\n"); |
97 | comment_text.push_str(&attr_text); | 98 | comment_text.push_str(&attr_text); |
98 | Some(comment_text) | 99 | Some(comment_text) |
99 | } | 100 | } |
@@ -105,17 +106,16 @@ fn merge_doc_comments_and_attrs( | |||
105 | 106 | ||
106 | fn expand_doc_attrs(owner: &dyn ast::AttrsOwner) -> Option<String> { | 107 | fn expand_doc_attrs(owner: &dyn ast::AttrsOwner) -> Option<String> { |
107 | let mut docs = String::new(); | 108 | let mut docs = String::new(); |
108 | for attr in owner.attrs() { | 109 | owner |
109 | if let Some(("doc", value)) = | 110 | .attrs() |
110 | attr.as_simple_key_value().as_ref().map(|(k, v)| (k.as_str(), v.as_str())) | 111 | .filter_map(|attr| attr.as_simple_key_value().filter(|(key, _)| key == "doc")) |
111 | { | 112 | .map(|(_, value)| value) |
112 | docs.push_str(value); | 113 | .intersperse(SmolStr::new_inline("\n")) |
113 | docs.push_str("\n\n"); | 114 | // No FromIterator<SmolStr> for String |
114 | } | 115 | .for_each(|s| docs.push_str(s.as_str())); |
115 | } | ||
116 | if docs.is_empty() { | 116 | if docs.is_empty() { |
117 | None | 117 | None |
118 | } else { | 118 | } else { |
119 | Some(docs.trim_end_matches("\n\n").to_owned()) | 119 | Some(docs) |
120 | } | 120 | } |
121 | } | 121 | } |
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 1b22d1eec..b41c5acb2 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs | |||
@@ -465,21 +465,37 @@ pub trait AsMacroCall { | |||
465 | db: &dyn db::DefDatabase, | 465 | db: &dyn db::DefDatabase, |
466 | krate: CrateId, | 466 | krate: CrateId, |
467 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, | 467 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, |
468 | ) -> Option<MacroCallId> { | ||
469 | self.as_call_id_with_errors(db, krate, resolver, &mut |_| ()) | ||
470 | } | ||
471 | |||
472 | fn as_call_id_with_errors( | ||
473 | &self, | ||
474 | db: &dyn db::DefDatabase, | ||
475 | krate: CrateId, | ||
476 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, | ||
477 | error_sink: &mut dyn FnMut(mbe::ExpandError), | ||
468 | ) -> Option<MacroCallId>; | 478 | ) -> Option<MacroCallId>; |
469 | } | 479 | } |
470 | 480 | ||
471 | impl AsMacroCall for InFile<&ast::MacroCall> { | 481 | impl AsMacroCall for InFile<&ast::MacroCall> { |
472 | fn as_call_id( | 482 | fn as_call_id_with_errors( |
473 | &self, | 483 | &self, |
474 | db: &dyn db::DefDatabase, | 484 | db: &dyn db::DefDatabase, |
475 | krate: CrateId, | 485 | krate: CrateId, |
476 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, | 486 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, |
487 | error_sink: &mut dyn FnMut(mbe::ExpandError), | ||
477 | ) -> Option<MacroCallId> { | 488 | ) -> Option<MacroCallId> { |
478 | let ast_id = AstId::new(self.file_id, db.ast_id_map(self.file_id).ast_id(self.value)); | 489 | let ast_id = AstId::new(self.file_id, db.ast_id_map(self.file_id).ast_id(self.value)); |
479 | let h = Hygiene::new(db.upcast(), self.file_id); | 490 | let h = Hygiene::new(db.upcast(), self.file_id); |
480 | let path = path::ModPath::from_src(self.value.path()?, &h)?; | 491 | let path = self.value.path().and_then(|path| path::ModPath::from_src(path, &h)); |
492 | |||
493 | if path.is_none() { | ||
494 | error_sink(mbe::ExpandError::Other("malformed macro invocation".into())); | ||
495 | } | ||
481 | 496 | ||
482 | AstIdWithPath::new(ast_id.file_id, ast_id.value, path).as_call_id(db, krate, resolver) | 497 | AstIdWithPath::new(ast_id.file_id, ast_id.value, path?) |
498 | .as_call_id_with_errors(db, krate, resolver, error_sink) | ||
483 | } | 499 | } |
484 | } | 500 | } |
485 | 501 | ||
@@ -497,22 +513,32 @@ impl<T: ast::AstNode> AstIdWithPath<T> { | |||
497 | } | 513 | } |
498 | 514 | ||
499 | impl AsMacroCall for AstIdWithPath<ast::MacroCall> { | 515 | impl AsMacroCall for AstIdWithPath<ast::MacroCall> { |
500 | fn as_call_id( | 516 | fn as_call_id_with_errors( |
501 | &self, | 517 | &self, |
502 | db: &dyn db::DefDatabase, | 518 | db: &dyn db::DefDatabase, |
503 | krate: CrateId, | 519 | krate: CrateId, |
504 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, | 520 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, |
521 | error_sink: &mut dyn FnMut(mbe::ExpandError), | ||
505 | ) -> Option<MacroCallId> { | 522 | ) -> Option<MacroCallId> { |
506 | let def: MacroDefId = resolver(self.path.clone())?; | 523 | let def: MacroDefId = resolver(self.path.clone()).or_else(|| { |
524 | error_sink(mbe::ExpandError::Other(format!("could not resolve macro `{}`", self.path))); | ||
525 | None | ||
526 | })?; | ||
507 | 527 | ||
508 | if let MacroDefKind::BuiltInEager(_) = def.kind { | 528 | if let MacroDefKind::BuiltInEager(_) = def.kind { |
509 | let macro_call = InFile::new(self.ast_id.file_id, self.ast_id.to_node(db.upcast())); | 529 | let macro_call = InFile::new(self.ast_id.file_id, self.ast_id.to_node(db.upcast())); |
510 | let hygiene = Hygiene::new(db.upcast(), self.ast_id.file_id); | 530 | let hygiene = Hygiene::new(db.upcast(), self.ast_id.file_id); |
511 | 531 | ||
512 | Some( | 532 | Some( |
513 | expand_eager_macro(db.upcast(), krate, macro_call, def, &|path: ast::Path| { | 533 | expand_eager_macro( |
514 | resolver(path::ModPath::from_src(path, &hygiene)?) | 534 | db.upcast(), |
515 | })? | 535 | krate, |
536 | macro_call, | ||
537 | def, | ||
538 | &|path: ast::Path| resolver(path::ModPath::from_src(path, &hygiene)?), | ||
539 | error_sink, | ||
540 | ) | ||
541 | .ok()? | ||
516 | .into(), | 542 | .into(), |
517 | ) | 543 | ) |
518 | } else { | 544 | } else { |
@@ -522,13 +548,18 @@ impl AsMacroCall for AstIdWithPath<ast::MacroCall> { | |||
522 | } | 548 | } |
523 | 549 | ||
524 | impl AsMacroCall for AstIdWithPath<ast::Item> { | 550 | impl AsMacroCall for AstIdWithPath<ast::Item> { |
525 | fn as_call_id( | 551 | fn as_call_id_with_errors( |
526 | &self, | 552 | &self, |
527 | db: &dyn db::DefDatabase, | 553 | db: &dyn db::DefDatabase, |
528 | krate: CrateId, | 554 | krate: CrateId, |
529 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, | 555 | resolver: impl Fn(path::ModPath) -> Option<MacroDefId>, |
556 | error_sink: &mut dyn FnMut(mbe::ExpandError), | ||
530 | ) -> Option<MacroCallId> { | 557 | ) -> Option<MacroCallId> { |
531 | let def = resolver(self.path.clone())?; | 558 | let def: MacroDefId = resolver(self.path.clone()).or_else(|| { |
559 | error_sink(mbe::ExpandError::Other(format!("could not resolve macro `{}`", self.path))); | ||
560 | None | ||
561 | })?; | ||
562 | |||
532 | Some( | 563 | Some( |
533 | def.as_lazy_macro( | 564 | def.as_lazy_macro( |
534 | db.upcast(), | 565 | db.upcast(), |
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs index 7f4db106d..44a5556b6 100644 --- a/crates/hir_expand/src/builtin_macro.rs +++ b/crates/hir_expand/src/builtin_macro.rs | |||
@@ -86,7 +86,6 @@ pub fn find_builtin_macro( | |||
86 | register_builtin! { | 86 | register_builtin! { |
87 | LAZY: | 87 | LAZY: |
88 | (column, Column) => column_expand, | 88 | (column, Column) => column_expand, |
89 | (compile_error, CompileError) => compile_error_expand, | ||
90 | (file, File) => file_expand, | 89 | (file, File) => file_expand, |
91 | (line, Line) => line_expand, | 90 | (line, Line) => line_expand, |
92 | (assert, Assert) => assert_expand, | 91 | (assert, Assert) => assert_expand, |
@@ -97,6 +96,7 @@ register_builtin! { | |||
97 | (format_args_nl, FormatArgsNl) => format_args_expand, | 96 | (format_args_nl, FormatArgsNl) => format_args_expand, |
98 | 97 | ||
99 | EAGER: | 98 | EAGER: |
99 | (compile_error, CompileError) => compile_error_expand, | ||
100 | (concat, Concat) => concat_expand, | 100 | (concat, Concat) => concat_expand, |
101 | (include, Include) => include_expand, | 101 | (include, Include) => include_expand, |
102 | (include_bytes, IncludeBytes) => include_bytes_expand, | 102 | (include_bytes, IncludeBytes) => include_bytes_expand, |
@@ -213,25 +213,6 @@ fn file_expand( | |||
213 | ExpandResult::ok(expanded) | 213 | ExpandResult::ok(expanded) |
214 | } | 214 | } |
215 | 215 | ||
216 | fn compile_error_expand( | ||
217 | _db: &dyn AstDatabase, | ||
218 | _id: LazyMacroId, | ||
219 | tt: &tt::Subtree, | ||
220 | ) -> ExpandResult<tt::Subtree> { | ||
221 | if tt.count() == 1 { | ||
222 | if let tt::TokenTree::Leaf(tt::Leaf::Literal(it)) = &tt.token_trees[0] { | ||
223 | let s = it.text.as_str(); | ||
224 | if s.contains('"') { | ||
225 | return ExpandResult::ok(quote! { loop { #it }}); | ||
226 | } | ||
227 | }; | ||
228 | } | ||
229 | |||
230 | ExpandResult::only_err(mbe::ExpandError::BindingError( | ||
231 | "`compile_error!` argument be a string".into(), | ||
232 | )) | ||
233 | } | ||
234 | |||
235 | fn format_args_expand( | 216 | fn format_args_expand( |
236 | _db: &dyn AstDatabase, | 217 | _db: &dyn AstDatabase, |
237 | _id: LazyMacroId, | 218 | _id: LazyMacroId, |
@@ -280,6 +261,27 @@ fn unquote_str(lit: &tt::Literal) -> Option<String> { | |||
280 | token.value().map(|it| it.into_owned()) | 261 | token.value().map(|it| it.into_owned()) |
281 | } | 262 | } |
282 | 263 | ||
264 | fn compile_error_expand( | ||
265 | _db: &dyn AstDatabase, | ||
266 | _id: EagerMacroId, | ||
267 | tt: &tt::Subtree, | ||
268 | ) -> ExpandResult<Option<(tt::Subtree, FragmentKind)>> { | ||
269 | let err = match &*tt.token_trees { | ||
270 | [tt::TokenTree::Leaf(tt::Leaf::Literal(it))] => { | ||
271 | let text = it.text.as_str(); | ||
272 | if text.starts_with('"') && text.ends_with('"') { | ||
273 | // FIXME: does not handle raw strings | ||
274 | mbe::ExpandError::Other(text[1..text.len() - 1].to_string()) | ||
275 | } else { | ||
276 | mbe::ExpandError::BindingError("`compile_error!` argument must be a string".into()) | ||
277 | } | ||
278 | } | ||
279 | _ => mbe::ExpandError::BindingError("`compile_error!` argument must be a string".into()), | ||
280 | }; | ||
281 | |||
282 | ExpandResult { value: Some((quote! {}, FragmentKind::Items)), err: Some(err) } | ||
283 | } | ||
284 | |||
283 | fn concat_expand( | 285 | fn concat_expand( |
284 | _db: &dyn AstDatabase, | 286 | _db: &dyn AstDatabase, |
285 | _arg_id: EagerMacroId, | 287 | _arg_id: EagerMacroId, |
@@ -417,17 +419,25 @@ fn env_expand( | |||
417 | Err(e) => return ExpandResult::only_err(e), | 419 | Err(e) => return ExpandResult::only_err(e), |
418 | }; | 420 | }; |
419 | 421 | ||
420 | // FIXME: | 422 | let mut err = None; |
421 | // If the environment variable is not defined int rustc, then a compilation error will be emitted. | 423 | let s = get_env_inner(db, arg_id, &key).unwrap_or_else(|| { |
422 | // We might do the same if we fully support all other stuffs. | 424 | // The only variable rust-analyzer ever sets is `OUT_DIR`, so only diagnose that to avoid |
423 | // But for now on, we should return some dummy string for better type infer purpose. | 425 | // unnecessary diagnostics for eg. `CARGO_PKG_NAME`. |
424 | // However, we cannot use an empty string here, because for | 426 | if key == "OUT_DIR" { |
425 | // `include!(concat!(env!("OUT_DIR"), "/foo.rs"))` will become | 427 | err = Some(mbe::ExpandError::Other( |
426 | // `include!("foo.rs"), which might go to infinite loop | 428 | r#"`OUT_DIR` not set, enable "load out dirs from check" to fix"#.into(), |
427 | let s = get_env_inner(db, arg_id, &key).unwrap_or_else(|| "__RA_UNIMPLEMENTED__".to_string()); | 429 | )); |
430 | } | ||
431 | |||
432 | // If the variable is unset, still return a dummy string to help type inference along. | ||
433 | // We cannot use an empty string here, because for | ||
434 | // `include!(concat!(env!("OUT_DIR"), "/foo.rs"))` will become | ||
435 | // `include!("foo.rs"), which might go to infinite loop | ||
436 | "__RA_UNIMPLEMENTED__".to_string() | ||
437 | }); | ||
428 | let expanded = quote! { #s }; | 438 | let expanded = quote! { #s }; |
429 | 439 | ||
430 | ExpandResult::ok(Some((expanded, FragmentKind::Expr))) | 440 | ExpandResult { value: Some((expanded, FragmentKind::Expr)), err } |
431 | } | 441 | } |
432 | 442 | ||
433 | fn option_env_expand( | 443 | fn option_env_expand( |
@@ -638,7 +648,8 @@ mod tests { | |||
638 | "#, | 648 | "#, |
639 | ); | 649 | ); |
640 | 650 | ||
641 | assert_eq!(expanded, r#"loop{"error!"}"#); | 651 | // This expands to nothing (since it's in item position), but emits an error. |
652 | assert_eq!(expanded, ""); | ||
642 | } | 653 | } |
643 | 654 | ||
644 | #[test] | 655 | #[test] |
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs index 4fd0ba290..842a177db 100644 --- a/crates/hir_expand/src/db.rs +++ b/crates/hir_expand/src/db.rs | |||
@@ -207,6 +207,7 @@ fn macro_expand_with_arg( | |||
207 | } else { | 207 | } else { |
208 | return ExpandResult { | 208 | return ExpandResult { |
209 | value: Some(db.lookup_intern_eager_expansion(id).subtree), | 209 | value: Some(db.lookup_intern_eager_expansion(id).subtree), |
210 | // FIXME: There could be errors here! | ||
210 | err: None, | 211 | err: None, |
211 | }; | 212 | }; |
212 | } | 213 | } |
diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs index ab6b4477c..0229a836e 100644 --- a/crates/hir_expand/src/eager.rs +++ b/crates/hir_expand/src/eager.rs | |||
@@ -26,19 +26,89 @@ use crate::{ | |||
26 | }; | 26 | }; |
27 | 27 | ||
28 | use base_db::CrateId; | 28 | use base_db::CrateId; |
29 | use mbe::ExpandResult; | ||
29 | use parser::FragmentKind; | 30 | use parser::FragmentKind; |
30 | use std::sync::Arc; | 31 | use std::sync::Arc; |
31 | use syntax::{algo::SyntaxRewriter, SyntaxNode}; | 32 | use syntax::{algo::SyntaxRewriter, SyntaxNode}; |
32 | 33 | ||
34 | pub struct ErrorEmitted { | ||
35 | _private: (), | ||
36 | } | ||
37 | |||
38 | trait ErrorSink { | ||
39 | fn emit(&mut self, err: mbe::ExpandError); | ||
40 | |||
41 | fn option<T>( | ||
42 | &mut self, | ||
43 | opt: Option<T>, | ||
44 | error: impl FnOnce() -> mbe::ExpandError, | ||
45 | ) -> Result<T, ErrorEmitted> { | ||
46 | match opt { | ||
47 | Some(it) => Ok(it), | ||
48 | None => { | ||
49 | self.emit(error()); | ||
50 | Err(ErrorEmitted { _private: () }) | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | fn option_with<T>( | ||
56 | &mut self, | ||
57 | opt: impl FnOnce() -> Option<T>, | ||
58 | error: impl FnOnce() -> mbe::ExpandError, | ||
59 | ) -> Result<T, ErrorEmitted> { | ||
60 | self.option(opt(), error) | ||
61 | } | ||
62 | |||
63 | fn result<T>(&mut self, res: Result<T, mbe::ExpandError>) -> Result<T, ErrorEmitted> { | ||
64 | match res { | ||
65 | Ok(it) => Ok(it), | ||
66 | Err(e) => { | ||
67 | self.emit(e); | ||
68 | Err(ErrorEmitted { _private: () }) | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | |||
73 | fn expand_result_option<T>(&mut self, res: ExpandResult<Option<T>>) -> Result<T, ErrorEmitted> { | ||
74 | match (res.value, res.err) { | ||
75 | (None, Some(err)) => { | ||
76 | self.emit(err); | ||
77 | Err(ErrorEmitted { _private: () }) | ||
78 | } | ||
79 | (Some(value), opt_err) => { | ||
80 | if let Some(err) = opt_err { | ||
81 | self.emit(err); | ||
82 | } | ||
83 | Ok(value) | ||
84 | } | ||
85 | (None, None) => unreachable!("`ExpandResult` without value or error"), | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | impl ErrorSink for &'_ mut dyn FnMut(mbe::ExpandError) { | ||
91 | fn emit(&mut self, err: mbe::ExpandError) { | ||
92 | self(err); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | fn err(msg: impl Into<String>) -> mbe::ExpandError { | ||
97 | mbe::ExpandError::Other(msg.into()) | ||
98 | } | ||
99 | |||
33 | pub fn expand_eager_macro( | 100 | pub fn expand_eager_macro( |
34 | db: &dyn AstDatabase, | 101 | db: &dyn AstDatabase, |
35 | krate: CrateId, | 102 | krate: CrateId, |
36 | macro_call: InFile<ast::MacroCall>, | 103 | macro_call: InFile<ast::MacroCall>, |
37 | def: MacroDefId, | 104 | def: MacroDefId, |
38 | resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, | 105 | resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, |
39 | ) -> Option<EagerMacroId> { | 106 | mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError), |
40 | let args = macro_call.value.token_tree()?; | 107 | ) -> Result<EagerMacroId, ErrorEmitted> { |
41 | let parsed_args = mbe::ast_to_token_tree(&args)?.0; | 108 | let parsed_args = diagnostic_sink.option_with( |
109 | || Some(mbe::ast_to_token_tree(¯o_call.value.token_tree()?)?.0), | ||
110 | || err("malformed macro invocation"), | ||
111 | )?; | ||
42 | 112 | ||
43 | // Note: | 113 | // Note: |
44 | // When `lazy_expand` is called, its *parent* file must be already exists. | 114 | // When `lazy_expand` is called, its *parent* file must be already exists. |
@@ -55,17 +125,22 @@ pub fn expand_eager_macro( | |||
55 | }); | 125 | }); |
56 | let arg_file_id: MacroCallId = arg_id.into(); | 126 | let arg_file_id: MacroCallId = arg_id.into(); |
57 | 127 | ||
58 | let parsed_args = mbe::token_tree_to_syntax_node(&parsed_args, FragmentKind::Expr).ok()?.0; | 128 | let parsed_args = |
129 | diagnostic_sink.result(mbe::token_tree_to_syntax_node(&parsed_args, FragmentKind::Expr))?.0; | ||
59 | let result = eager_macro_recur( | 130 | let result = eager_macro_recur( |
60 | db, | 131 | db, |
61 | InFile::new(arg_file_id.as_file(), parsed_args.syntax_node()), | 132 | InFile::new(arg_file_id.as_file(), parsed_args.syntax_node()), |
62 | krate, | 133 | krate, |
63 | resolver, | 134 | resolver, |
135 | diagnostic_sink, | ||
64 | )?; | 136 | )?; |
65 | let subtree = to_subtree(&result)?; | 137 | let subtree = |
138 | diagnostic_sink.option(to_subtree(&result), || err("failed to parse macro result"))?; | ||
66 | 139 | ||
67 | if let MacroDefKind::BuiltInEager(eager) = def.kind { | 140 | if let MacroDefKind::BuiltInEager(eager) = def.kind { |
68 | let (subtree, fragment) = eager.expand(db, arg_id, &subtree).value?; | 141 | let res = eager.expand(db, arg_id, &subtree); |
142 | |||
143 | let (subtree, fragment) = diagnostic_sink.expand_result_option(res)?; | ||
69 | let eager = EagerCallLoc { | 144 | let eager = EagerCallLoc { |
70 | def, | 145 | def, |
71 | fragment, | 146 | fragment, |
@@ -74,9 +149,9 @@ pub fn expand_eager_macro( | |||
74 | file_id: macro_call.file_id, | 149 | file_id: macro_call.file_id, |
75 | }; | 150 | }; |
76 | 151 | ||
77 | Some(db.intern_eager_expansion(eager)) | 152 | Ok(db.intern_eager_expansion(eager)) |
78 | } else { | 153 | } else { |
79 | None | 154 | panic!("called `expand_eager_macro` on non-eager macro def {:?}", def); |
80 | } | 155 | } |
81 | } | 156 | } |
82 | 157 | ||
@@ -91,13 +166,16 @@ fn lazy_expand( | |||
91 | def: &MacroDefId, | 166 | def: &MacroDefId, |
92 | macro_call: InFile<ast::MacroCall>, | 167 | macro_call: InFile<ast::MacroCall>, |
93 | krate: CrateId, | 168 | krate: CrateId, |
94 | ) -> Option<InFile<SyntaxNode>> { | 169 | ) -> ExpandResult<Option<InFile<SyntaxNode>>> { |
95 | let ast_id = db.ast_id_map(macro_call.file_id).ast_id(¯o_call.value); | 170 | let ast_id = db.ast_id_map(macro_call.file_id).ast_id(¯o_call.value); |
96 | 171 | ||
97 | let id: MacroCallId = | 172 | let id: MacroCallId = |
98 | def.as_lazy_macro(db, krate, MacroCallKind::FnLike(macro_call.with_value(ast_id))).into(); | 173 | def.as_lazy_macro(db, krate, MacroCallKind::FnLike(macro_call.with_value(ast_id))).into(); |
99 | 174 | ||
100 | db.parse_or_expand(id.as_file()).map(|node| InFile::new(id.as_file(), node)) | 175 | let err = db.macro_expand_error(id); |
176 | let value = db.parse_or_expand(id.as_file()).map(|node| InFile::new(id.as_file(), node)); | ||
177 | |||
178 | ExpandResult { value, err } | ||
101 | } | 179 | } |
102 | 180 | ||
103 | fn eager_macro_recur( | 181 | fn eager_macro_recur( |
@@ -105,7 +183,8 @@ fn eager_macro_recur( | |||
105 | curr: InFile<SyntaxNode>, | 183 | curr: InFile<SyntaxNode>, |
106 | krate: CrateId, | 184 | krate: CrateId, |
107 | macro_resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, | 185 | macro_resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, |
108 | ) -> Option<SyntaxNode> { | 186 | mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError), |
187 | ) -> Result<SyntaxNode, ErrorEmitted> { | ||
109 | let original = curr.value.clone(); | 188 | let original = curr.value.clone(); |
110 | 189 | ||
111 | let children = curr.value.descendants().filter_map(ast::MacroCall::cast); | 190 | let children = curr.value.descendants().filter_map(ast::MacroCall::cast); |
@@ -113,7 +192,8 @@ fn eager_macro_recur( | |||
113 | 192 | ||
114 | // Collect replacement | 193 | // Collect replacement |
115 | for child in children { | 194 | for child in children { |
116 | let def: MacroDefId = macro_resolver(child.path()?)?; | 195 | let def = diagnostic_sink |
196 | .option_with(|| macro_resolver(child.path()?), || err("failed to resolve macro"))?; | ||
117 | let insert = match def.kind { | 197 | let insert = match def.kind { |
118 | MacroDefKind::BuiltInEager(_) => { | 198 | MacroDefKind::BuiltInEager(_) => { |
119 | let id: MacroCallId = expand_eager_macro( | 199 | let id: MacroCallId = expand_eager_macro( |
@@ -122,17 +202,21 @@ fn eager_macro_recur( | |||
122 | curr.with_value(child.clone()), | 202 | curr.with_value(child.clone()), |
123 | def, | 203 | def, |
124 | macro_resolver, | 204 | macro_resolver, |
205 | diagnostic_sink, | ||
125 | )? | 206 | )? |
126 | .into(); | 207 | .into(); |
127 | db.parse_or_expand(id.as_file())? | 208 | db.parse_or_expand(id.as_file()) |
209 | .expect("successful macro expansion should be parseable") | ||
128 | } | 210 | } |
129 | MacroDefKind::Declarative | 211 | MacroDefKind::Declarative |
130 | | MacroDefKind::BuiltIn(_) | 212 | | MacroDefKind::BuiltIn(_) |
131 | | MacroDefKind::BuiltInDerive(_) | 213 | | MacroDefKind::BuiltInDerive(_) |
132 | | MacroDefKind::ProcMacro(_) => { | 214 | | MacroDefKind::ProcMacro(_) => { |
133 | let expanded = lazy_expand(db, &def, curr.with_value(child.clone()), krate)?; | 215 | let res = lazy_expand(db, &def, curr.with_value(child.clone()), krate); |
216 | let val = diagnostic_sink.expand_result_option(res)?; | ||
217 | |||
134 | // replace macro inside | 218 | // replace macro inside |
135 | eager_macro_recur(db, expanded, krate, macro_resolver)? | 219 | eager_macro_recur(db, val, krate, macro_resolver, diagnostic_sink)? |
136 | } | 220 | } |
137 | }; | 221 | }; |
138 | 222 | ||
@@ -140,5 +224,5 @@ fn eager_macro_recur( | |||
140 | } | 224 | } |
141 | 225 | ||
142 | let res = rewriter.rewrite(&original); | 226 | let res = rewriter.rewrite(&original); |
143 | Some(res) | 227 | Ok(res) |
144 | } | 228 | } |
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index d383b968d..5d3fa0518 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -30,7 +30,7 @@ impl Hygiene { | |||
30 | let loc = db.lookup_intern_macro(id); | 30 | let loc = db.lookup_intern_macro(id); |
31 | match loc.def.kind { | 31 | match loc.def.kind { |
32 | MacroDefKind::Declarative => (loc.def.krate, loc.def.local_inner), | 32 | MacroDefKind::Declarative => (loc.def.krate, loc.def.local_inner), |
33 | MacroDefKind::BuiltIn(_) => (None, false), | 33 | MacroDefKind::BuiltIn(_) => (loc.def.krate, false), |
34 | MacroDefKind::BuiltInDerive(_) => (None, false), | 34 | MacroDefKind::BuiltInDerive(_) => (None, false), |
35 | MacroDefKind::BuiltInEager(_) => (None, false), | 35 | MacroDefKind::BuiltInEager(_) => (None, false), |
36 | MacroDefKind::ProcMacro(_) => (None, false), | 36 | MacroDefKind::ProcMacro(_) => (None, false), |
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 6dad2507b..2633fd8f7 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs | |||
@@ -143,7 +143,11 @@ impl HirFileId { | |||
143 | let loc: MacroCallLoc = db.lookup_intern_macro(lazy_id); | 143 | let loc: MacroCallLoc = db.lookup_intern_macro(lazy_id); |
144 | 144 | ||
145 | let arg_tt = loc.kind.arg(db)?; | 145 | let arg_tt = loc.kind.arg(db)?; |
146 | let def_tt = loc.def.ast_id?.to_node(db).token_tree()?; | 146 | |
147 | let def = loc.def.ast_id.and_then(|id| { | ||
148 | let def_tt = id.to_node(db).token_tree()?; | ||
149 | Some(InFile::new(id.file_id, def_tt)) | ||
150 | }); | ||
147 | 151 | ||
148 | let macro_def = db.macro_def(loc.def)?; | 152 | let macro_def = db.macro_def(loc.def)?; |
149 | let (parse, exp_map) = db.parse_macro_expansion(macro_file).value?; | 153 | let (parse, exp_map) = db.parse_macro_expansion(macro_file).value?; |
@@ -152,7 +156,7 @@ impl HirFileId { | |||
152 | Some(ExpansionInfo { | 156 | Some(ExpansionInfo { |
153 | expanded: InFile::new(self, parse.syntax_node()), | 157 | expanded: InFile::new(self, parse.syntax_node()), |
154 | arg: InFile::new(loc.kind.file_id(), arg_tt), | 158 | arg: InFile::new(loc.kind.file_id(), arg_tt), |
155 | def: InFile::new(loc.def.ast_id?.file_id, def_tt), | 159 | def, |
156 | macro_arg, | 160 | macro_arg, |
157 | macro_def, | 161 | macro_def, |
158 | exp_map, | 162 | exp_map, |
@@ -311,7 +315,8 @@ pub struct EagerCallLoc { | |||
311 | pub struct ExpansionInfo { | 315 | pub struct ExpansionInfo { |
312 | expanded: InFile<SyntaxNode>, | 316 | expanded: InFile<SyntaxNode>, |
313 | arg: InFile<SyntaxNode>, | 317 | arg: InFile<SyntaxNode>, |
314 | def: InFile<ast::TokenTree>, | 318 | /// The `macro_rules!` arguments. |
319 | def: Option<InFile<ast::TokenTree>>, | ||
315 | 320 | ||
316 | macro_def: Arc<(db::TokenExpander, mbe::TokenMap)>, | 321 | macro_def: Arc<(db::TokenExpander, mbe::TokenMap)>, |
317 | macro_arg: Arc<(tt::Subtree, mbe::TokenMap)>, | 322 | macro_arg: Arc<(tt::Subtree, mbe::TokenMap)>, |
@@ -348,9 +353,14 @@ impl ExpansionInfo { | |||
348 | let (token_id, origin) = self.macro_def.0.map_id_up(token_id); | 353 | let (token_id, origin) = self.macro_def.0.map_id_up(token_id); |
349 | let (token_map, tt) = match origin { | 354 | let (token_map, tt) = match origin { |
350 | mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()), | 355 | mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()), |
351 | mbe::Origin::Def => { | 356 | mbe::Origin::Def => ( |
352 | (&self.macro_def.1, self.def.as_ref().map(|tt| tt.syntax().clone())) | 357 | &self.macro_def.1, |
353 | } | 358 | self.def |
359 | .as_ref() | ||
360 | .expect("`Origin::Def` used with non-`macro_rules!` macro") | ||
361 | .as_ref() | ||
362 | .map(|tt| tt.syntax().clone()), | ||
363 | ), | ||
354 | }; | 364 | }; |
355 | 365 | ||
356 | let range = token_map.range_by_token(token_id)?.by_kind(token.value.kind())?; | 366 | let range = token_map.range_by_token(token_id)?.by_kind(token.value.kind())?; |
diff --git a/crates/hir_expand/src/proc_macro.rs b/crates/hir_expand/src/proc_macro.rs index 97edf0fb6..38882d2b6 100644 --- a/crates/hir_expand/src/proc_macro.rs +++ b/crates/hir_expand/src/proc_macro.rs | |||
@@ -26,7 +26,6 @@ impl ProcMacroExpander { | |||
26 | 26 | ||
27 | pub fn dummy(krate: CrateId) -> Self { | 27 | pub fn dummy(krate: CrateId) -> Self { |
28 | // FIXME: Should store the name for better errors | 28 | // FIXME: Should store the name for better errors |
29 | // FIXME: I think this is the second layer of "dummy" expansion, we should reduce that | ||
30 | Self { krate, proc_macro_id: None } | 29 | Self { krate, proc_macro_id: None } |
31 | } | 30 | } |
32 | 31 | ||
diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index cf5c38a23..289e812fe 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml | |||
@@ -17,9 +17,9 @@ ena = "0.14.0" | |||
17 | log = "0.4.8" | 17 | log = "0.4.8" |
18 | rustc-hash = "1.1.0" | 18 | rustc-hash = "1.1.0" |
19 | scoped-tls = "1" | 19 | scoped-tls = "1" |
20 | chalk-solve = { version = "0.37", default-features = false } | 20 | chalk-solve = { version = "0.43", default-features = false } |
21 | chalk-ir = "0.37" | 21 | chalk-ir = "0.43" |
22 | chalk-recursive = "0.37" | 22 | chalk-recursive = "0.43" |
23 | 23 | ||
24 | stdx = { path = "../stdx", version = "0.0.0" } | 24 | stdx = { path = "../stdx", version = "0.0.0" } |
25 | hir_def = { path = "../hir_def", version = "0.0.0" } | 25 | hir_def = { path = "../hir_def", version = "0.0.0" } |
diff --git a/crates/hir_ty/src/db.rs b/crates/hir_ty/src/db.rs index 25cf9eb7f..66bdb8e88 100644 --- a/crates/hir_ty/src/db.rs +++ b/crates/hir_ty/src/db.rs | |||
@@ -99,6 +99,12 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { | |||
99 | #[salsa::invoke(crate::traits::chalk::fn_def_datum_query)] | 99 | #[salsa::invoke(crate::traits::chalk::fn_def_datum_query)] |
100 | fn fn_def_datum(&self, krate: CrateId, fn_def_id: chalk::FnDefId) -> Arc<chalk::FnDefDatum>; | 100 | fn fn_def_datum(&self, krate: CrateId, fn_def_id: chalk::FnDefId) -> Arc<chalk::FnDefDatum>; |
101 | 101 | ||
102 | #[salsa::invoke(crate::traits::chalk::fn_def_variance_query)] | ||
103 | fn fn_def_variance(&self, krate: CrateId, fn_def_id: chalk::FnDefId) -> chalk::Variances; | ||
104 | |||
105 | #[salsa::invoke(crate::traits::chalk::adt_variance_query)] | ||
106 | fn adt_variance(&self, krate: CrateId, adt_id: chalk::AdtId) -> chalk::Variances; | ||
107 | |||
102 | #[salsa::invoke(crate::traits::chalk::associated_ty_value_query)] | 108 | #[salsa::invoke(crate::traits::chalk::associated_ty_value_query)] |
103 | fn associated_ty_value( | 109 | fn associated_ty_value( |
104 | &self, | 110 | &self, |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 5a6f0c67f..8a289f52a 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -720,7 +720,13 @@ fn transform_receiver_ty( | |||
720 | .push(self_ty.value.clone()) | 720 | .push(self_ty.value.clone()) |
721 | .fill_with_unknown() | 721 | .fill_with_unknown() |
722 | .build(), | 722 | .build(), |
723 | AssocContainerId::ImplId(impl_id) => inherent_impl_substs(db, impl_id, &self_ty)?, | 723 | AssocContainerId::ImplId(impl_id) => { |
724 | let impl_substs = inherent_impl_substs(db, impl_id, &self_ty)?; | ||
725 | Substs::build_for_def(db, function_id) | ||
726 | .use_parent_substs(&impl_substs) | ||
727 | .fill_with_unknown() | ||
728 | .build() | ||
729 | } | ||
724 | AssocContainerId::ContainerId(_) => unreachable!(), | 730 | AssocContainerId::ContainerId(_) => unreachable!(), |
725 | }; | 731 | }; |
726 | let sig = db.callable_item_signature(function_id.into()); | 732 | let sig = db.callable_item_signature(function_id.into()); |
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 0f17ff151..a6a54e542 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs | |||
@@ -1087,3 +1087,22 @@ fn method_resolution_foreign_opaque_type() { | |||
1087 | "#]], | 1087 | "#]], |
1088 | ); | 1088 | ); |
1089 | } | 1089 | } |
1090 | |||
1091 | #[test] | ||
1092 | fn method_with_allocator_box_self_type() { | ||
1093 | check_types( | ||
1094 | r#" | ||
1095 | struct Slice<T> {} | ||
1096 | struct Box<T, A> {} | ||
1097 | |||
1098 | impl<T> Slice<T> { | ||
1099 | pub fn into_vec<A>(self: Box<Self, A>) { } | ||
1100 | } | ||
1101 | |||
1102 | fn main() { | ||
1103 | let foo: Slice<u32>; | ||
1104 | (foo.into_vec()); // we don't actually support arbitrary self types, but we shouldn't crash at least | ||
1105 | } //^ {unknown} | ||
1106 | "#, | ||
1107 | ); | ||
1108 | } | ||
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 94d86b0d1..8cf4e7012 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs | |||
@@ -840,3 +840,46 @@ fn issue_4966() { | |||
840 | "#]], | 840 | "#]], |
841 | ); | 841 | ); |
842 | } | 842 | } |
843 | |||
844 | #[test] | ||
845 | fn issue_6628() { | ||
846 | check_infer( | ||
847 | r#" | ||
848 | #[lang = "fn_once"] | ||
849 | pub trait FnOnce<Args> { | ||
850 | type Output; | ||
851 | } | ||
852 | |||
853 | struct S<T>(); | ||
854 | impl<T> S<T> { | ||
855 | fn f(&self, _t: T) {} | ||
856 | fn g<F: FnOnce(&T)>(&self, _f: F) {} | ||
857 | } | ||
858 | fn main() { | ||
859 | let s = S(); | ||
860 | s.g(|_x| {}); | ||
861 | s.f(10); | ||
862 | } | ||
863 | "#, | ||
864 | expect![[r#" | ||
865 | 105..109 'self': &S<T> | ||
866 | 111..113 '_t': T | ||
867 | 118..120 '{}': () | ||
868 | 146..150 'self': &S<T> | ||
869 | 152..154 '_f': F | ||
870 | 159..161 '{}': () | ||
871 | 174..225 '{ ...10); }': () | ||
872 | 184..185 's': S<i32> | ||
873 | 188..189 'S': S<i32>() -> S<i32> | ||
874 | 188..191 'S()': S<i32> | ||
875 | 197..198 's': S<i32> | ||
876 | 197..209 's.g(|_x| {})': () | ||
877 | 201..208 '|_x| {}': |&i32| -> () | ||
878 | 202..204 '_x': &i32 | ||
879 | 206..208 '{}': () | ||
880 | 215..216 's': S<i32> | ||
881 | 215..222 's.f(10)': () | ||
882 | 219..221 '10': i32 | ||
883 | "#]], | ||
884 | ); | ||
885 | } | ||
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index ce1174cbe..dfa51896b 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! Trait solving using Chalk. | 1 | //! Trait solving using Chalk. |
2 | use std::env::var; | ||
2 | use std::sync::Arc; | 3 | use std::sync::Arc; |
3 | 4 | ||
4 | use base_db::CrateId; | 5 | use base_db::CrateId; |
@@ -15,12 +16,6 @@ use self::chalk::{from_chalk, Interner, ToChalk}; | |||
15 | 16 | ||
16 | pub(crate) mod chalk; | 17 | pub(crate) mod chalk; |
17 | 18 | ||
18 | // This controls the maximum size of types Chalk considers. If we set this too | ||
19 | // high, we can run into slow edge cases; if we set it too low, Chalk won't | ||
20 | // find some solutions. | ||
21 | // FIXME this is currently hardcoded in the recursive solver | ||
22 | // const CHALK_SOLVER_MAX_SIZE: usize = 10; | ||
23 | |||
24 | /// This controls how much 'time' we give the Chalk solver before giving up. | 19 | /// This controls how much 'time' we give the Chalk solver before giving up. |
25 | const CHALK_SOLVER_FUEL: i32 = 100; | 20 | const CHALK_SOLVER_FUEL: i32 = 100; |
26 | 21 | ||
@@ -31,9 +26,11 @@ struct ChalkContext<'a> { | |||
31 | } | 26 | } |
32 | 27 | ||
33 | fn create_chalk_solver() -> chalk_recursive::RecursiveSolver<Interner> { | 28 | fn create_chalk_solver() -> chalk_recursive::RecursiveSolver<Interner> { |
34 | let overflow_depth = 100; | 29 | let overflow_depth = |
30 | var("CHALK_OVERFLOW_DEPTH").ok().and_then(|s| s.parse().ok()).unwrap_or(100); | ||
35 | let caching_enabled = true; | 31 | let caching_enabled = true; |
36 | chalk_recursive::RecursiveSolver::new(overflow_depth, caching_enabled) | 32 | let max_size = var("CHALK_SOLVER_MAX_SIZE").ok().and_then(|s| s.parse().ok()).unwrap_or(30); |
33 | chalk_recursive::RecursiveSolver::new(overflow_depth, max_size, caching_enabled) | ||
37 | } | 34 | } |
38 | 35 | ||
39 | /// A set of clauses that we assume to be true. E.g. if we are inside this function: | 36 | /// A set of clauses that we assume to be true. E.g. if we are inside this function: |
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 55e2c3a3e..69eae6f79 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -104,7 +104,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
104 | }; | 104 | }; |
105 | 105 | ||
106 | // Note: Since we're using impls_for_trait, only impls where the trait | 106 | // Note: Since we're using impls_for_trait, only impls where the trait |
107 | // can be resolved should ever reach Chalk. `impl_datum` relies on that | 107 | // can be resolved should ever reach Chalk. Symbol’s value as variable is void: impl_datum relies on that |
108 | // and will panic if the trait can't be resolved. | 108 | // and will panic if the trait can't be resolved. |
109 | let in_deps = self.db.trait_impls_in_deps(self.krate); | 109 | let in_deps = self.db.trait_impls_in_deps(self.krate); |
110 | let in_self = self.db.trait_impls_in_crate(self.krate); | 110 | let in_self = self.db.trait_impls_in_crate(self.krate); |
@@ -206,7 +206,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
206 | Some((trait_, alias)) | 206 | Some((trait_, alias)) |
207 | }) | 207 | }) |
208 | { | 208 | { |
209 | // Making up `AsyncBlock<T>: Future<Output = T>` | 209 | // Making up Symbol’s value as variable is void: AsyncBlock<T>: |
210 | // | 210 | // |
211 | // |--------------------OpaqueTyDatum-------------------| | 211 | // |--------------------OpaqueTyDatum-------------------| |
212 | // |-------------OpaqueTyDatumBound--------------| | 212 | // |-------------OpaqueTyDatumBound--------------| |
@@ -242,7 +242,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
242 | // The opaque type has 1 parameter. | 242 | // The opaque type has 1 parameter. |
243 | make_binders(bound, 1) | 243 | make_binders(bound, 1) |
244 | } else { | 244 | } else { |
245 | // If failed to find `Future::Output`, return empty bounds as fallback. | 245 | // If failed to find Symbol’s value as variable is void: Future::Output, return empty bounds as fallback. |
246 | let bound = OpaqueTyDatumBound { | 246 | let bound = OpaqueTyDatumBound { |
247 | bounds: make_binders(vec![], 0), | 247 | bounds: make_binders(vec![], 0), |
248 | where_clauses: make_binders(vec![], 0), | 248 | where_clauses: make_binders(vec![], 0), |
@@ -343,6 +343,23 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
343 | // FIXME | 343 | // FIXME |
344 | unimplemented!() | 344 | unimplemented!() |
345 | } | 345 | } |
346 | |||
347 | fn unification_database(&self) -> &dyn chalk_ir::UnificationDatabase<Interner> { | ||
348 | self | ||
349 | } | ||
350 | } | ||
351 | |||
352 | impl<'a> chalk_ir::UnificationDatabase<Interner> for ChalkContext<'a> { | ||
353 | fn fn_def_variance( | ||
354 | &self, | ||
355 | fn_def_id: chalk_ir::FnDefId<Interner>, | ||
356 | ) -> chalk_ir::Variances<Interner> { | ||
357 | self.db.fn_def_variance(self.krate, fn_def_id) | ||
358 | } | ||
359 | |||
360 | fn adt_variance(&self, adt_id: chalk_ir::AdtId<Interner>) -> chalk_ir::Variances<Interner> { | ||
361 | self.db.adt_variance(self.krate, adt_id) | ||
362 | } | ||
346 | } | 363 | } |
347 | 364 | ||
348 | pub(crate) fn program_clauses_for_chalk_env_query( | 365 | pub(crate) fn program_clauses_for_chalk_env_query( |
@@ -644,6 +661,32 @@ pub(crate) fn fn_def_datum_query( | |||
644 | Arc::new(datum) | 661 | Arc::new(datum) |
645 | } | 662 | } |
646 | 663 | ||
664 | pub(crate) fn fn_def_variance_query( | ||
665 | db: &dyn HirDatabase, | ||
666 | _krate: CrateId, | ||
667 | fn_def_id: FnDefId, | ||
668 | ) -> Variances { | ||
669 | let callable_def: CallableDefId = from_chalk(db, fn_def_id); | ||
670 | let generic_params = generics(db.upcast(), callable_def.into()); | ||
671 | Variances::from( | ||
672 | &Interner, | ||
673 | std::iter::repeat(chalk_ir::Variance::Invariant).take(generic_params.len()), | ||
674 | ) | ||
675 | } | ||
676 | |||
677 | pub(crate) fn adt_variance_query( | ||
678 | db: &dyn HirDatabase, | ||
679 | _krate: CrateId, | ||
680 | adt_id: AdtId, | ||
681 | ) -> Variances { | ||
682 | let adt: crate::AdtId = from_chalk(db, adt_id); | ||
683 | let generic_params = generics(db.upcast(), adt.into()); | ||
684 | Variances::from( | ||
685 | &Interner, | ||
686 | std::iter::repeat(chalk_ir::Variance::Invariant).take(generic_params.len()), | ||
687 | ) | ||
688 | } | ||
689 | |||
647 | impl From<FnDefId> for crate::db::InternedCallableDefId { | 690 | impl From<FnDefId> for crate::db::InternedCallableDefId { |
648 | fn from(fn_def_id: FnDefId) -> Self { | 691 | fn from(fn_def_id: FnDefId) -> Self { |
649 | InternKey::from_intern_id(fn_def_id.0) | 692 | InternKey::from_intern_id(fn_def_id.0) |
diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index 39569e690..6a4aa8333 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs | |||
@@ -25,6 +25,7 @@ pub(crate) type FnDefId = chalk_ir::FnDefId<Interner>; | |||
25 | pub(crate) type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>; | 25 | pub(crate) type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>; |
26 | pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>; | 26 | pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>; |
27 | pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>; | 27 | pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>; |
28 | pub(crate) type Variances = chalk_ir::Variances<Interner>; | ||
28 | 29 | ||
29 | impl chalk_ir::interner::Interner for Interner { | 30 | impl chalk_ir::interner::Interner for Interner { |
30 | type InternedType = Arc<chalk_ir::TyData<Self>>; | 31 | type InternedType = Arc<chalk_ir::TyData<Self>>; |
@@ -41,6 +42,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
41 | type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>; | 42 | type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>; |
42 | type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>; | 43 | type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>; |
43 | type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>; | 44 | type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>; |
45 | type InternedVariances = Arc<[chalk_ir::Variance]>; | ||
44 | type DefId = InternId; | 46 | type DefId = InternId; |
45 | type InternedAdtId = hir_def::AdtId; | 47 | type InternedAdtId = hir_def::AdtId; |
46 | type Identifier = TypeAliasId; | 48 | type Identifier = TypeAliasId; |
@@ -370,6 +372,20 @@ impl chalk_ir::interner::Interner for Interner { | |||
370 | ) -> Option<fmt::Result> { | 372 | ) -> Option<fmt::Result> { |
371 | None | 373 | None |
372 | } | 374 | } |
375 | |||
376 | fn intern_variances<E>( | ||
377 | &self, | ||
378 | data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>, | ||
379 | ) -> Result<Self::InternedVariances, E> { | ||
380 | data.into_iter().collect() | ||
381 | } | ||
382 | |||
383 | fn variances_data<'a>( | ||
384 | &self, | ||
385 | variances: &'a Self::InternedVariances, | ||
386 | ) -> &'a [chalk_ir::Variance] { | ||
387 | &variances | ||
388 | } | ||
373 | } | 389 | } |
374 | 390 | ||
375 | impl chalk_ir::interner::HasInterner for Interner { | 391 | impl chalk_ir::interner::HasInterner for Interner { |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 86cbc4c7e..8700d664e 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -31,7 +31,8 @@ impl ToChalk for Ty { | |||
31 | TypeCtor::Ref(m) => ref_to_chalk(db, m, apply_ty.parameters), | 31 | TypeCtor::Ref(m) => ref_to_chalk(db, m, apply_ty.parameters), |
32 | TypeCtor::Array => array_to_chalk(db, apply_ty.parameters), | 32 | TypeCtor::Array => array_to_chalk(db, apply_ty.parameters), |
33 | TypeCtor::FnPtr { num_args: _, is_varargs } => { | 33 | TypeCtor::FnPtr { num_args: _, is_varargs } => { |
34 | let substitution = apply_ty.parameters.to_chalk(db).shifted_in(&Interner); | 34 | let substitution = |
35 | chalk_ir::FnSubst(apply_ty.parameters.to_chalk(db).shifted_in(&Interner)); | ||
35 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { | 36 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { |
36 | num_binders: 0, | 37 | num_binders: 0, |
37 | sig: chalk_ir::FnSig { | 38 | sig: chalk_ir::FnSig { |
@@ -183,7 +184,7 @@ impl ToChalk for Ty { | |||
183 | assert_eq!(num_binders, 0); | 184 | assert_eq!(num_binders, 0); |
184 | let parameters: Substs = from_chalk( | 185 | let parameters: Substs = from_chalk( |
185 | db, | 186 | db, |
186 | substitution.shifted_out(&Interner).expect("fn ptr should have no binders"), | 187 | substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), |
187 | ); | 188 | ); |
188 | Ty::Apply(ApplicationTy { | 189 | Ty::Apply(ApplicationTy { |
189 | ctor: TypeCtor::FnPtr { | 190 | ctor: TypeCtor::FnPtr { |
@@ -536,6 +537,7 @@ impl ToChalk for GenericPredicate { | |||
536 | // we don't produce any where clauses with binders and can't currently deal with them | 537 | // we don't produce any where clauses with binders and can't currently deal with them |
537 | match where_clause | 538 | match where_clause |
538 | .skip_binders() | 539 | .skip_binders() |
540 | .clone() | ||
539 | .shifted_out(&Interner) | 541 | .shifted_out(&Interner) |
540 | .expect("unexpected bound vars in where clause") | 542 | .expect("unexpected bound vars in where clause") |
541 | { | 543 | { |
@@ -661,7 +663,12 @@ where | |||
661 | chalk_ir::TyVariableKind::Integer => TyKind::Integer, | 663 | chalk_ir::TyVariableKind::Integer => TyKind::Integer, |
662 | chalk_ir::TyVariableKind::Float => TyKind::Float, | 664 | chalk_ir::TyVariableKind::Float => TyKind::Float, |
663 | }, | 665 | }, |
664 | chalk_ir::VariableKind::Lifetime => panic!("unexpected lifetime from Chalk"), | 666 | // HACK: Chalk can sometimes return new lifetime variables. We |
667 | // want to just skip them, but to not mess up the indices of | ||
668 | // other variables, we'll just create a new type variable in | ||
669 | // their place instead. This should not matter (we never see the | ||
670 | // actual *uses* of the lifetime variable). | ||
671 | chalk_ir::VariableKind::Lifetime => TyKind::General, | ||
665 | chalk_ir::VariableKind::Const(_) => panic!("unexpected const from Chalk"), | 672 | chalk_ir::VariableKind::Const(_) => panic!("unexpected const from Chalk"), |
666 | }) | 673 | }) |
667 | .collect(); | 674 | .collect(); |
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 9d3d88289..c8453edb3 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -135,6 +135,11 @@ pub(crate) fn diagnostics( | |||
135 | res.borrow_mut().push(warning_with_fix(d, &sema)); | 135 | res.borrow_mut().push(warning_with_fix(d, &sema)); |
136 | }) | 136 | }) |
137 | .on::<hir::diagnostics::InactiveCode, _>(|d| { | 137 | .on::<hir::diagnostics::InactiveCode, _>(|d| { |
138 | // If there's inactive code somewhere in a macro, don't propagate to the call-site. | ||
139 | if d.display_source().file_id.expansion_info(db).is_some() { | ||
140 | return; | ||
141 | } | ||
142 | |||
138 | // Override severity and mark as unused. | 143 | // Override severity and mark as unused. |
139 | res.borrow_mut().push( | 144 | res.borrow_mut().push( |
140 | Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) | 145 | Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) |
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 462f5c2b8..dc9621f46 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -1525,9 +1525,7 @@ fn foo() { let bar = Ba<|>r; } | |||
1525 | --- | 1525 | --- |
1526 | 1526 | ||
1527 | bar docs 0 | 1527 | bar docs 0 |
1528 | |||
1529 | bar docs 1 | 1528 | bar docs 1 |
1530 | |||
1531 | bar docs 2 | 1529 | bar docs 2 |
1532 | "#]], | 1530 | "#]], |
1533 | ); | 1531 | ); |
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 5150a970c..f5c6eabef 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs | |||
@@ -726,7 +726,7 @@ fn highlight_method_call( | |||
726 | method_call: &ast::MethodCallExpr, | 726 | method_call: &ast::MethodCallExpr, |
727 | ) -> Option<Highlight> { | 727 | ) -> Option<Highlight> { |
728 | let func = sema.resolve_method_call(&method_call)?; | 728 | let func = sema.resolve_method_call(&method_call)?; |
729 | let mut h = HighlightTag::Function.into(); | 729 | let mut h = HighlightTag::Method.into(); |
730 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { | 730 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { |
731 | h |= HighlightModifier::Unsafe; | 731 | h |= HighlightModifier::Unsafe; |
732 | } | 732 | } |
@@ -755,13 +755,18 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
755 | Definition::ModuleDef(def) => match def { | 755 | Definition::ModuleDef(def) => match def { |
756 | hir::ModuleDef::Module(_) => HighlightTag::Module, | 756 | hir::ModuleDef::Module(_) => HighlightTag::Module, |
757 | hir::ModuleDef::Function(func) => { | 757 | hir::ModuleDef::Function(func) => { |
758 | let mut h = HighlightTag::Function.into(); | 758 | let mut h = if func.as_assoc_item(db).is_some() { |
759 | if func.self_param(db).is_none() { | ||
760 | Highlight::from(HighlightTag::Method) | HighlightModifier::Static | ||
761 | } else { | ||
762 | HighlightTag::Method.into() | ||
763 | } | ||
764 | } else { | ||
765 | HighlightTag::Function.into() | ||
766 | }; | ||
759 | if func.is_unsafe(db) { | 767 | if func.is_unsafe(db) { |
760 | h |= HighlightModifier::Unsafe; | 768 | h |= HighlightModifier::Unsafe; |
761 | } | 769 | } |
762 | if func.as_assoc_item(db).is_some() && func.self_param(db).is_none() { | ||
763 | h |= HighlightModifier::Static; | ||
764 | } | ||
765 | return h; | 770 | return h; |
766 | } | 771 | } |
767 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, | 772 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, |
diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs index 65e0671a5..ffd9588b8 100644 --- a/crates/ide/src/syntax_highlighting/tags.rs +++ b/crates/ide/src/syntax_highlighting/tags.rs | |||
@@ -30,6 +30,7 @@ pub enum HighlightTag { | |||
30 | Keyword, | 30 | Keyword, |
31 | Lifetime, | 31 | Lifetime, |
32 | Macro, | 32 | Macro, |
33 | Method, | ||
33 | Module, | 34 | Module, |
34 | NumericLiteral, | 35 | NumericLiteral, |
35 | Punctuation, | 36 | Punctuation, |
@@ -90,6 +91,7 @@ impl HighlightTag { | |||
90 | HighlightTag::Lifetime => "lifetime", | 91 | HighlightTag::Lifetime => "lifetime", |
91 | HighlightTag::Punctuation => "punctuation", | 92 | HighlightTag::Punctuation => "punctuation", |
92 | HighlightTag::Macro => "macro", | 93 | HighlightTag::Macro => "macro", |
94 | HighlightTag::Method => "method", | ||
93 | HighlightTag::Module => "module", | 95 | HighlightTag::Module => "module", |
94 | HighlightTag::NumericLiteral => "numeric_literal", | 96 | HighlightTag::NumericLiteral => "numeric_literal", |
95 | HighlightTag::Operator => "operator", | 97 | HighlightTag::Operator => "operator", |
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html b/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html index cd80d72b7..6fb606a47 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html | |||
@@ -40,17 +40,17 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
40 | <span class="keyword">struct</span> <span class="struct declaration">foo</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 40 | <span class="keyword">struct</span> <span class="struct declaration">foo</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
41 | 41 | ||
42 | <span class="keyword">impl</span> <span class="struct">foo</span> <span class="punctuation">{</span> | 42 | <span class="keyword">impl</span> <span class="struct">foo</span> <span class="punctuation">{</span> |
43 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration static">is_static</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 43 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method declaration static">is_static</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
44 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">is_not_static</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 44 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method declaration">is_not_static</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
45 | <span class="punctuation">}</span> | 45 | <span class="punctuation">}</span> |
46 | 46 | ||
47 | <span class="keyword">trait</span> <span class="trait declaration">t</span> <span class="punctuation">{</span> | 47 | <span class="keyword">trait</span> <span class="trait declaration">t</span> <span class="punctuation">{</span> |
48 | <span class="keyword">fn</span> <span class="function declaration static">t_is_static</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 48 | <span class="keyword">fn</span> <span class="method declaration static">t_is_static</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
49 | <span class="keyword">fn</span> <span class="function declaration">t_is_not_static</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 49 | <span class="keyword">fn</span> <span class="method declaration">t_is_not_static</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
50 | <span class="punctuation">}</span> | 50 | <span class="punctuation">}</span> |
51 | 51 | ||
52 | <span class="keyword">impl</span> <span class="trait">t</span> <span class="keyword">for</span> <span class="struct">foo</span> <span class="punctuation">{</span> | 52 | <span class="keyword">impl</span> <span class="trait">t</span> <span class="keyword">for</span> <span class="struct">foo</span> <span class="punctuation">{</span> |
53 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration static">is_static</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 53 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method declaration static">is_static</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
54 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">is_not_static</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 54 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method declaration">is_not_static</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
55 | <span class="punctuation">}</span> | 55 | <span class="punctuation">}</span> |
56 | </code></pre> \ No newline at end of file | 56 | </code></pre> \ No newline at end of file |
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html index d79fa6dca..396fd46fb 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html | |||
@@ -53,7 +53,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
53 | <span class="comment documentation">/// #</span><span class="generic injected"> </span><span class="attribute attribute injected">#</span><span class="attribute attribute injected">!</span><span class="attribute attribute injected">[</span><span class="function attribute injected">allow</span><span class="punctuation attribute injected">(</span><span class="attribute attribute injected">unused_mut</span><span class="punctuation attribute injected">)</span><span class="attribute attribute injected">]</span> | 53 | <span class="comment documentation">/// #</span><span class="generic injected"> </span><span class="attribute attribute injected">#</span><span class="attribute attribute injected">!</span><span class="attribute attribute injected">[</span><span class="function attribute injected">allow</span><span class="punctuation attribute injected">(</span><span class="attribute attribute injected">unused_mut</span><span class="punctuation attribute injected">)</span><span class="attribute attribute injected">]</span> |
54 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="keyword injected">mut</span><span class="generic injected"> </span><span class="variable declaration injected mutable">foo</span><span class="punctuation injected">:</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span><span class="punctuation injected"> | 54 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="keyword injected">mut</span><span class="generic injected"> </span><span class="variable declaration injected mutable">foo</span><span class="punctuation injected">:</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="punctuation injected">(</span><span class="punctuation injected">)</span><span class="punctuation injected">;</span><span class="punctuation injected"> |
55 | </span> <span class="comment documentation">/// ```</span> | 55 | </span> <span class="comment documentation">/// ```</span> |
56 | <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration static">new</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="struct">Foo</span> <span class="punctuation">{</span> | 56 | <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="method declaration static">new</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="struct">Foo</span> <span class="punctuation">{</span> |
57 | <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">bar</span><span class="punctuation">:</span> <span class="bool_literal">true</span> <span class="punctuation">}</span> | 57 | <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">bar</span><span class="punctuation">:</span> <span class="bool_literal">true</span> <span class="punctuation">}</span> |
58 | <span class="punctuation">}</span> | 58 | <span class="punctuation">}</span> |
59 | 59 | ||
@@ -87,7 +87,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
87 | <span class="comment documentation">/// ```sh</span> | 87 | <span class="comment documentation">/// ```sh</span> |
88 | <span class="comment documentation">/// echo 1</span> | 88 | <span class="comment documentation">/// echo 1</span> |
89 | <span class="comment documentation">/// ```</span> | 89 | <span class="comment documentation">/// ```</span> |
90 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="punctuation">{</span> | 90 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="method declaration">foo</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="punctuation">{</span> |
91 | <span class="bool_literal">true</span> | 91 | <span class="bool_literal">true</span> |
92 | <span class="punctuation">}</span> | 92 | <span class="punctuation">}</span> |
93 | <span class="punctuation">}</span> | 93 | <span class="punctuation">}</span> |
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html index 57c178916..31daf2bd0 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html | |||
@@ -40,7 +40,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
40 | <span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 40 | <span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
41 | <span class="function">fixture</span><span class="punctuation">(</span><span class="string_literal">r#"</span> | 41 | <span class="function">fixture</span><span class="punctuation">(</span><span class="string_literal">r#"</span> |
42 | <span class="keyword">trait</span> <span class="trait declaration">Foo</span> <span class="punctuation">{</span> | 42 | <span class="keyword">trait</span> <span class="trait declaration">Foo</span> <span class="punctuation">{</span> |
43 | <span class="keyword">fn</span> <span class="function declaration static">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 43 | <span class="keyword">fn</span> <span class="method declaration static">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
44 | <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"2 + 2 = {}"</span><span class="punctuation">,</span> <span class="numeric_literal">4</span><span class="punctuation">)</span><span class="punctuation">;</span> | 44 | <span class="macro">println!</span><span class="punctuation">(</span><span class="string_literal">"2 + 2 = {}"</span><span class="punctuation">,</span> <span class="numeric_literal">4</span><span class="punctuation">)</span><span class="punctuation">;</span> |
45 | <span class="punctuation">}</span> | 45 | <span class="punctuation">}</span> |
46 | <span class="punctuation">}</span><span class="string_literal">"#</span> | 46 | <span class="punctuation">}</span><span class="string_literal">"#</span> |
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html index 1d05b7713..67ec73f15 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html | |||
@@ -45,7 +45,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
45 | <span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span><span class="punctuation">;</span> | 45 | <span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span><span class="punctuation">;</span> |
46 | 46 | ||
47 | <span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> <span class="punctuation">{</span> | 47 | <span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> <span class="punctuation">{</span> |
48 | <span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 48 | <span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="method declaration unsafe">unsafe_method</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
49 | <span class="punctuation">}</span> | 49 | <span class="punctuation">}</span> |
50 | 50 | ||
51 | <span class="keyword">struct</span> <span class="struct declaration">TypeForStaticMut</span> <span class="punctuation">{</span> | 51 | <span class="keyword">struct</span> <span class="struct declaration">TypeForStaticMut</span> <span class="punctuation">{</span> |
@@ -60,11 +60,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
60 | <span class="punctuation">}</span> | 60 | <span class="punctuation">}</span> |
61 | 61 | ||
62 | <span class="keyword">trait</span> <span class="trait declaration">DoTheAutoref</span> <span class="punctuation">{</span> | 62 | <span class="keyword">trait</span> <span class="trait declaration">DoTheAutoref</span> <span class="punctuation">{</span> |
63 | <span class="keyword">fn</span> <span class="function declaration">calls_autoref</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span><span class="punctuation">;</span> | 63 | <span class="keyword">fn</span> <span class="method declaration">calls_autoref</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span><span class="punctuation">;</span> |
64 | <span class="punctuation">}</span> | 64 | <span class="punctuation">}</span> |
65 | 65 | ||
66 | <span class="keyword">impl</span> <span class="trait">DoTheAutoref</span> <span class="keyword">for</span> <span class="builtin_type">u16</span> <span class="punctuation">{</span> | 66 | <span class="keyword">impl</span> <span class="trait">DoTheAutoref</span> <span class="keyword">for</span> <span class="builtin_type">u16</span> <span class="punctuation">{</span> |
67 | <span class="keyword">fn</span> <span class="function declaration">calls_autoref</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> | 67 | <span class="keyword">fn</span> <span class="method declaration">calls_autoref</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> |
68 | <span class="punctuation">}</span> | 68 | <span class="punctuation">}</span> |
69 | 69 | ||
70 | <span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 70 | <span class="keyword">fn</span> <span class="function declaration">main</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
@@ -78,7 +78,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
78 | <span class="union">Union</span> <span class="punctuation">{</span> <span class="field unsafe">b</span><span class="punctuation">:</span> <span class="numeric_literal">0</span> <span class="punctuation">}</span> <span class="operator">=></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span> | 78 | <span class="union">Union</span> <span class="punctuation">{</span> <span class="field unsafe">b</span><span class="punctuation">:</span> <span class="numeric_literal">0</span> <span class="punctuation">}</span> <span class="operator">=></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span> |
79 | <span class="union">Union</span> <span class="punctuation">{</span> <span class="field unsafe">a</span> <span class="punctuation">}</span> <span class="operator">=></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span> | 79 | <span class="union">Union</span> <span class="punctuation">{</span> <span class="field unsafe">a</span> <span class="punctuation">}</span> <span class="operator">=></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span> |
80 | <span class="punctuation">}</span> | 80 | <span class="punctuation">}</span> |
81 | <span class="struct">HasUnsafeFn</span><span class="operator">.</span><span class="function unsafe">unsafe_method</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> | 81 | <span class="struct">HasUnsafeFn</span><span class="operator">.</span><span class="method unsafe">unsafe_method</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> |
82 | 82 | ||
83 | <span class="comment">// unsafe deref</span> | 83 | <span class="comment">// unsafe deref</span> |
84 | <span class="keyword">let</span> <span class="variable declaration">y</span> <span class="operator">=</span> <span class="operator unsafe">*</span><span class="variable">x</span><span class="punctuation">;</span> | 84 | <span class="keyword">let</span> <span class="variable declaration">y</span> <span class="operator">=</span> <span class="operator unsafe">*</span><span class="variable">x</span><span class="punctuation">;</span> |
@@ -94,6 +94,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
94 | <span class="keyword">let</span> <span class="struct">Packed</span> <span class="punctuation">{</span> <span class="field">a</span><span class="punctuation">:</span> <span class="keyword unsafe">ref</span> <span class="variable declaration">_a</span> <span class="punctuation">}</span> <span class="operator">=</span> <span class="variable">packed</span><span class="punctuation">;</span> | 94 | <span class="keyword">let</span> <span class="struct">Packed</span> <span class="punctuation">{</span> <span class="field">a</span><span class="punctuation">:</span> <span class="keyword unsafe">ref</span> <span class="variable declaration">_a</span> <span class="punctuation">}</span> <span class="operator">=</span> <span class="variable">packed</span><span class="punctuation">;</span> |
95 | 95 | ||
96 | <span class="comment">// unsafe auto ref of packed field</span> | 96 | <span class="comment">// unsafe auto ref of packed field</span> |
97 | <span class="variable">packed</span><span class="operator">.</span><span class="field">a</span><span class="operator">.</span><span class="function unsafe">calls_autoref</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> | 97 | <span class="variable">packed</span><span class="operator">.</span><span class="field">a</span><span class="operator">.</span><span class="method unsafe">calls_autoref</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> |
98 | <span class="punctuation">}</span> | 98 | <span class="punctuation">}</span> |
99 | <span class="punctuation">}</span></code></pre> \ No newline at end of file | 99 | <span class="punctuation">}</span></code></pre> \ No newline at end of file |
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index 15fbf2ce3..a3b4f20e8 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html | |||
@@ -62,25 +62,25 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
62 | <span class="punctuation">}</span> | 62 | <span class="punctuation">}</span> |
63 | 63 | ||
64 | <span class="keyword">trait</span> <span class="trait declaration">Bar</span> <span class="punctuation">{</span> | 64 | <span class="keyword">trait</span> <span class="trait declaration">Bar</span> <span class="punctuation">{</span> |
65 | <span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span><span class="punctuation">;</span> | 65 | <span class="keyword">fn</span> <span class="method declaration">bar</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span><span class="punctuation">;</span> |
66 | <span class="punctuation">}</span> | 66 | <span class="punctuation">}</span> |
67 | 67 | ||
68 | <span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> <span class="punctuation">{</span> | 68 | <span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> <span class="punctuation">{</span> |
69 | <span class="keyword">fn</span> <span class="function declaration">bar</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span> | 69 | <span class="keyword">fn</span> <span class="method declaration">bar</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span> |
70 | <span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span> | 70 | <span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span> |
71 | <span class="punctuation">}</span> | 71 | <span class="punctuation">}</span> |
72 | <span class="punctuation">}</span> | 72 | <span class="punctuation">}</span> |
73 | 73 | ||
74 | <span class="keyword">impl</span> <span class="struct">Foo</span> <span class="punctuation">{</span> | 74 | <span class="keyword">impl</span> <span class="struct">Foo</span> <span class="punctuation">{</span> |
75 | <span class="keyword">fn</span> <span class="function declaration">baz</span><span class="punctuation">(</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">,</span> <span class="value_param declaration">f</span><span class="punctuation">:</span> <span class="struct">Foo</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span> | 75 | <span class="keyword">fn</span> <span class="method declaration">baz</span><span class="punctuation">(</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">,</span> <span class="value_param declaration">f</span><span class="punctuation">:</span> <span class="struct">Foo</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span> |
76 | <span class="value_param">f</span><span class="operator">.</span><span class="function consuming">baz</span><span class="punctuation">(</span><span class="self_keyword mutable consuming">self</span><span class="punctuation">)</span> | 76 | <span class="value_param">f</span><span class="operator">.</span><span class="method consuming">baz</span><span class="punctuation">(</span><span class="self_keyword mutable consuming">self</span><span class="punctuation">)</span> |
77 | <span class="punctuation">}</span> | 77 | <span class="punctuation">}</span> |
78 | 78 | ||
79 | <span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 79 | <span class="keyword">fn</span> <span class="method declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
80 | <span class="self_keyword mutable">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> | 80 | <span class="self_keyword mutable">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> |
81 | <span class="punctuation">}</span> | 81 | <span class="punctuation">}</span> |
82 | 82 | ||
83 | <span class="keyword">fn</span> <span class="function declaration">quop</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span> | 83 | <span class="keyword">fn</span> <span class="method declaration">quop</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="punctuation">{</span> |
84 | <span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span> | 84 | <span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span> |
85 | <span class="punctuation">}</span> | 85 | <span class="punctuation">}</span> |
86 | <span class="punctuation">}</span> | 86 | <span class="punctuation">}</span> |
@@ -91,15 +91,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
91 | <span class="punctuation">}</span> | 91 | <span class="punctuation">}</span> |
92 | 92 | ||
93 | <span class="keyword">impl</span> <span class="struct">FooCopy</span> <span class="punctuation">{</span> | 93 | <span class="keyword">impl</span> <span class="struct">FooCopy</span> <span class="punctuation">{</span> |
94 | <span class="keyword">fn</span> <span class="function declaration">baz</span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">,</span> <span class="value_param declaration">f</span><span class="punctuation">:</span> <span class="struct">FooCopy</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="punctuation">{</span> | 94 | <span class="keyword">fn</span> <span class="method declaration">baz</span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">,</span> <span class="value_param declaration">f</span><span class="punctuation">:</span> <span class="struct">FooCopy</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="punctuation">{</span> |
95 | <span class="value_param">f</span><span class="operator">.</span><span class="function">baz</span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">)</span> | 95 | <span class="value_param">f</span><span class="operator">.</span><span class="method">baz</span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">)</span> |
96 | <span class="punctuation">}</span> | 96 | <span class="punctuation">}</span> |
97 | 97 | ||
98 | <span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 98 | <span class="keyword">fn</span> <span class="method declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
99 | <span class="self_keyword mutable">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> | 99 | <span class="self_keyword mutable">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> |
100 | <span class="punctuation">}</span> | 100 | <span class="punctuation">}</span> |
101 | 101 | ||
102 | <span class="keyword">fn</span> <span class="function declaration">quop</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="punctuation">{</span> | 102 | <span class="keyword">fn</span> <span class="method declaration">quop</span><span class="punctuation">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="punctuation">)</span> <span class="operator">-></span> <span class="builtin_type">u32</span> <span class="punctuation">{</span> |
103 | <span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span> | 103 | <span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span> |
104 | <span class="punctuation">}</span> | 104 | <span class="punctuation">}</span> |
105 | <span class="punctuation">}</span> | 105 | <span class="punctuation">}</span> |
@@ -175,17 +175,17 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
175 | 175 | ||
176 | <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">,</span> <span class="field">y</span><span class="punctuation">:</span> <span class="variable mutable">x</span> <span class="punctuation">}</span><span class="punctuation">;</span> | 176 | <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">,</span> <span class="field">y</span><span class="punctuation">:</span> <span class="variable mutable">x</span> <span class="punctuation">}</span><span class="punctuation">;</span> |
177 | <span class="keyword">let</span> <span class="variable declaration">foo2</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">,</span> <span class="field">y</span><span class="punctuation">:</span> <span class="variable mutable">x</span> <span class="punctuation">}</span><span class="punctuation">;</span> | 177 | <span class="keyword">let</span> <span class="variable declaration">foo2</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="punctuation">{</span> <span class="field">x</span><span class="punctuation">,</span> <span class="field">y</span><span class="punctuation">:</span> <span class="variable mutable">x</span> <span class="punctuation">}</span><span class="punctuation">;</span> |
178 | <span class="variable mutable">foo</span><span class="operator">.</span><span class="function">quop</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> | 178 | <span class="variable mutable">foo</span><span class="operator">.</span><span class="method">quop</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> |
179 | <span class="variable mutable">foo</span><span class="operator">.</span><span class="function mutable">qux</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> | 179 | <span class="variable mutable">foo</span><span class="operator">.</span><span class="method mutable">qux</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> |
180 | <span class="variable mutable">foo</span><span class="operator">.</span><span class="function consuming">baz</span><span class="punctuation">(</span><span class="variable consuming">foo2</span><span class="punctuation">)</span><span class="punctuation">;</span> | 180 | <span class="variable mutable">foo</span><span class="operator">.</span><span class="method consuming">baz</span><span class="punctuation">(</span><span class="variable consuming">foo2</span><span class="punctuation">)</span><span class="punctuation">;</span> |
181 | 181 | ||
182 | <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">copy</span> <span class="operator">=</span> <span class="struct">FooCopy</span> <span class="punctuation">{</span> <span class="field">x</span> <span class="punctuation">}</span><span class="punctuation">;</span> | 182 | <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">copy</span> <span class="operator">=</span> <span class="struct">FooCopy</span> <span class="punctuation">{</span> <span class="field">x</span> <span class="punctuation">}</span><span class="punctuation">;</span> |
183 | <span class="variable mutable">copy</span><span class="operator">.</span><span class="function">quop</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> | 183 | <span class="variable mutable">copy</span><span class="operator">.</span><span class="method">quop</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> |
184 | <span class="variable mutable">copy</span><span class="operator">.</span><span class="function mutable">qux</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> | 184 | <span class="variable mutable">copy</span><span class="operator">.</span><span class="method mutable">qux</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span> |
185 | <span class="variable mutable">copy</span><span class="operator">.</span><span class="function">baz</span><span class="punctuation">(</span><span class="variable mutable">copy</span><span class="punctuation">)</span><span class="punctuation">;</span> | 185 | <span class="variable mutable">copy</span><span class="operator">.</span><span class="method">baz</span><span class="punctuation">(</span><span class="variable mutable">copy</span><span class="punctuation">)</span><span class="punctuation">;</span> |
186 | 186 | ||
187 | <span class="keyword">let</span> <span class="variable declaration callable">a</span> <span class="operator">=</span> <span class="punctuation">|</span><span class="value_param declaration">x</span><span class="punctuation">|</span> <span class="value_param">x</span><span class="punctuation">;</span> | 187 | <span class="keyword">let</span> <span class="variable declaration callable">a</span> <span class="operator">=</span> <span class="punctuation">|</span><span class="value_param declaration">x</span><span class="punctuation">|</span> <span class="value_param">x</span><span class="punctuation">;</span> |
188 | <span class="keyword">let</span> <span class="variable declaration callable">bar</span> <span class="operator">=</span> <span class="struct">Foo</span><span class="operator">::</span><span class="function">baz</span><span class="punctuation">;</span> | 188 | <span class="keyword">let</span> <span class="variable declaration callable">bar</span> <span class="operator">=</span> <span class="struct">Foo</span><span class="operator">::</span><span class="method">baz</span><span class="punctuation">;</span> |
189 | 189 | ||
190 | <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="punctuation">;</span> | 190 | <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="punctuation">;</span> |
191 | <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="punctuation">;</span> | 191 | <span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="punctuation">;</span> |
@@ -200,7 +200,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
200 | <span class="keyword">use</span> <span class="enum">Option</span><span class="operator">::</span><span class="punctuation">*</span><span class="punctuation">;</span> | 200 | <span class="keyword">use</span> <span class="enum">Option</span><span class="operator">::</span><span class="punctuation">*</span><span class="punctuation">;</span> |
201 | 201 | ||
202 | <span class="keyword">impl</span><span class="punctuation"><</span><span class="type_param declaration">T</span><span class="punctuation">></span> <span class="enum">Option</span><span class="punctuation"><</span><span class="type_param">T</span><span class="punctuation">></span> <span class="punctuation">{</span> | 202 | <span class="keyword">impl</span><span class="punctuation"><</span><span class="type_param declaration">T</span><span class="punctuation">></span> <span class="enum">Option</span><span class="punctuation"><</span><span class="type_param">T</span><span class="punctuation">></span> <span class="punctuation">{</span> |
203 | <span class="keyword">fn</span> <span class="function declaration">and</span><span class="punctuation"><</span><span class="type_param declaration">U</span><span class="punctuation">></span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">,</span> <span class="value_param declaration">other</span><span class="punctuation">:</span> <span class="enum">Option</span><span class="punctuation"><</span><span class="type_param">U</span><span class="punctuation">></span><span class="punctuation">)</span> <span class="operator">-></span> <span class="enum">Option</span><span class="punctuation"><</span><span class="punctuation">(</span><span class="type_param">T</span><span class="punctuation">,</span> <span class="type_param">U</span><span class="punctuation">)</span><span class="punctuation">></span> <span class="punctuation">{</span> | 203 | <span class="keyword">fn</span> <span class="method declaration">and</span><span class="punctuation"><</span><span class="type_param declaration">U</span><span class="punctuation">></span><span class="punctuation">(</span><span class="self_keyword">self</span><span class="punctuation">,</span> <span class="value_param declaration">other</span><span class="punctuation">:</span> <span class="enum">Option</span><span class="punctuation"><</span><span class="type_param">U</span><span class="punctuation">></span><span class="punctuation">)</span> <span class="operator">-></span> <span class="enum">Option</span><span class="punctuation"><</span><span class="punctuation">(</span><span class="type_param">T</span><span class="punctuation">,</span> <span class="type_param">U</span><span class="punctuation">)</span><span class="punctuation">></span> <span class="punctuation">{</span> |
204 | <span class="keyword control">match</span> <span class="value_param">other</span> <span class="punctuation">{</span> | 204 | <span class="keyword control">match</span> <span class="value_param">other</span> <span class="punctuation">{</span> |
205 | <span class="enum_variant">None</span> <span class="operator">=></span> <span class="macro">unimplemented!</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span> | 205 | <span class="enum_variant">None</span> <span class="operator">=></span> <span class="macro">unimplemented!</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span> |
206 | <span class="variable declaration">Nope</span> <span class="operator">=></span> <span class="variable">Nope</span><span class="punctuation">,</span> | 206 | <span class="variable declaration">Nope</span> <span class="operator">=></span> <span class="variable">Nope</span><span class="punctuation">,</span> |
diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs index 83a602b9a..615fa7b0e 100644 --- a/crates/ide_db/src/call_info.rs +++ b/crates/ide_db/src/call_info.rs | |||
@@ -228,529 +228,4 @@ impl FnCallNode { | |||
228 | } | 228 | } |
229 | 229 | ||
230 | #[cfg(test)] | 230 | #[cfg(test)] |
231 | mod tests { | 231 | mod tests; |
232 | use crate::RootDatabase; | ||
233 | use base_db::{fixture::ChangeFixture, FilePosition}; | ||
234 | use expect_test::{expect, Expect}; | ||
235 | use test_utils::{mark, RangeOrOffset}; | ||
236 | |||
237 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. | ||
238 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { | ||
239 | let change_fixture = ChangeFixture::parse(ra_fixture); | ||
240 | let mut database = RootDatabase::default(); | ||
241 | database.apply_change(change_fixture.change); | ||
242 | let (file_id, range_or_offset) = | ||
243 | change_fixture.file_position.expect("expected a marker (<|>)"); | ||
244 | let offset = match range_or_offset { | ||
245 | RangeOrOffset::Range(_) => panic!(), | ||
246 | RangeOrOffset::Offset(it) => it, | ||
247 | }; | ||
248 | (database, FilePosition { file_id, offset }) | ||
249 | } | ||
250 | |||
251 | fn check(ra_fixture: &str, expect: Expect) { | ||
252 | let (db, position) = position(ra_fixture); | ||
253 | let call_info = crate::call_info::call_info(&db, position); | ||
254 | let actual = match call_info { | ||
255 | Some(call_info) => { | ||
256 | let docs = match &call_info.doc { | ||
257 | None => "".to_string(), | ||
258 | Some(docs) => format!("{}\n------\n", docs.as_str()), | ||
259 | }; | ||
260 | let params = call_info | ||
261 | .parameter_labels() | ||
262 | .enumerate() | ||
263 | .map(|(i, param)| { | ||
264 | if Some(i) == call_info.active_parameter { | ||
265 | format!("<{}>", param) | ||
266 | } else { | ||
267 | param.to_string() | ||
268 | } | ||
269 | }) | ||
270 | .collect::<Vec<_>>() | ||
271 | .join(", "); | ||
272 | format!("{}{}\n({})\n", docs, call_info.signature, params) | ||
273 | } | ||
274 | None => String::new(), | ||
275 | }; | ||
276 | expect.assert_eq(&actual); | ||
277 | } | ||
278 | |||
279 | #[test] | ||
280 | fn test_fn_signature_two_args() { | ||
281 | check( | ||
282 | r#" | ||
283 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
284 | fn bar() { foo(<|>3, ); } | ||
285 | "#, | ||
286 | expect![[r#" | ||
287 | fn foo(x: u32, y: u32) -> u32 | ||
288 | (<x: u32>, y: u32) | ||
289 | "#]], | ||
290 | ); | ||
291 | check( | ||
292 | r#" | ||
293 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
294 | fn bar() { foo(3<|>, ); } | ||
295 | "#, | ||
296 | expect![[r#" | ||
297 | fn foo(x: u32, y: u32) -> u32 | ||
298 | (<x: u32>, y: u32) | ||
299 | "#]], | ||
300 | ); | ||
301 | check( | ||
302 | r#" | ||
303 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
304 | fn bar() { foo(3,<|> ); } | ||
305 | "#, | ||
306 | expect![[r#" | ||
307 | fn foo(x: u32, y: u32) -> u32 | ||
308 | (x: u32, <y: u32>) | ||
309 | "#]], | ||
310 | ); | ||
311 | check( | ||
312 | r#" | ||
313 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
314 | fn bar() { foo(3, <|>); } | ||
315 | "#, | ||
316 | expect![[r#" | ||
317 | fn foo(x: u32, y: u32) -> u32 | ||
318 | (x: u32, <y: u32>) | ||
319 | "#]], | ||
320 | ); | ||
321 | } | ||
322 | |||
323 | #[test] | ||
324 | fn test_fn_signature_two_args_empty() { | ||
325 | check( | ||
326 | r#" | ||
327 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
328 | fn bar() { foo(<|>); } | ||
329 | "#, | ||
330 | expect![[r#" | ||
331 | fn foo(x: u32, y: u32) -> u32 | ||
332 | (<x: u32>, y: u32) | ||
333 | "#]], | ||
334 | ); | ||
335 | } | ||
336 | |||
337 | #[test] | ||
338 | fn test_fn_signature_two_args_first_generics() { | ||
339 | check( | ||
340 | r#" | ||
341 | fn foo<T, U: Copy + Display>(x: T, y: U) -> u32 | ||
342 | where T: Copy + Display, U: Debug | ||
343 | { x + y } | ||
344 | |||
345 | fn bar() { foo(<|>3, ); } | ||
346 | "#, | ||
347 | expect![[r#" | ||
348 | fn foo(x: i32, y: {unknown}) -> u32 | ||
349 | (<x: i32>, y: {unknown}) | ||
350 | "#]], | ||
351 | ); | ||
352 | } | ||
353 | |||
354 | #[test] | ||
355 | fn test_fn_signature_no_params() { | ||
356 | check( | ||
357 | r#" | ||
358 | fn foo<T>() -> T where T: Copy + Display {} | ||
359 | fn bar() { foo(<|>); } | ||
360 | "#, | ||
361 | expect![[r#" | ||
362 | fn foo() -> {unknown} | ||
363 | () | ||
364 | "#]], | ||
365 | ); | ||
366 | } | ||
367 | |||
368 | #[test] | ||
369 | fn test_fn_signature_for_impl() { | ||
370 | check( | ||
371 | r#" | ||
372 | struct F; | ||
373 | impl F { pub fn new() { } } | ||
374 | fn bar() { | ||
375 | let _ : F = F::new(<|>); | ||
376 | } | ||
377 | "#, | ||
378 | expect![[r#" | ||
379 | fn new() | ||
380 | () | ||
381 | "#]], | ||
382 | ); | ||
383 | } | ||
384 | |||
385 | #[test] | ||
386 | fn test_fn_signature_for_method_self() { | ||
387 | check( | ||
388 | r#" | ||
389 | struct S; | ||
390 | impl S { pub fn do_it(&self) {} } | ||
391 | |||
392 | fn bar() { | ||
393 | let s: S = S; | ||
394 | s.do_it(<|>); | ||
395 | } | ||
396 | "#, | ||
397 | expect![[r#" | ||
398 | fn do_it(&self) | ||
399 | () | ||
400 | "#]], | ||
401 | ); | ||
402 | } | ||
403 | |||
404 | #[test] | ||
405 | fn test_fn_signature_for_method_with_arg() { | ||
406 | check( | ||
407 | r#" | ||
408 | struct S; | ||
409 | impl S { | ||
410 | fn foo(&self, x: i32) {} | ||
411 | } | ||
412 | |||
413 | fn main() { S.foo(<|>); } | ||
414 | "#, | ||
415 | expect![[r#" | ||
416 | fn foo(&self, x: i32) | ||
417 | (<x: i32>) | ||
418 | "#]], | ||
419 | ); | ||
420 | } | ||
421 | |||
422 | #[test] | ||
423 | fn test_fn_signature_for_method_with_arg_as_assoc_fn() { | ||
424 | check( | ||
425 | r#" | ||
426 | struct S; | ||
427 | impl S { | ||
428 | fn foo(&self, x: i32) {} | ||
429 | } | ||
430 | |||
431 | fn main() { S::foo(<|>); } | ||
432 | "#, | ||
433 | expect![[r#" | ||
434 | fn foo(self: &S, x: i32) | ||
435 | (<self: &S>, x: i32) | ||
436 | "#]], | ||
437 | ); | ||
438 | } | ||
439 | |||
440 | #[test] | ||
441 | fn test_fn_signature_with_docs_simple() { | ||
442 | check( | ||
443 | r#" | ||
444 | /// test | ||
445 | // non-doc-comment | ||
446 | fn foo(j: u32) -> u32 { | ||
447 | j | ||
448 | } | ||
449 | |||
450 | fn bar() { | ||
451 | let _ = foo(<|>); | ||
452 | } | ||
453 | "#, | ||
454 | expect![[r#" | ||
455 | test | ||
456 | ------ | ||
457 | fn foo(j: u32) -> u32 | ||
458 | (<j: u32>) | ||
459 | "#]], | ||
460 | ); | ||
461 | } | ||
462 | |||
463 | #[test] | ||
464 | fn test_fn_signature_with_docs() { | ||
465 | check( | ||
466 | r#" | ||
467 | /// Adds one to the number given. | ||
468 | /// | ||
469 | /// # Examples | ||
470 | /// | ||
471 | /// ``` | ||
472 | /// let five = 5; | ||
473 | /// | ||
474 | /// assert_eq!(6, my_crate::add_one(5)); | ||
475 | /// ``` | ||
476 | pub fn add_one(x: i32) -> i32 { | ||
477 | x + 1 | ||
478 | } | ||
479 | |||
480 | pub fn do() { | ||
481 | add_one(<|> | ||
482 | }"#, | ||
483 | expect![[r##" | ||
484 | Adds one to the number given. | ||
485 | |||
486 | # Examples | ||
487 | |||
488 | ``` | ||
489 | let five = 5; | ||
490 | |||
491 | assert_eq!(6, my_crate::add_one(5)); | ||
492 | ``` | ||
493 | ------ | ||
494 | fn add_one(x: i32) -> i32 | ||
495 | (<x: i32>) | ||
496 | "##]], | ||
497 | ); | ||
498 | } | ||
499 | |||
500 | #[test] | ||
501 | fn test_fn_signature_with_docs_impl() { | ||
502 | check( | ||
503 | r#" | ||
504 | struct addr; | ||
505 | impl addr { | ||
506 | /// Adds one to the number given. | ||
507 | /// | ||
508 | /// # Examples | ||
509 | /// | ||
510 | /// ``` | ||
511 | /// let five = 5; | ||
512 | /// | ||
513 | /// assert_eq!(6, my_crate::add_one(5)); | ||
514 | /// ``` | ||
515 | pub fn add_one(x: i32) -> i32 { | ||
516 | x + 1 | ||
517 | } | ||
518 | } | ||
519 | |||
520 | pub fn do_it() { | ||
521 | addr {}; | ||
522 | addr::add_one(<|>); | ||
523 | } | ||
524 | "#, | ||
525 | expect![[r##" | ||
526 | Adds one to the number given. | ||
527 | |||
528 | # Examples | ||
529 | |||
530 | ``` | ||
531 | let five = 5; | ||
532 | |||
533 | assert_eq!(6, my_crate::add_one(5)); | ||
534 | ``` | ||
535 | ------ | ||
536 | fn add_one(x: i32) -> i32 | ||
537 | (<x: i32>) | ||
538 | "##]], | ||
539 | ); | ||
540 | } | ||
541 | |||
542 | #[test] | ||
543 | fn test_fn_signature_with_docs_from_actix() { | ||
544 | check( | ||
545 | r#" | ||
546 | struct WriteHandler<E>; | ||
547 | |||
548 | impl<E> WriteHandler<E> { | ||
549 | /// Method is called when writer emits error. | ||
550 | /// | ||
551 | /// If this method returns `ErrorAction::Continue` writer processing | ||
552 | /// continues otherwise stream processing stops. | ||
553 | fn error(&mut self, err: E, ctx: &mut Self::Context) -> Running { | ||
554 | Running::Stop | ||
555 | } | ||
556 | |||
557 | /// Method is called when writer finishes. | ||
558 | /// | ||
559 | /// By default this method stops actor's `Context`. | ||
560 | fn finished(&mut self, ctx: &mut Self::Context) { | ||
561 | ctx.stop() | ||
562 | } | ||
563 | } | ||
564 | |||
565 | pub fn foo(mut r: WriteHandler<()>) { | ||
566 | r.finished(<|>); | ||
567 | } | ||
568 | "#, | ||
569 | expect![[r#" | ||
570 | Method is called when writer finishes. | ||
571 | |||
572 | By default this method stops actor's `Context`. | ||
573 | ------ | ||
574 | fn finished(&mut self, ctx: &mut {unknown}) | ||
575 | (<ctx: &mut {unknown}>) | ||
576 | "#]], | ||
577 | ); | ||
578 | } | ||
579 | |||
580 | #[test] | ||
581 | fn call_info_bad_offset() { | ||
582 | mark::check!(call_info_bad_offset); | ||
583 | check( | ||
584 | r#" | ||
585 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
586 | fn bar() { foo <|> (3, ); } | ||
587 | "#, | ||
588 | expect![[""]], | ||
589 | ); | ||
590 | } | ||
591 | |||
592 | #[test] | ||
593 | fn test_nested_method_in_lambda() { | ||
594 | check( | ||
595 | r#" | ||
596 | struct Foo; | ||
597 | impl Foo { fn bar(&self, _: u32) { } } | ||
598 | |||
599 | fn bar(_: u32) { } | ||
600 | |||
601 | fn main() { | ||
602 | let foo = Foo; | ||
603 | std::thread::spawn(move || foo.bar(<|>)); | ||
604 | } | ||
605 | "#, | ||
606 | expect![[r#" | ||
607 | fn bar(&self, _: u32) | ||
608 | (<_: u32>) | ||
609 | "#]], | ||
610 | ); | ||
611 | } | ||
612 | |||
613 | #[test] | ||
614 | fn works_for_tuple_structs() { | ||
615 | check( | ||
616 | r#" | ||
617 | /// A cool tuple struct | ||
618 | struct S(u32, i32); | ||
619 | fn main() { | ||
620 | let s = S(0, <|>); | ||
621 | } | ||
622 | "#, | ||
623 | expect![[r#" | ||
624 | A cool tuple struct | ||
625 | ------ | ||
626 | struct S(u32, i32) | ||
627 | (u32, <i32>) | ||
628 | "#]], | ||
629 | ); | ||
630 | } | ||
631 | |||
632 | #[test] | ||
633 | fn generic_struct() { | ||
634 | check( | ||
635 | r#" | ||
636 | struct S<T>(T); | ||
637 | fn main() { | ||
638 | let s = S(<|>); | ||
639 | } | ||
640 | "#, | ||
641 | expect![[r#" | ||
642 | struct S({unknown}) | ||
643 | (<{unknown}>) | ||
644 | "#]], | ||
645 | ); | ||
646 | } | ||
647 | |||
648 | #[test] | ||
649 | fn works_for_enum_variants() { | ||
650 | check( | ||
651 | r#" | ||
652 | enum E { | ||
653 | /// A Variant | ||
654 | A(i32), | ||
655 | /// Another | ||
656 | B, | ||
657 | /// And C | ||
658 | C { a: i32, b: i32 } | ||
659 | } | ||
660 | |||
661 | fn main() { | ||
662 | let a = E::A(<|>); | ||
663 | } | ||
664 | "#, | ||
665 | expect![[r#" | ||
666 | A Variant | ||
667 | ------ | ||
668 | enum E::A(i32) | ||
669 | (<i32>) | ||
670 | "#]], | ||
671 | ); | ||
672 | } | ||
673 | |||
674 | #[test] | ||
675 | fn cant_call_struct_record() { | ||
676 | check( | ||
677 | r#" | ||
678 | struct S { x: u32, y: i32 } | ||
679 | fn main() { | ||
680 | let s = S(<|>); | ||
681 | } | ||
682 | "#, | ||
683 | expect![[""]], | ||
684 | ); | ||
685 | } | ||
686 | |||
687 | #[test] | ||
688 | fn cant_call_enum_record() { | ||
689 | check( | ||
690 | r#" | ||
691 | enum E { | ||
692 | /// A Variant | ||
693 | A(i32), | ||
694 | /// Another | ||
695 | B, | ||
696 | /// And C | ||
697 | C { a: i32, b: i32 } | ||
698 | } | ||
699 | |||
700 | fn main() { | ||
701 | let a = E::C(<|>); | ||
702 | } | ||
703 | "#, | ||
704 | expect![[""]], | ||
705 | ); | ||
706 | } | ||
707 | |||
708 | #[test] | ||
709 | fn fn_signature_for_call_in_macro() { | ||
710 | check( | ||
711 | r#" | ||
712 | macro_rules! id { ($($tt:tt)*) => { $($tt)* } } | ||
713 | fn foo() { } | ||
714 | id! { | ||
715 | fn bar() { foo(<|>); } | ||
716 | } | ||
717 | "#, | ||
718 | expect![[r#" | ||
719 | fn foo() | ||
720 | () | ||
721 | "#]], | ||
722 | ); | ||
723 | } | ||
724 | |||
725 | #[test] | ||
726 | fn call_info_for_lambdas() { | ||
727 | check( | ||
728 | r#" | ||
729 | struct S; | ||
730 | fn foo(s: S) -> i32 { 92 } | ||
731 | fn main() { | ||
732 | (|s| foo(s))(<|>) | ||
733 | } | ||
734 | "#, | ||
735 | expect![[r#" | ||
736 | (S) -> i32 | ||
737 | (<S>) | ||
738 | "#]], | ||
739 | ) | ||
740 | } | ||
741 | |||
742 | #[test] | ||
743 | fn call_info_for_fn_ptr() { | ||
744 | check( | ||
745 | r#" | ||
746 | fn main(f: fn(i32, f64) -> char) { | ||
747 | f(0, <|>) | ||
748 | } | ||
749 | "#, | ||
750 | expect![[r#" | ||
751 | (i32, f64) -> char | ||
752 | (i32, <f64>) | ||
753 | "#]], | ||
754 | ) | ||
755 | } | ||
756 | } | ||
diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs new file mode 100644 index 000000000..9335aeaa5 --- /dev/null +++ b/crates/ide_db/src/call_info/tests.rs | |||
@@ -0,0 +1,523 @@ | |||
1 | use crate::RootDatabase; | ||
2 | use base_db::{fixture::ChangeFixture, FilePosition}; | ||
3 | use expect_test::{expect, Expect}; | ||
4 | use test_utils::{mark, RangeOrOffset}; | ||
5 | |||
6 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. | ||
7 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { | ||
8 | let change_fixture = ChangeFixture::parse(ra_fixture); | ||
9 | let mut database = RootDatabase::default(); | ||
10 | database.apply_change(change_fixture.change); | ||
11 | let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); | ||
12 | let offset = match range_or_offset { | ||
13 | RangeOrOffset::Range(_) => panic!(), | ||
14 | RangeOrOffset::Offset(it) => it, | ||
15 | }; | ||
16 | (database, FilePosition { file_id, offset }) | ||
17 | } | ||
18 | |||
19 | fn check(ra_fixture: &str, expect: Expect) { | ||
20 | let (db, position) = position(ra_fixture); | ||
21 | let call_info = crate::call_info::call_info(&db, position); | ||
22 | let actual = match call_info { | ||
23 | Some(call_info) => { | ||
24 | let docs = match &call_info.doc { | ||
25 | None => "".to_string(), | ||
26 | Some(docs) => format!("{}\n------\n", docs.as_str()), | ||
27 | }; | ||
28 | let params = call_info | ||
29 | .parameter_labels() | ||
30 | .enumerate() | ||
31 | .map(|(i, param)| { | ||
32 | if Some(i) == call_info.active_parameter { | ||
33 | format!("<{}>", param) | ||
34 | } else { | ||
35 | param.to_string() | ||
36 | } | ||
37 | }) | ||
38 | .collect::<Vec<_>>() | ||
39 | .join(", "); | ||
40 | format!("{}{}\n({})\n", docs, call_info.signature, params) | ||
41 | } | ||
42 | None => String::new(), | ||
43 | }; | ||
44 | expect.assert_eq(&actual); | ||
45 | } | ||
46 | |||
47 | #[test] | ||
48 | fn test_fn_signature_two_args() { | ||
49 | check( | ||
50 | r#" | ||
51 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
52 | fn bar() { foo(<|>3, ); } | ||
53 | "#, | ||
54 | expect![[r#" | ||
55 | fn foo(x: u32, y: u32) -> u32 | ||
56 | (<x: u32>, y: u32) | ||
57 | "#]], | ||
58 | ); | ||
59 | check( | ||
60 | r#" | ||
61 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
62 | fn bar() { foo(3<|>, ); } | ||
63 | "#, | ||
64 | expect![[r#" | ||
65 | fn foo(x: u32, y: u32) -> u32 | ||
66 | (<x: u32>, y: u32) | ||
67 | "#]], | ||
68 | ); | ||
69 | check( | ||
70 | r#" | ||
71 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
72 | fn bar() { foo(3,<|> ); } | ||
73 | "#, | ||
74 | expect![[r#" | ||
75 | fn foo(x: u32, y: u32) -> u32 | ||
76 | (x: u32, <y: u32>) | ||
77 | "#]], | ||
78 | ); | ||
79 | check( | ||
80 | r#" | ||
81 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
82 | fn bar() { foo(3, <|>); } | ||
83 | "#, | ||
84 | expect![[r#" | ||
85 | fn foo(x: u32, y: u32) -> u32 | ||
86 | (x: u32, <y: u32>) | ||
87 | "#]], | ||
88 | ); | ||
89 | } | ||
90 | |||
91 | #[test] | ||
92 | fn test_fn_signature_two_args_empty() { | ||
93 | check( | ||
94 | r#" | ||
95 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
96 | fn bar() { foo(<|>); } | ||
97 | "#, | ||
98 | expect![[r#" | ||
99 | fn foo(x: u32, y: u32) -> u32 | ||
100 | (<x: u32>, y: u32) | ||
101 | "#]], | ||
102 | ); | ||
103 | } | ||
104 | |||
105 | #[test] | ||
106 | fn test_fn_signature_two_args_first_generics() { | ||
107 | check( | ||
108 | r#" | ||
109 | fn foo<T, U: Copy + Display>(x: T, y: U) -> u32 | ||
110 | where T: Copy + Display, U: Debug | ||
111 | { x + y } | ||
112 | |||
113 | fn bar() { foo(<|>3, ); } | ||
114 | "#, | ||
115 | expect![[r#" | ||
116 | fn foo(x: i32, y: {unknown}) -> u32 | ||
117 | (<x: i32>, y: {unknown}) | ||
118 | "#]], | ||
119 | ); | ||
120 | } | ||
121 | |||
122 | #[test] | ||
123 | fn test_fn_signature_no_params() { | ||
124 | check( | ||
125 | r#" | ||
126 | fn foo<T>() -> T where T: Copy + Display {} | ||
127 | fn bar() { foo(<|>); } | ||
128 | "#, | ||
129 | expect![[r#" | ||
130 | fn foo() -> {unknown} | ||
131 | () | ||
132 | "#]], | ||
133 | ); | ||
134 | } | ||
135 | |||
136 | #[test] | ||
137 | fn test_fn_signature_for_impl() { | ||
138 | check( | ||
139 | r#" | ||
140 | struct F; | ||
141 | impl F { pub fn new() { } } | ||
142 | fn bar() { | ||
143 | let _ : F = F::new(<|>); | ||
144 | } | ||
145 | "#, | ||
146 | expect![[r#" | ||
147 | fn new() | ||
148 | () | ||
149 | "#]], | ||
150 | ); | ||
151 | } | ||
152 | |||
153 | #[test] | ||
154 | fn test_fn_signature_for_method_self() { | ||
155 | check( | ||
156 | r#" | ||
157 | struct S; | ||
158 | impl S { pub fn do_it(&self) {} } | ||
159 | |||
160 | fn bar() { | ||
161 | let s: S = S; | ||
162 | s.do_it(<|>); | ||
163 | } | ||
164 | "#, | ||
165 | expect![[r#" | ||
166 | fn do_it(&self) | ||
167 | () | ||
168 | "#]], | ||
169 | ); | ||
170 | } | ||
171 | |||
172 | #[test] | ||
173 | fn test_fn_signature_for_method_with_arg() { | ||
174 | check( | ||
175 | r#" | ||
176 | struct S; | ||
177 | impl S { | ||
178 | fn foo(&self, x: i32) {} | ||
179 | } | ||
180 | |||
181 | fn main() { S.foo(<|>); } | ||
182 | "#, | ||
183 | expect![[r#" | ||
184 | fn foo(&self, x: i32) | ||
185 | (<x: i32>) | ||
186 | "#]], | ||
187 | ); | ||
188 | } | ||
189 | |||
190 | #[test] | ||
191 | fn test_fn_signature_for_method_with_arg_as_assoc_fn() { | ||
192 | check( | ||
193 | r#" | ||
194 | struct S; | ||
195 | impl S { | ||
196 | fn foo(&self, x: i32) {} | ||
197 | } | ||
198 | |||
199 | fn main() { S::foo(<|>); } | ||
200 | "#, | ||
201 | expect![[r#" | ||
202 | fn foo(self: &S, x: i32) | ||
203 | (<self: &S>, x: i32) | ||
204 | "#]], | ||
205 | ); | ||
206 | } | ||
207 | |||
208 | #[test] | ||
209 | fn test_fn_signature_with_docs_simple() { | ||
210 | check( | ||
211 | r#" | ||
212 | /// test | ||
213 | // non-doc-comment | ||
214 | fn foo(j: u32) -> u32 { | ||
215 | j | ||
216 | } | ||
217 | |||
218 | fn bar() { | ||
219 | let _ = foo(<|>); | ||
220 | } | ||
221 | "#, | ||
222 | expect![[r#" | ||
223 | test | ||
224 | ------ | ||
225 | fn foo(j: u32) -> u32 | ||
226 | (<j: u32>) | ||
227 | "#]], | ||
228 | ); | ||
229 | } | ||
230 | |||
231 | #[test] | ||
232 | fn test_fn_signature_with_docs() { | ||
233 | check( | ||
234 | r#" | ||
235 | /// Adds one to the number given. | ||
236 | /// | ||
237 | /// # Examples | ||
238 | /// | ||
239 | /// ``` | ||
240 | /// let five = 5; | ||
241 | /// | ||
242 | /// assert_eq!(6, my_crate::add_one(5)); | ||
243 | /// ``` | ||
244 | pub fn add_one(x: i32) -> i32 { | ||
245 | x + 1 | ||
246 | } | ||
247 | |||
248 | pub fn do() { | ||
249 | add_one(<|> | ||
250 | }"#, | ||
251 | expect![[r##" | ||
252 | Adds one to the number given. | ||
253 | |||
254 | # Examples | ||
255 | |||
256 | ``` | ||
257 | let five = 5; | ||
258 | |||
259 | assert_eq!(6, my_crate::add_one(5)); | ||
260 | ``` | ||
261 | ------ | ||
262 | fn add_one(x: i32) -> i32 | ||
263 | (<x: i32>) | ||
264 | "##]], | ||
265 | ); | ||
266 | } | ||
267 | |||
268 | #[test] | ||
269 | fn test_fn_signature_with_docs_impl() { | ||
270 | check( | ||
271 | r#" | ||
272 | struct addr; | ||
273 | impl addr { | ||
274 | /// Adds one to the number given. | ||
275 | /// | ||
276 | /// # Examples | ||
277 | /// | ||
278 | /// ``` | ||
279 | /// let five = 5; | ||
280 | /// | ||
281 | /// assert_eq!(6, my_crate::add_one(5)); | ||
282 | /// ``` | ||
283 | pub fn add_one(x: i32) -> i32 { | ||
284 | x + 1 | ||
285 | } | ||
286 | } | ||
287 | |||
288 | pub fn do_it() { | ||
289 | addr {}; | ||
290 | addr::add_one(<|>); | ||
291 | } | ||
292 | "#, | ||
293 | expect![[r##" | ||
294 | Adds one to the number given. | ||
295 | |||
296 | # Examples | ||
297 | |||
298 | ``` | ||
299 | let five = 5; | ||
300 | |||
301 | assert_eq!(6, my_crate::add_one(5)); | ||
302 | ``` | ||
303 | ------ | ||
304 | fn add_one(x: i32) -> i32 | ||
305 | (<x: i32>) | ||
306 | "##]], | ||
307 | ); | ||
308 | } | ||
309 | |||
310 | #[test] | ||
311 | fn test_fn_signature_with_docs_from_actix() { | ||
312 | check( | ||
313 | r#" | ||
314 | struct WriteHandler<E>; | ||
315 | |||
316 | impl<E> WriteHandler<E> { | ||
317 | /// Method is called when writer emits error. | ||
318 | /// | ||
319 | /// If this method returns `ErrorAction::Continue` writer processing | ||
320 | /// continues otherwise stream processing stops. | ||
321 | fn error(&mut self, err: E, ctx: &mut Self::Context) -> Running { | ||
322 | Running::Stop | ||
323 | } | ||
324 | |||
325 | /// Method is called when writer finishes. | ||
326 | /// | ||
327 | /// By default this method stops actor's `Context`. | ||
328 | fn finished(&mut self, ctx: &mut Self::Context) { | ||
329 | ctx.stop() | ||
330 | } | ||
331 | } | ||
332 | |||
333 | pub fn foo(mut r: WriteHandler<()>) { | ||
334 | r.finished(<|>); | ||
335 | } | ||
336 | "#, | ||
337 | expect![[r#" | ||
338 | Method is called when writer finishes. | ||
339 | |||
340 | By default this method stops actor's `Context`. | ||
341 | ------ | ||
342 | fn finished(&mut self, ctx: &mut {unknown}) | ||
343 | (<ctx: &mut {unknown}>) | ||
344 | "#]], | ||
345 | ); | ||
346 | } | ||
347 | |||
348 | #[test] | ||
349 | fn call_info_bad_offset() { | ||
350 | mark::check!(call_info_bad_offset); | ||
351 | check( | ||
352 | r#" | ||
353 | fn foo(x: u32, y: u32) -> u32 {x + y} | ||
354 | fn bar() { foo <|> (3, ); } | ||
355 | "#, | ||
356 | expect![[""]], | ||
357 | ); | ||
358 | } | ||
359 | |||
360 | #[test] | ||
361 | fn test_nested_method_in_lambda() { | ||
362 | check( | ||
363 | r#" | ||
364 | struct Foo; | ||
365 | impl Foo { fn bar(&self, _: u32) { } } | ||
366 | |||
367 | fn bar(_: u32) { } | ||
368 | |||
369 | fn main() { | ||
370 | let foo = Foo; | ||
371 | std::thread::spawn(move || foo.bar(<|>)); | ||
372 | } | ||
373 | "#, | ||
374 | expect![[r#" | ||
375 | fn bar(&self, _: u32) | ||
376 | (<_: u32>) | ||
377 | "#]], | ||
378 | ); | ||
379 | } | ||
380 | |||
381 | #[test] | ||
382 | fn works_for_tuple_structs() { | ||
383 | check( | ||
384 | r#" | ||
385 | /// A cool tuple struct | ||
386 | struct S(u32, i32); | ||
387 | fn main() { | ||
388 | let s = S(0, <|>); | ||
389 | } | ||
390 | "#, | ||
391 | expect![[r#" | ||
392 | A cool tuple struct | ||
393 | ------ | ||
394 | struct S(u32, i32) | ||
395 | (u32, <i32>) | ||
396 | "#]], | ||
397 | ); | ||
398 | } | ||
399 | |||
400 | #[test] | ||
401 | fn generic_struct() { | ||
402 | check( | ||
403 | r#" | ||
404 | struct S<T>(T); | ||
405 | fn main() { | ||
406 | let s = S(<|>); | ||
407 | } | ||
408 | "#, | ||
409 | expect![[r#" | ||
410 | struct S({unknown}) | ||
411 | (<{unknown}>) | ||
412 | "#]], | ||
413 | ); | ||
414 | } | ||
415 | |||
416 | #[test] | ||
417 | fn works_for_enum_variants() { | ||
418 | check( | ||
419 | r#" | ||
420 | enum E { | ||
421 | /// A Variant | ||
422 | A(i32), | ||
423 | /// Another | ||
424 | B, | ||
425 | /// And C | ||
426 | C { a: i32, b: i32 } | ||
427 | } | ||
428 | |||
429 | fn main() { | ||
430 | let a = E::A(<|>); | ||
431 | } | ||
432 | "#, | ||
433 | expect![[r#" | ||
434 | A Variant | ||
435 | ------ | ||
436 | enum E::A(i32) | ||
437 | (<i32>) | ||
438 | "#]], | ||
439 | ); | ||
440 | } | ||
441 | |||
442 | #[test] | ||
443 | fn cant_call_struct_record() { | ||
444 | check( | ||
445 | r#" | ||
446 | struct S { x: u32, y: i32 } | ||
447 | fn main() { | ||
448 | let s = S(<|>); | ||
449 | } | ||
450 | "#, | ||
451 | expect![[""]], | ||
452 | ); | ||
453 | } | ||
454 | |||
455 | #[test] | ||
456 | fn cant_call_enum_record() { | ||
457 | check( | ||
458 | r#" | ||
459 | enum E { | ||
460 | /// A Variant | ||
461 | A(i32), | ||
462 | /// Another | ||
463 | B, | ||
464 | /// And C | ||
465 | C { a: i32, b: i32 } | ||
466 | } | ||
467 | |||
468 | fn main() { | ||
469 | let a = E::C(<|>); | ||
470 | } | ||
471 | "#, | ||
472 | expect![[""]], | ||
473 | ); | ||
474 | } | ||
475 | |||
476 | #[test] | ||
477 | fn fn_signature_for_call_in_macro() { | ||
478 | check( | ||
479 | r#" | ||
480 | macro_rules! id { ($($tt:tt)*) => { $($tt)* } } | ||
481 | fn foo() { } | ||
482 | id! { | ||
483 | fn bar() { foo(<|>); } | ||
484 | } | ||
485 | "#, | ||
486 | expect![[r#" | ||
487 | fn foo() | ||
488 | () | ||
489 | "#]], | ||
490 | ); | ||
491 | } | ||
492 | |||
493 | #[test] | ||
494 | fn call_info_for_lambdas() { | ||
495 | check( | ||
496 | r#" | ||
497 | struct S; | ||
498 | fn foo(s: S) -> i32 { 92 } | ||
499 | fn main() { | ||
500 | (|s| foo(s))(<|>) | ||
501 | } | ||
502 | "#, | ||
503 | expect![[r#" | ||
504 | (S) -> i32 | ||
505 | (<S>) | ||
506 | "#]], | ||
507 | ) | ||
508 | } | ||
509 | |||
510 | #[test] | ||
511 | fn call_info_for_fn_ptr() { | ||
512 | check( | ||
513 | r#" | ||
514 | fn main(f: fn(i32, f64) -> char) { | ||
515 | f(0, <|>) | ||
516 | } | ||
517 | "#, | ||
518 | expect![[r#" | ||
519 | (i32, f64) -> char | ||
520 | (i32, <f64>) | ||
521 | "#]], | ||
522 | ) | ||
523 | } | ||
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index 201a3d6fa..5d2cd30d1 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs | |||
@@ -258,7 +258,7 @@ impl NameRefClass { | |||
258 | sema: &Semantics<RootDatabase>, | 258 | sema: &Semantics<RootDatabase>, |
259 | name_ref: &ast::NameRef, | 259 | name_ref: &ast::NameRef, |
260 | ) -> Option<NameRefClass> { | 260 | ) -> Option<NameRefClass> { |
261 | let _p = profile::span("classify_name_ref"); | 261 | let _p = profile::span("classify_name_ref").detail(|| name_ref.to_string()); |
262 | 262 | ||
263 | let parent = name_ref.syntax().parent()?; | 263 | let parent = name_ref.syntax().parent()?; |
264 | 264 | ||
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index 08d246c16..040843990 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -573,641 +573,4 @@ fn find_insert_position( | |||
573 | } | 573 | } |
574 | 574 | ||
575 | #[cfg(test)] | 575 | #[cfg(test)] |
576 | mod tests { | 576 | mod tests; |
577 | use super::*; | ||
578 | |||
579 | use test_utils::assert_eq_text; | ||
580 | |||
581 | #[test] | ||
582 | fn insert_existing() { | ||
583 | check_full("std::fs", "use std::fs;", "use std::fs;") | ||
584 | } | ||
585 | |||
586 | #[test] | ||
587 | fn insert_start() { | ||
588 | check_none( | ||
589 | "std::bar::AA", | ||
590 | r" | ||
591 | use std::bar::B; | ||
592 | use std::bar::D; | ||
593 | use std::bar::F; | ||
594 | use std::bar::G;", | ||
595 | r" | ||
596 | use std::bar::AA; | ||
597 | use std::bar::B; | ||
598 | use std::bar::D; | ||
599 | use std::bar::F; | ||
600 | use std::bar::G;", | ||
601 | ) | ||
602 | } | ||
603 | |||
604 | #[test] | ||
605 | fn insert_start_indent() { | ||
606 | mark::check!(insert_use_indent_after); | ||
607 | check_none( | ||
608 | "std::bar::AA", | ||
609 | r" | ||
610 | use std::bar::B; | ||
611 | use std::bar::D;", | ||
612 | r" | ||
613 | use std::bar::AA; | ||
614 | use std::bar::B; | ||
615 | use std::bar::D;", | ||
616 | ) | ||
617 | } | ||
618 | |||
619 | #[test] | ||
620 | fn insert_middle() { | ||
621 | check_none( | ||
622 | "std::bar::EE", | ||
623 | r" | ||
624 | use std::bar::A; | ||
625 | use std::bar::D; | ||
626 | use std::bar::F; | ||
627 | use std::bar::G;", | ||
628 | r" | ||
629 | use std::bar::A; | ||
630 | use std::bar::D; | ||
631 | use std::bar::EE; | ||
632 | use std::bar::F; | ||
633 | use std::bar::G;", | ||
634 | ) | ||
635 | } | ||
636 | |||
637 | #[test] | ||
638 | fn insert_middle_indent() { | ||
639 | check_none( | ||
640 | "std::bar::EE", | ||
641 | r" | ||
642 | use std::bar::A; | ||
643 | use std::bar::D; | ||
644 | use std::bar::F; | ||
645 | use std::bar::G;", | ||
646 | r" | ||
647 | use std::bar::A; | ||
648 | use std::bar::D; | ||
649 | use std::bar::EE; | ||
650 | use std::bar::F; | ||
651 | use std::bar::G;", | ||
652 | ) | ||
653 | } | ||
654 | |||
655 | #[test] | ||
656 | fn insert_end() { | ||
657 | check_none( | ||
658 | "std::bar::ZZ", | ||
659 | r" | ||
660 | use std::bar::A; | ||
661 | use std::bar::D; | ||
662 | use std::bar::F; | ||
663 | use std::bar::G;", | ||
664 | r" | ||
665 | use std::bar::A; | ||
666 | use std::bar::D; | ||
667 | use std::bar::F; | ||
668 | use std::bar::G; | ||
669 | use std::bar::ZZ;", | ||
670 | ) | ||
671 | } | ||
672 | |||
673 | #[test] | ||
674 | fn insert_end_indent() { | ||
675 | mark::check!(insert_use_indent_before); | ||
676 | check_none( | ||
677 | "std::bar::ZZ", | ||
678 | r" | ||
679 | use std::bar::A; | ||
680 | use std::bar::D; | ||
681 | use std::bar::F; | ||
682 | use std::bar::G;", | ||
683 | r" | ||
684 | use std::bar::A; | ||
685 | use std::bar::D; | ||
686 | use std::bar::F; | ||
687 | use std::bar::G; | ||
688 | use std::bar::ZZ;", | ||
689 | ) | ||
690 | } | ||
691 | |||
692 | #[test] | ||
693 | fn insert_middle_nested() { | ||
694 | check_none( | ||
695 | "std::bar::EE", | ||
696 | r" | ||
697 | use std::bar::A; | ||
698 | use std::bar::{D, Z}; // example of weird imports due to user | ||
699 | use std::bar::F; | ||
700 | use std::bar::G;", | ||
701 | r" | ||
702 | use std::bar::A; | ||
703 | use std::bar::EE; | ||
704 | use std::bar::{D, Z}; // example of weird imports due to user | ||
705 | use std::bar::F; | ||
706 | use std::bar::G;", | ||
707 | ) | ||
708 | } | ||
709 | |||
710 | #[test] | ||
711 | fn insert_middle_groups() { | ||
712 | check_none( | ||
713 | "foo::bar::GG", | ||
714 | r" | ||
715 | use std::bar::A; | ||
716 | use std::bar::D; | ||
717 | |||
718 | use foo::bar::F; | ||
719 | use foo::bar::H;", | ||
720 | r" | ||
721 | use std::bar::A; | ||
722 | use std::bar::D; | ||
723 | |||
724 | use foo::bar::F; | ||
725 | use foo::bar::GG; | ||
726 | use foo::bar::H;", | ||
727 | ) | ||
728 | } | ||
729 | |||
730 | #[test] | ||
731 | fn insert_first_matching_group() { | ||
732 | check_none( | ||
733 | "foo::bar::GG", | ||
734 | r" | ||
735 | use foo::bar::A; | ||
736 | use foo::bar::D; | ||
737 | |||
738 | use std; | ||
739 | |||
740 | use foo::bar::F; | ||
741 | use foo::bar::H;", | ||
742 | r" | ||
743 | use foo::bar::A; | ||
744 | use foo::bar::D; | ||
745 | use foo::bar::GG; | ||
746 | |||
747 | use std; | ||
748 | |||
749 | use foo::bar::F; | ||
750 | use foo::bar::H;", | ||
751 | ) | ||
752 | } | ||
753 | |||
754 | #[test] | ||
755 | fn insert_missing_group_std() { | ||
756 | check_none( | ||
757 | "std::fmt", | ||
758 | r" | ||
759 | use foo::bar::A; | ||
760 | use foo::bar::D;", | ||
761 | r" | ||
762 | use std::fmt; | ||
763 | |||
764 | use foo::bar::A; | ||
765 | use foo::bar::D;", | ||
766 | ) | ||
767 | } | ||
768 | |||
769 | #[test] | ||
770 | fn insert_missing_group_self() { | ||
771 | check_none( | ||
772 | "self::fmt", | ||
773 | r" | ||
774 | use foo::bar::A; | ||
775 | use foo::bar::D;", | ||
776 | r" | ||
777 | use foo::bar::A; | ||
778 | use foo::bar::D; | ||
779 | |||
780 | use self::fmt;", | ||
781 | ) | ||
782 | } | ||
783 | |||
784 | #[test] | ||
785 | fn insert_no_imports() { | ||
786 | check_full( | ||
787 | "foo::bar", | ||
788 | "fn main() {}", | ||
789 | r"use foo::bar; | ||
790 | |||
791 | fn main() {}", | ||
792 | ) | ||
793 | } | ||
794 | |||
795 | #[test] | ||
796 | fn insert_empty_file() { | ||
797 | // empty files will get two trailing newlines | ||
798 | // this is due to the test case insert_no_imports above | ||
799 | check_full( | ||
800 | "foo::bar", | ||
801 | "", | ||
802 | r"use foo::bar; | ||
803 | |||
804 | ", | ||
805 | ) | ||
806 | } | ||
807 | |||
808 | #[test] | ||
809 | fn insert_empty_module() { | ||
810 | mark::check!(insert_use_no_indent_after); | ||
811 | check( | ||
812 | "foo::bar", | ||
813 | "mod x {}", | ||
814 | r"{ | ||
815 | use foo::bar; | ||
816 | }", | ||
817 | None, | ||
818 | true, | ||
819 | ) | ||
820 | } | ||
821 | |||
822 | #[test] | ||
823 | fn insert_after_inner_attr() { | ||
824 | check_full( | ||
825 | "foo::bar", | ||
826 | r"#![allow(unused_imports)]", | ||
827 | r"#![allow(unused_imports)] | ||
828 | |||
829 | use foo::bar;", | ||
830 | ) | ||
831 | } | ||
832 | |||
833 | #[test] | ||
834 | fn insert_after_inner_attr2() { | ||
835 | check_full( | ||
836 | "foo::bar", | ||
837 | r"#![allow(unused_imports)] | ||
838 | |||
839 | #![no_std] | ||
840 | fn main() {}", | ||
841 | r"#![allow(unused_imports)] | ||
842 | |||
843 | #![no_std] | ||
844 | |||
845 | use foo::bar; | ||
846 | fn main() {}", | ||
847 | ); | ||
848 | } | ||
849 | |||
850 | #[test] | ||
851 | fn inserts_after_single_line_inner_comments() { | ||
852 | check_none( | ||
853 | "foo::bar::Baz", | ||
854 | "//! Single line inner comments do not allow any code before them.", | ||
855 | r#"//! Single line inner comments do not allow any code before them. | ||
856 | |||
857 | use foo::bar::Baz;"#, | ||
858 | ); | ||
859 | } | ||
860 | |||
861 | #[test] | ||
862 | fn inserts_after_multiline_inner_comments() { | ||
863 | check_none( | ||
864 | "foo::bar::Baz", | ||
865 | r#"/*! Multiline inner comments do not allow any code before them. */ | ||
866 | |||
867 | /*! Still an inner comment, cannot place any code before. */ | ||
868 | fn main() {}"#, | ||
869 | r#"/*! Multiline inner comments do not allow any code before them. */ | ||
870 | |||
871 | /*! Still an inner comment, cannot place any code before. */ | ||
872 | |||
873 | use foo::bar::Baz; | ||
874 | fn main() {}"#, | ||
875 | ) | ||
876 | } | ||
877 | |||
878 | #[test] | ||
879 | fn inserts_after_all_inner_items() { | ||
880 | check_none( | ||
881 | "foo::bar::Baz", | ||
882 | r#"#![allow(unused_imports)] | ||
883 | /*! Multiline line comment 2 */ | ||
884 | |||
885 | |||
886 | //! Single line comment 1 | ||
887 | #![no_std] | ||
888 | //! Single line comment 2 | ||
889 | fn main() {}"#, | ||
890 | r#"#![allow(unused_imports)] | ||
891 | /*! Multiline line comment 2 */ | ||
892 | |||
893 | |||
894 | //! Single line comment 1 | ||
895 | #![no_std] | ||
896 | //! Single line comment 2 | ||
897 | |||
898 | use foo::bar::Baz; | ||
899 | fn main() {}"#, | ||
900 | ) | ||
901 | } | ||
902 | |||
903 | #[test] | ||
904 | fn merge_groups() { | ||
905 | check_last("std::io", r"use std::fmt;", r"use std::{fmt, io};") | ||
906 | } | ||
907 | |||
908 | #[test] | ||
909 | fn merge_groups_last() { | ||
910 | check_last( | ||
911 | "std::io", | ||
912 | r"use std::fmt::{Result, Display};", | ||
913 | r"use std::fmt::{Result, Display}; | ||
914 | use std::io;", | ||
915 | ) | ||
916 | } | ||
917 | |||
918 | #[test] | ||
919 | fn merge_last_into_self() { | ||
920 | check_last("foo::bar::baz", r"use foo::bar;", r"use foo::bar::{self, baz};"); | ||
921 | } | ||
922 | |||
923 | #[test] | ||
924 | fn merge_groups_full() { | ||
925 | check_full( | ||
926 | "std::io", | ||
927 | r"use std::fmt::{Result, Display};", | ||
928 | r"use std::{fmt::{Result, Display}, io};", | ||
929 | ) | ||
930 | } | ||
931 | |||
932 | #[test] | ||
933 | fn merge_groups_long_full() { | ||
934 | check_full( | ||
935 | "std::foo::bar::Baz", | ||
936 | r"use std::foo::bar::Qux;", | ||
937 | r"use std::foo::bar::{Baz, Qux};", | ||
938 | ) | ||
939 | } | ||
940 | |||
941 | #[test] | ||
942 | fn merge_groups_long_last() { | ||
943 | check_last( | ||
944 | "std::foo::bar::Baz", | ||
945 | r"use std::foo::bar::Qux;", | ||
946 | r"use std::foo::bar::{Baz, Qux};", | ||
947 | ) | ||
948 | } | ||
949 | |||
950 | #[test] | ||
951 | fn merge_groups_long_full_list() { | ||
952 | check_full( | ||
953 | "std::foo::bar::Baz", | ||
954 | r"use std::foo::bar::{Qux, Quux};", | ||
955 | r"use std::foo::bar::{Baz, Quux, Qux};", | ||
956 | ) | ||
957 | } | ||
958 | |||
959 | #[test] | ||
960 | fn merge_groups_long_last_list() { | ||
961 | check_last( | ||
962 | "std::foo::bar::Baz", | ||
963 | r"use std::foo::bar::{Qux, Quux};", | ||
964 | r"use std::foo::bar::{Baz, Quux, Qux};", | ||
965 | ) | ||
966 | } | ||
967 | |||
968 | #[test] | ||
969 | fn merge_groups_long_full_nested() { | ||
970 | check_full( | ||
971 | "std::foo::bar::Baz", | ||
972 | r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
973 | r"use std::foo::bar::{Baz, Qux, quux::{Fez, Fizz}};", | ||
974 | ) | ||
975 | } | ||
976 | |||
977 | #[test] | ||
978 | fn merge_groups_long_last_nested() { | ||
979 | check_last( | ||
980 | "std::foo::bar::Baz", | ||
981 | r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
982 | r"use std::foo::bar::Baz; | ||
983 | use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
984 | ) | ||
985 | } | ||
986 | |||
987 | #[test] | ||
988 | fn merge_groups_full_nested_deep() { | ||
989 | check_full( | ||
990 | "std::foo::bar::quux::Baz", | ||
991 | r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
992 | r"use std::foo::bar::{Qux, quux::{Baz, Fez, Fizz}};", | ||
993 | ) | ||
994 | } | ||
995 | |||
996 | #[test] | ||
997 | fn merge_groups_full_nested_long() { | ||
998 | check_full( | ||
999 | "std::foo::bar::Baz", | ||
1000 | r"use std::{foo::bar::Qux};", | ||
1001 | r"use std::{foo::bar::{Baz, Qux}};", | ||
1002 | ); | ||
1003 | } | ||
1004 | |||
1005 | #[test] | ||
1006 | fn merge_groups_last_nested_long() { | ||
1007 | check_full( | ||
1008 | "std::foo::bar::Baz", | ||
1009 | r"use std::{foo::bar::Qux};", | ||
1010 | r"use std::{foo::bar::{Baz, Qux}};", | ||
1011 | ); | ||
1012 | } | ||
1013 | |||
1014 | #[test] | ||
1015 | fn merge_groups_skip_pub() { | ||
1016 | check_full( | ||
1017 | "std::io", | ||
1018 | r"pub use std::fmt::{Result, Display};", | ||
1019 | r"pub use std::fmt::{Result, Display}; | ||
1020 | use std::io;", | ||
1021 | ) | ||
1022 | } | ||
1023 | |||
1024 | #[test] | ||
1025 | fn merge_groups_skip_pub_crate() { | ||
1026 | check_full( | ||
1027 | "std::io", | ||
1028 | r"pub(crate) use std::fmt::{Result, Display};", | ||
1029 | r"pub(crate) use std::fmt::{Result, Display}; | ||
1030 | use std::io;", | ||
1031 | ) | ||
1032 | } | ||
1033 | |||
1034 | #[test] | ||
1035 | #[ignore] // FIXME: Support this | ||
1036 | fn split_out_merge() { | ||
1037 | check_last( | ||
1038 | "std::fmt::Result", | ||
1039 | r"use std::{fmt, io};", | ||
1040 | r"use std::fmt::{self, Result}; | ||
1041 | use std::io;", | ||
1042 | ) | ||
1043 | } | ||
1044 | |||
1045 | #[test] | ||
1046 | fn merge_into_module_import() { | ||
1047 | check_full( | ||
1048 | "std::fmt::Result", | ||
1049 | r"use std::{fmt, io};", | ||
1050 | r"use std::{fmt::{self, Result}, io};", | ||
1051 | ) | ||
1052 | } | ||
1053 | |||
1054 | #[test] | ||
1055 | fn merge_groups_self() { | ||
1056 | check_full("std::fmt::Debug", r"use std::fmt;", r"use std::fmt::{self, Debug};") | ||
1057 | } | ||
1058 | |||
1059 | #[test] | ||
1060 | fn merge_mod_into_glob() { | ||
1061 | check_full( | ||
1062 | "token::TokenKind", | ||
1063 | r"use token::TokenKind::*;", | ||
1064 | r"use token::TokenKind::{*, self};", | ||
1065 | ) | ||
1066 | // FIXME: have it emit `use token::TokenKind::{self, *}`? | ||
1067 | } | ||
1068 | |||
1069 | #[test] | ||
1070 | fn merge_self_glob() { | ||
1071 | check_full("self", r"use self::*;", r"use self::{*, self};") | ||
1072 | // FIXME: have it emit `use {self, *}`? | ||
1073 | } | ||
1074 | |||
1075 | #[test] | ||
1076 | fn merge_glob_nested() { | ||
1077 | check_full( | ||
1078 | "foo::bar::quux::Fez", | ||
1079 | r"use foo::bar::{Baz, quux::*};", | ||
1080 | r"use foo::bar::{Baz, quux::{self::*, Fez}};", | ||
1081 | ) | ||
1082 | } | ||
1083 | |||
1084 | #[test] | ||
1085 | fn merge_nested_considers_first_segments() { | ||
1086 | check_full( | ||
1087 | "hir_ty::display::write_bounds_like_dyn_trait", | ||
1088 | r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter}, method_resolution};", | ||
1089 | r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter, write_bounds_like_dyn_trait}, method_resolution};", | ||
1090 | ); | ||
1091 | } | ||
1092 | |||
1093 | #[test] | ||
1094 | fn skip_merge_last_too_long() { | ||
1095 | check_last( | ||
1096 | "foo::bar", | ||
1097 | r"use foo::bar::baz::Qux;", | ||
1098 | r"use foo::bar; | ||
1099 | use foo::bar::baz::Qux;", | ||
1100 | ); | ||
1101 | } | ||
1102 | |||
1103 | #[test] | ||
1104 | fn skip_merge_last_too_long2() { | ||
1105 | check_last( | ||
1106 | "foo::bar::baz::Qux", | ||
1107 | r"use foo::bar;", | ||
1108 | r"use foo::bar; | ||
1109 | use foo::bar::baz::Qux;", | ||
1110 | ); | ||
1111 | } | ||
1112 | |||
1113 | #[test] | ||
1114 | fn insert_short_before_long() { | ||
1115 | check_none( | ||
1116 | "foo::bar", | ||
1117 | r"use foo::bar::baz::Qux;", | ||
1118 | r"use foo::bar; | ||
1119 | use foo::bar::baz::Qux;", | ||
1120 | ); | ||
1121 | } | ||
1122 | |||
1123 | #[test] | ||
1124 | fn merge_last_fail() { | ||
1125 | check_merge_only_fail( | ||
1126 | r"use foo::bar::{baz::{Qux, Fez}};", | ||
1127 | r"use foo::bar::{baaz::{Quux, Feez}};", | ||
1128 | MergeBehaviour::Last, | ||
1129 | ); | ||
1130 | } | ||
1131 | |||
1132 | #[test] | ||
1133 | fn merge_last_fail1() { | ||
1134 | check_merge_only_fail( | ||
1135 | r"use foo::bar::{baz::{Qux, Fez}};", | ||
1136 | r"use foo::bar::baaz::{Quux, Feez};", | ||
1137 | MergeBehaviour::Last, | ||
1138 | ); | ||
1139 | } | ||
1140 | |||
1141 | #[test] | ||
1142 | fn merge_last_fail2() { | ||
1143 | check_merge_only_fail( | ||
1144 | r"use foo::bar::baz::{Qux, Fez};", | ||
1145 | r"use foo::bar::{baaz::{Quux, Feez}};", | ||
1146 | MergeBehaviour::Last, | ||
1147 | ); | ||
1148 | } | ||
1149 | |||
1150 | #[test] | ||
1151 | fn merge_last_fail3() { | ||
1152 | check_merge_only_fail( | ||
1153 | r"use foo::bar::baz::{Qux, Fez};", | ||
1154 | r"use foo::bar::baaz::{Quux, Feez};", | ||
1155 | MergeBehaviour::Last, | ||
1156 | ); | ||
1157 | } | ||
1158 | |||
1159 | fn check( | ||
1160 | path: &str, | ||
1161 | ra_fixture_before: &str, | ||
1162 | ra_fixture_after: &str, | ||
1163 | mb: Option<MergeBehaviour>, | ||
1164 | module: bool, | ||
1165 | ) { | ||
1166 | let mut syntax = ast::SourceFile::parse(ra_fixture_before).tree().syntax().clone(); | ||
1167 | if module { | ||
1168 | syntax = syntax.descendants().find_map(ast::Module::cast).unwrap().syntax().clone(); | ||
1169 | } | ||
1170 | let file = super::ImportScope::from(syntax).unwrap(); | ||
1171 | let path = ast::SourceFile::parse(&format!("use {};", path)) | ||
1172 | .tree() | ||
1173 | .syntax() | ||
1174 | .descendants() | ||
1175 | .find_map(ast::Path::cast) | ||
1176 | .unwrap(); | ||
1177 | |||
1178 | let rewriter = insert_use(&file, path, mb); | ||
1179 | let result = rewriter.rewrite(file.as_syntax_node()).to_string(); | ||
1180 | assert_eq_text!(&result, ra_fixture_after); | ||
1181 | } | ||
1182 | |||
1183 | fn check_full(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
1184 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehaviour::Full), false) | ||
1185 | } | ||
1186 | |||
1187 | fn check_last(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
1188 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehaviour::Last), false) | ||
1189 | } | ||
1190 | |||
1191 | fn check_none(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
1192 | check(path, ra_fixture_before, ra_fixture_after, None, false) | ||
1193 | } | ||
1194 | |||
1195 | fn check_merge_only_fail(ra_fixture0: &str, ra_fixture1: &str, mb: MergeBehaviour) { | ||
1196 | let use0 = ast::SourceFile::parse(ra_fixture0) | ||
1197 | .tree() | ||
1198 | .syntax() | ||
1199 | .descendants() | ||
1200 | .find_map(ast::Use::cast) | ||
1201 | .unwrap(); | ||
1202 | |||
1203 | let use1 = ast::SourceFile::parse(ra_fixture1) | ||
1204 | .tree() | ||
1205 | .syntax() | ||
1206 | .descendants() | ||
1207 | .find_map(ast::Use::cast) | ||
1208 | .unwrap(); | ||
1209 | |||
1210 | let result = try_merge_imports(&use0, &use1, mb); | ||
1211 | assert_eq!(result.map(|u| u.to_string()), None); | ||
1212 | } | ||
1213 | } | ||
diff --git a/crates/ide_db/src/helpers/insert_use/tests.rs b/crates/ide_db/src/helpers/insert_use/tests.rs new file mode 100644 index 000000000..86bfa5b41 --- /dev/null +++ b/crates/ide_db/src/helpers/insert_use/tests.rs | |||
@@ -0,0 +1,620 @@ | |||
1 | use super::*; | ||
2 | |||
3 | use test_utils::assert_eq_text; | ||
4 | |||
5 | #[test] | ||
6 | fn insert_existing() { | ||
7 | check_full("std::fs", "use std::fs;", "use std::fs;") | ||
8 | } | ||
9 | |||
10 | #[test] | ||
11 | fn insert_start() { | ||
12 | check_none( | ||
13 | "std::bar::AA", | ||
14 | r" | ||
15 | use std::bar::B; | ||
16 | use std::bar::D; | ||
17 | use std::bar::F; | ||
18 | use std::bar::G;", | ||
19 | r" | ||
20 | use std::bar::AA; | ||
21 | use std::bar::B; | ||
22 | use std::bar::D; | ||
23 | use std::bar::F; | ||
24 | use std::bar::G;", | ||
25 | ) | ||
26 | } | ||
27 | |||
28 | #[test] | ||
29 | fn insert_start_indent() { | ||
30 | mark::check!(insert_use_indent_after); | ||
31 | check_none( | ||
32 | "std::bar::AA", | ||
33 | r" | ||
34 | use std::bar::B; | ||
35 | use std::bar::D;", | ||
36 | r" | ||
37 | use std::bar::AA; | ||
38 | use std::bar::B; | ||
39 | use std::bar::D;", | ||
40 | ) | ||
41 | } | ||
42 | |||
43 | #[test] | ||
44 | fn insert_middle() { | ||
45 | check_none( | ||
46 | "std::bar::EE", | ||
47 | r" | ||
48 | use std::bar::A; | ||
49 | use std::bar::D; | ||
50 | use std::bar::F; | ||
51 | use std::bar::G;", | ||
52 | r" | ||
53 | use std::bar::A; | ||
54 | use std::bar::D; | ||
55 | use std::bar::EE; | ||
56 | use std::bar::F; | ||
57 | use std::bar::G;", | ||
58 | ) | ||
59 | } | ||
60 | |||
61 | #[test] | ||
62 | fn insert_middle_indent() { | ||
63 | check_none( | ||
64 | "std::bar::EE", | ||
65 | r" | ||
66 | use std::bar::A; | ||
67 | use std::bar::D; | ||
68 | use std::bar::F; | ||
69 | use std::bar::G;", | ||
70 | r" | ||
71 | use std::bar::A; | ||
72 | use std::bar::D; | ||
73 | use std::bar::EE; | ||
74 | use std::bar::F; | ||
75 | use std::bar::G;", | ||
76 | ) | ||
77 | } | ||
78 | |||
79 | #[test] | ||
80 | fn insert_end() { | ||
81 | check_none( | ||
82 | "std::bar::ZZ", | ||
83 | r" | ||
84 | use std::bar::A; | ||
85 | use std::bar::D; | ||
86 | use std::bar::F; | ||
87 | use std::bar::G;", | ||
88 | r" | ||
89 | use std::bar::A; | ||
90 | use std::bar::D; | ||
91 | use std::bar::F; | ||
92 | use std::bar::G; | ||
93 | use std::bar::ZZ;", | ||
94 | ) | ||
95 | } | ||
96 | |||
97 | #[test] | ||
98 | fn insert_end_indent() { | ||
99 | mark::check!(insert_use_indent_before); | ||
100 | check_none( | ||
101 | "std::bar::ZZ", | ||
102 | r" | ||
103 | use std::bar::A; | ||
104 | use std::bar::D; | ||
105 | use std::bar::F; | ||
106 | use std::bar::G;", | ||
107 | r" | ||
108 | use std::bar::A; | ||
109 | use std::bar::D; | ||
110 | use std::bar::F; | ||
111 | use std::bar::G; | ||
112 | use std::bar::ZZ;", | ||
113 | ) | ||
114 | } | ||
115 | |||
116 | #[test] | ||
117 | fn insert_middle_nested() { | ||
118 | check_none( | ||
119 | "std::bar::EE", | ||
120 | r" | ||
121 | use std::bar::A; | ||
122 | use std::bar::{D, Z}; // example of weird imports due to user | ||
123 | use std::bar::F; | ||
124 | use std::bar::G;", | ||
125 | r" | ||
126 | use std::bar::A; | ||
127 | use std::bar::EE; | ||
128 | use std::bar::{D, Z}; // example of weird imports due to user | ||
129 | use std::bar::F; | ||
130 | use std::bar::G;", | ||
131 | ) | ||
132 | } | ||
133 | |||
134 | #[test] | ||
135 | fn insert_middle_groups() { | ||
136 | check_none( | ||
137 | "foo::bar::GG", | ||
138 | r" | ||
139 | use std::bar::A; | ||
140 | use std::bar::D; | ||
141 | |||
142 | use foo::bar::F; | ||
143 | use foo::bar::H;", | ||
144 | r" | ||
145 | use std::bar::A; | ||
146 | use std::bar::D; | ||
147 | |||
148 | use foo::bar::F; | ||
149 | use foo::bar::GG; | ||
150 | use foo::bar::H;", | ||
151 | ) | ||
152 | } | ||
153 | |||
154 | #[test] | ||
155 | fn insert_first_matching_group() { | ||
156 | check_none( | ||
157 | "foo::bar::GG", | ||
158 | r" | ||
159 | use foo::bar::A; | ||
160 | use foo::bar::D; | ||
161 | |||
162 | use std; | ||
163 | |||
164 | use foo::bar::F; | ||
165 | use foo::bar::H;", | ||
166 | r" | ||
167 | use foo::bar::A; | ||
168 | use foo::bar::D; | ||
169 | use foo::bar::GG; | ||
170 | |||
171 | use std; | ||
172 | |||
173 | use foo::bar::F; | ||
174 | use foo::bar::H;", | ||
175 | ) | ||
176 | } | ||
177 | |||
178 | #[test] | ||
179 | fn insert_missing_group_std() { | ||
180 | check_none( | ||
181 | "std::fmt", | ||
182 | r" | ||
183 | use foo::bar::A; | ||
184 | use foo::bar::D;", | ||
185 | r" | ||
186 | use std::fmt; | ||
187 | |||
188 | use foo::bar::A; | ||
189 | use foo::bar::D;", | ||
190 | ) | ||
191 | } | ||
192 | |||
193 | #[test] | ||
194 | fn insert_missing_group_self() { | ||
195 | check_none( | ||
196 | "self::fmt", | ||
197 | r" | ||
198 | use foo::bar::A; | ||
199 | use foo::bar::D;", | ||
200 | r" | ||
201 | use foo::bar::A; | ||
202 | use foo::bar::D; | ||
203 | |||
204 | use self::fmt;", | ||
205 | ) | ||
206 | } | ||
207 | |||
208 | #[test] | ||
209 | fn insert_no_imports() { | ||
210 | check_full( | ||
211 | "foo::bar", | ||
212 | "fn main() {}", | ||
213 | r"use foo::bar; | ||
214 | |||
215 | fn main() {}", | ||
216 | ) | ||
217 | } | ||
218 | |||
219 | #[test] | ||
220 | fn insert_empty_file() { | ||
221 | // empty files will get two trailing newlines | ||
222 | // this is due to the test case insert_no_imports above | ||
223 | check_full( | ||
224 | "foo::bar", | ||
225 | "", | ||
226 | r"use foo::bar; | ||
227 | |||
228 | ", | ||
229 | ) | ||
230 | } | ||
231 | |||
232 | #[test] | ||
233 | fn insert_empty_module() { | ||
234 | mark::check!(insert_use_no_indent_after); | ||
235 | check( | ||
236 | "foo::bar", | ||
237 | "mod x {}", | ||
238 | r"{ | ||
239 | use foo::bar; | ||
240 | }", | ||
241 | None, | ||
242 | true, | ||
243 | ) | ||
244 | } | ||
245 | |||
246 | #[test] | ||
247 | fn insert_after_inner_attr() { | ||
248 | check_full( | ||
249 | "foo::bar", | ||
250 | r"#![allow(unused_imports)]", | ||
251 | r"#![allow(unused_imports)] | ||
252 | |||
253 | use foo::bar;", | ||
254 | ) | ||
255 | } | ||
256 | |||
257 | #[test] | ||
258 | fn insert_after_inner_attr2() { | ||
259 | check_full( | ||
260 | "foo::bar", | ||
261 | r"#![allow(unused_imports)] | ||
262 | |||
263 | #![no_std] | ||
264 | fn main() {}", | ||
265 | r"#![allow(unused_imports)] | ||
266 | |||
267 | #![no_std] | ||
268 | |||
269 | use foo::bar; | ||
270 | fn main() {}", | ||
271 | ); | ||
272 | } | ||
273 | |||
274 | #[test] | ||
275 | fn inserts_after_single_line_inner_comments() { | ||
276 | check_none( | ||
277 | "foo::bar::Baz", | ||
278 | "//! Single line inner comments do not allow any code before them.", | ||
279 | r#"//! Single line inner comments do not allow any code before them. | ||
280 | |||
281 | use foo::bar::Baz;"#, | ||
282 | ); | ||
283 | } | ||
284 | |||
285 | #[test] | ||
286 | fn inserts_after_multiline_inner_comments() { | ||
287 | check_none( | ||
288 | "foo::bar::Baz", | ||
289 | r#"/*! Multiline inner comments do not allow any code before them. */ | ||
290 | |||
291 | /*! Still an inner comment, cannot place any code before. */ | ||
292 | fn main() {}"#, | ||
293 | r#"/*! Multiline inner comments do not allow any code before them. */ | ||
294 | |||
295 | /*! Still an inner comment, cannot place any code before. */ | ||
296 | |||
297 | use foo::bar::Baz; | ||
298 | fn main() {}"#, | ||
299 | ) | ||
300 | } | ||
301 | |||
302 | #[test] | ||
303 | fn inserts_after_all_inner_items() { | ||
304 | check_none( | ||
305 | "foo::bar::Baz", | ||
306 | r#"#![allow(unused_imports)] | ||
307 | /*! Multiline line comment 2 */ | ||
308 | |||
309 | |||
310 | //! Single line comment 1 | ||
311 | #![no_std] | ||
312 | //! Single line comment 2 | ||
313 | fn main() {}"#, | ||
314 | r#"#![allow(unused_imports)] | ||
315 | /*! Multiline line comment 2 */ | ||
316 | |||
317 | |||
318 | //! Single line comment 1 | ||
319 | #![no_std] | ||
320 | //! Single line comment 2 | ||
321 | |||
322 | use foo::bar::Baz; | ||
323 | fn main() {}"#, | ||
324 | ) | ||
325 | } | ||
326 | |||
327 | #[test] | ||
328 | fn merge_groups() { | ||
329 | check_last("std::io", r"use std::fmt;", r"use std::{fmt, io};") | ||
330 | } | ||
331 | |||
332 | #[test] | ||
333 | fn merge_groups_last() { | ||
334 | check_last( | ||
335 | "std::io", | ||
336 | r"use std::fmt::{Result, Display};", | ||
337 | r"use std::fmt::{Result, Display}; | ||
338 | use std::io;", | ||
339 | ) | ||
340 | } | ||
341 | |||
342 | #[test] | ||
343 | fn merge_last_into_self() { | ||
344 | check_last("foo::bar::baz", r"use foo::bar;", r"use foo::bar::{self, baz};"); | ||
345 | } | ||
346 | |||
347 | #[test] | ||
348 | fn merge_groups_full() { | ||
349 | check_full( | ||
350 | "std::io", | ||
351 | r"use std::fmt::{Result, Display};", | ||
352 | r"use std::{fmt::{Result, Display}, io};", | ||
353 | ) | ||
354 | } | ||
355 | |||
356 | #[test] | ||
357 | fn merge_groups_long_full() { | ||
358 | check_full("std::foo::bar::Baz", r"use std::foo::bar::Qux;", r"use std::foo::bar::{Baz, Qux};") | ||
359 | } | ||
360 | |||
361 | #[test] | ||
362 | fn merge_groups_long_last() { | ||
363 | check_last("std::foo::bar::Baz", r"use std::foo::bar::Qux;", r"use std::foo::bar::{Baz, Qux};") | ||
364 | } | ||
365 | |||
366 | #[test] | ||
367 | fn merge_groups_long_full_list() { | ||
368 | check_full( | ||
369 | "std::foo::bar::Baz", | ||
370 | r"use std::foo::bar::{Qux, Quux};", | ||
371 | r"use std::foo::bar::{Baz, Quux, Qux};", | ||
372 | ) | ||
373 | } | ||
374 | |||
375 | #[test] | ||
376 | fn merge_groups_long_last_list() { | ||
377 | check_last( | ||
378 | "std::foo::bar::Baz", | ||
379 | r"use std::foo::bar::{Qux, Quux};", | ||
380 | r"use std::foo::bar::{Baz, Quux, Qux};", | ||
381 | ) | ||
382 | } | ||
383 | |||
384 | #[test] | ||
385 | fn merge_groups_long_full_nested() { | ||
386 | check_full( | ||
387 | "std::foo::bar::Baz", | ||
388 | r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
389 | r"use std::foo::bar::{Baz, Qux, quux::{Fez, Fizz}};", | ||
390 | ) | ||
391 | } | ||
392 | |||
393 | #[test] | ||
394 | fn merge_groups_long_last_nested() { | ||
395 | check_last( | ||
396 | "std::foo::bar::Baz", | ||
397 | r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
398 | r"use std::foo::bar::Baz; | ||
399 | use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
400 | ) | ||
401 | } | ||
402 | |||
403 | #[test] | ||
404 | fn merge_groups_full_nested_deep() { | ||
405 | check_full( | ||
406 | "std::foo::bar::quux::Baz", | ||
407 | r"use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | ||
408 | r"use std::foo::bar::{Qux, quux::{Baz, Fez, Fizz}};", | ||
409 | ) | ||
410 | } | ||
411 | |||
412 | #[test] | ||
413 | fn merge_groups_full_nested_long() { | ||
414 | check_full( | ||
415 | "std::foo::bar::Baz", | ||
416 | r"use std::{foo::bar::Qux};", | ||
417 | r"use std::{foo::bar::{Baz, Qux}};", | ||
418 | ); | ||
419 | } | ||
420 | |||
421 | #[test] | ||
422 | fn merge_groups_last_nested_long() { | ||
423 | check_full( | ||
424 | "std::foo::bar::Baz", | ||
425 | r"use std::{foo::bar::Qux};", | ||
426 | r"use std::{foo::bar::{Baz, Qux}};", | ||
427 | ); | ||
428 | } | ||
429 | |||
430 | #[test] | ||
431 | fn merge_groups_skip_pub() { | ||
432 | check_full( | ||
433 | "std::io", | ||
434 | r"pub use std::fmt::{Result, Display};", | ||
435 | r"pub use std::fmt::{Result, Display}; | ||
436 | use std::io;", | ||
437 | ) | ||
438 | } | ||
439 | |||
440 | #[test] | ||
441 | fn merge_groups_skip_pub_crate() { | ||
442 | check_full( | ||
443 | "std::io", | ||
444 | r"pub(crate) use std::fmt::{Result, Display};", | ||
445 | r"pub(crate) use std::fmt::{Result, Display}; | ||
446 | use std::io;", | ||
447 | ) | ||
448 | } | ||
449 | |||
450 | #[test] | ||
451 | #[ignore] // FIXME: Support this | ||
452 | fn split_out_merge() { | ||
453 | check_last( | ||
454 | "std::fmt::Result", | ||
455 | r"use std::{fmt, io};", | ||
456 | r"use std::fmt::{self, Result}; | ||
457 | use std::io;", | ||
458 | ) | ||
459 | } | ||
460 | |||
461 | #[test] | ||
462 | fn merge_into_module_import() { | ||
463 | check_full("std::fmt::Result", r"use std::{fmt, io};", r"use std::{fmt::{self, Result}, io};") | ||
464 | } | ||
465 | |||
466 | #[test] | ||
467 | fn merge_groups_self() { | ||
468 | check_full("std::fmt::Debug", r"use std::fmt;", r"use std::fmt::{self, Debug};") | ||
469 | } | ||
470 | |||
471 | #[test] | ||
472 | fn merge_mod_into_glob() { | ||
473 | check_full("token::TokenKind", r"use token::TokenKind::*;", r"use token::TokenKind::{*, self};") | ||
474 | // FIXME: have it emit `use token::TokenKind::{self, *}`? | ||
475 | } | ||
476 | |||
477 | #[test] | ||
478 | fn merge_self_glob() { | ||
479 | check_full("self", r"use self::*;", r"use self::{*, self};") | ||
480 | // FIXME: have it emit `use {self, *}`? | ||
481 | } | ||
482 | |||
483 | #[test] | ||
484 | fn merge_glob_nested() { | ||
485 | check_full( | ||
486 | "foo::bar::quux::Fez", | ||
487 | r"use foo::bar::{Baz, quux::*};", | ||
488 | r"use foo::bar::{Baz, quux::{self::*, Fez}};", | ||
489 | ) | ||
490 | } | ||
491 | |||
492 | #[test] | ||
493 | fn merge_nested_considers_first_segments() { | ||
494 | check_full( | ||
495 | "hir_ty::display::write_bounds_like_dyn_trait", | ||
496 | r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter}, method_resolution};", | ||
497 | r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter, write_bounds_like_dyn_trait}, method_resolution};", | ||
498 | ); | ||
499 | } | ||
500 | |||
501 | #[test] | ||
502 | fn skip_merge_last_too_long() { | ||
503 | check_last( | ||
504 | "foo::bar", | ||
505 | r"use foo::bar::baz::Qux;", | ||
506 | r"use foo::bar; | ||
507 | use foo::bar::baz::Qux;", | ||
508 | ); | ||
509 | } | ||
510 | |||
511 | #[test] | ||
512 | fn skip_merge_last_too_long2() { | ||
513 | check_last( | ||
514 | "foo::bar::baz::Qux", | ||
515 | r"use foo::bar;", | ||
516 | r"use foo::bar; | ||
517 | use foo::bar::baz::Qux;", | ||
518 | ); | ||
519 | } | ||
520 | |||
521 | #[test] | ||
522 | fn insert_short_before_long() { | ||
523 | check_none( | ||
524 | "foo::bar", | ||
525 | r"use foo::bar::baz::Qux;", | ||
526 | r"use foo::bar; | ||
527 | use foo::bar::baz::Qux;", | ||
528 | ); | ||
529 | } | ||
530 | |||
531 | #[test] | ||
532 | fn merge_last_fail() { | ||
533 | check_merge_only_fail( | ||
534 | r"use foo::bar::{baz::{Qux, Fez}};", | ||
535 | r"use foo::bar::{baaz::{Quux, Feez}};", | ||
536 | MergeBehaviour::Last, | ||
537 | ); | ||
538 | } | ||
539 | |||
540 | #[test] | ||
541 | fn merge_last_fail1() { | ||
542 | check_merge_only_fail( | ||
543 | r"use foo::bar::{baz::{Qux, Fez}};", | ||
544 | r"use foo::bar::baaz::{Quux, Feez};", | ||
545 | MergeBehaviour::Last, | ||
546 | ); | ||
547 | } | ||
548 | |||
549 | #[test] | ||
550 | fn merge_last_fail2() { | ||
551 | check_merge_only_fail( | ||
552 | r"use foo::bar::baz::{Qux, Fez};", | ||
553 | r"use foo::bar::{baaz::{Quux, Feez}};", | ||
554 | MergeBehaviour::Last, | ||
555 | ); | ||
556 | } | ||
557 | |||
558 | #[test] | ||
559 | fn merge_last_fail3() { | ||
560 | check_merge_only_fail( | ||
561 | r"use foo::bar::baz::{Qux, Fez};", | ||
562 | r"use foo::bar::baaz::{Quux, Feez};", | ||
563 | MergeBehaviour::Last, | ||
564 | ); | ||
565 | } | ||
566 | |||
567 | fn check( | ||
568 | path: &str, | ||
569 | ra_fixture_before: &str, | ||
570 | ra_fixture_after: &str, | ||
571 | mb: Option<MergeBehaviour>, | ||
572 | module: bool, | ||
573 | ) { | ||
574 | let mut syntax = ast::SourceFile::parse(ra_fixture_before).tree().syntax().clone(); | ||
575 | if module { | ||
576 | syntax = syntax.descendants().find_map(ast::Module::cast).unwrap().syntax().clone(); | ||
577 | } | ||
578 | let file = super::ImportScope::from(syntax).unwrap(); | ||
579 | let path = ast::SourceFile::parse(&format!("use {};", path)) | ||
580 | .tree() | ||
581 | .syntax() | ||
582 | .descendants() | ||
583 | .find_map(ast::Path::cast) | ||
584 | .unwrap(); | ||
585 | |||
586 | let rewriter = insert_use(&file, path, mb); | ||
587 | let result = rewriter.rewrite(file.as_syntax_node()).to_string(); | ||
588 | assert_eq_text!(&result, ra_fixture_after); | ||
589 | } | ||
590 | |||
591 | fn check_full(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
592 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehaviour::Full), false) | ||
593 | } | ||
594 | |||
595 | fn check_last(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
596 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehaviour::Last), false) | ||
597 | } | ||
598 | |||
599 | fn check_none(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | ||
600 | check(path, ra_fixture_before, ra_fixture_after, None, false) | ||
601 | } | ||
602 | |||
603 | fn check_merge_only_fail(ra_fixture0: &str, ra_fixture1: &str, mb: MergeBehaviour) { | ||
604 | let use0 = ast::SourceFile::parse(ra_fixture0) | ||
605 | .tree() | ||
606 | .syntax() | ||
607 | .descendants() | ||
608 | .find_map(ast::Use::cast) | ||
609 | .unwrap(); | ||
610 | |||
611 | let use1 = ast::SourceFile::parse(ra_fixture1) | ||
612 | .tree() | ||
613 | .syntax() | ||
614 | .descendants() | ||
615 | .find_map(ast::Use::cast) | ||
616 | .unwrap(); | ||
617 | |||
618 | let result = try_merge_imports(&use0, &use1, mb); | ||
619 | assert_eq!(result.map(|u| u.to_string()), None); | ||
620 | } | ||
diff --git a/crates/ide_db/src/line_index.rs b/crates/ide_db/src/line_index.rs index a381f7fb8..41226305e 100644 --- a/crates/ide_db/src/line_index.rs +++ b/crates/ide_db/src/line_index.rs | |||
@@ -149,133 +149,4 @@ impl LineIndex { | |||
149 | } | 149 | } |
150 | 150 | ||
151 | #[cfg(test)] | 151 | #[cfg(test)] |
152 | mod tests { | 152 | mod tests; |
153 | use super::*; | ||
154 | |||
155 | #[test] | ||
156 | fn test_line_index() { | ||
157 | let text = "hello\nworld"; | ||
158 | let index = LineIndex::new(text); | ||
159 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | ||
160 | assert_eq!(index.line_col(1.into()), LineCol { line: 0, col_utf16: 1 }); | ||
161 | assert_eq!(index.line_col(5.into()), LineCol { line: 0, col_utf16: 5 }); | ||
162 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 0 }); | ||
163 | assert_eq!(index.line_col(7.into()), LineCol { line: 1, col_utf16: 1 }); | ||
164 | assert_eq!(index.line_col(8.into()), LineCol { line: 1, col_utf16: 2 }); | ||
165 | assert_eq!(index.line_col(10.into()), LineCol { line: 1, col_utf16: 4 }); | ||
166 | assert_eq!(index.line_col(11.into()), LineCol { line: 1, col_utf16: 5 }); | ||
167 | assert_eq!(index.line_col(12.into()), LineCol { line: 1, col_utf16: 6 }); | ||
168 | |||
169 | let text = "\nhello\nworld"; | ||
170 | let index = LineIndex::new(text); | ||
171 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | ||
172 | assert_eq!(index.line_col(1.into()), LineCol { line: 1, col_utf16: 0 }); | ||
173 | assert_eq!(index.line_col(2.into()), LineCol { line: 1, col_utf16: 1 }); | ||
174 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 5 }); | ||
175 | assert_eq!(index.line_col(7.into()), LineCol { line: 2, col_utf16: 0 }); | ||
176 | } | ||
177 | |||
178 | #[test] | ||
179 | fn test_char_len() { | ||
180 | assert_eq!('メ'.len_utf8(), 3); | ||
181 | assert_eq!('メ'.len_utf16(), 1); | ||
182 | } | ||
183 | |||
184 | #[test] | ||
185 | fn test_empty_index() { | ||
186 | let col_index = LineIndex::new( | ||
187 | " | ||
188 | const C: char = 'x'; | ||
189 | ", | ||
190 | ); | ||
191 | assert_eq!(col_index.utf16_lines.len(), 0); | ||
192 | } | ||
193 | |||
194 | #[test] | ||
195 | fn test_single_char() { | ||
196 | let col_index = LineIndex::new( | ||
197 | " | ||
198 | const C: char = 'メ'; | ||
199 | ", | ||
200 | ); | ||
201 | |||
202 | assert_eq!(col_index.utf16_lines.len(), 1); | ||
203 | assert_eq!(col_index.utf16_lines[&1].len(), 1); | ||
204 | assert_eq!(col_index.utf16_lines[&1][0], Utf16Char { start: 17.into(), end: 20.into() }); | ||
205 | |||
206 | // UTF-8 to UTF-16, no changes | ||
207 | assert_eq!(col_index.utf8_to_utf16_col(1, 15.into()), 15); | ||
208 | |||
209 | // UTF-8 to UTF-16 | ||
210 | assert_eq!(col_index.utf8_to_utf16_col(1, 22.into()), 20); | ||
211 | |||
212 | // UTF-16 to UTF-8, no changes | ||
213 | assert_eq!(col_index.utf16_to_utf8_col(1, 15), TextSize::from(15)); | ||
214 | |||
215 | // UTF-16 to UTF-8 | ||
216 | assert_eq!(col_index.utf16_to_utf8_col(1, 19), TextSize::from(21)); | ||
217 | |||
218 | let col_index = LineIndex::new("a𐐏b"); | ||
219 | assert_eq!(col_index.utf16_to_utf8_col(0, 3), TextSize::from(5)); | ||
220 | } | ||
221 | |||
222 | #[test] | ||
223 | fn test_string() { | ||
224 | let col_index = LineIndex::new( | ||
225 | " | ||
226 | const C: char = \"メ メ\"; | ||
227 | ", | ||
228 | ); | ||
229 | |||
230 | assert_eq!(col_index.utf16_lines.len(), 1); | ||
231 | assert_eq!(col_index.utf16_lines[&1].len(), 2); | ||
232 | assert_eq!(col_index.utf16_lines[&1][0], Utf16Char { start: 17.into(), end: 20.into() }); | ||
233 | assert_eq!(col_index.utf16_lines[&1][1], Utf16Char { start: 21.into(), end: 24.into() }); | ||
234 | |||
235 | // UTF-8 to UTF-16 | ||
236 | assert_eq!(col_index.utf8_to_utf16_col(1, 15.into()), 15); | ||
237 | |||
238 | assert_eq!(col_index.utf8_to_utf16_col(1, 21.into()), 19); | ||
239 | assert_eq!(col_index.utf8_to_utf16_col(1, 25.into()), 21); | ||
240 | |||
241 | assert!(col_index.utf8_to_utf16_col(2, 15.into()) == 15); | ||
242 | |||
243 | // UTF-16 to UTF-8 | ||
244 | assert_eq!(col_index.utf16_to_utf8_col(1, 15), TextSize::from(15)); | ||
245 | |||
246 | // メ UTF-8: 0xE3 0x83 0xA1, UTF-16: 0x30E1 | ||
247 | assert_eq!(col_index.utf16_to_utf8_col(1, 17), TextSize::from(17)); // first メ at 17..20 | ||
248 | assert_eq!(col_index.utf16_to_utf8_col(1, 18), TextSize::from(20)); // space | ||
249 | assert_eq!(col_index.utf16_to_utf8_col(1, 19), TextSize::from(21)); // second メ at 21..24 | ||
250 | |||
251 | assert_eq!(col_index.utf16_to_utf8_col(2, 15), TextSize::from(15)); | ||
252 | } | ||
253 | |||
254 | #[test] | ||
255 | fn test_splitlines() { | ||
256 | fn r(lo: u32, hi: u32) -> TextRange { | ||
257 | TextRange::new(lo.into(), hi.into()) | ||
258 | } | ||
259 | |||
260 | let text = "a\nbb\nccc\n"; | ||
261 | let line_index = LineIndex::new(text); | ||
262 | |||
263 | let actual = line_index.lines(r(0, 9)).collect::<Vec<_>>(); | ||
264 | let expected = vec![r(0, 2), r(2, 5), r(5, 9)]; | ||
265 | assert_eq!(actual, expected); | ||
266 | |||
267 | let text = ""; | ||
268 | let line_index = LineIndex::new(text); | ||
269 | |||
270 | let actual = line_index.lines(r(0, 0)).collect::<Vec<_>>(); | ||
271 | let expected = vec![]; | ||
272 | assert_eq!(actual, expected); | ||
273 | |||
274 | let text = "\n"; | ||
275 | let line_index = LineIndex::new(text); | ||
276 | |||
277 | let actual = line_index.lines(r(0, 1)).collect::<Vec<_>>(); | ||
278 | let expected = vec![r(0, 1)]; | ||
279 | assert_eq!(actual, expected) | ||
280 | } | ||
281 | } | ||
diff --git a/crates/ide_db/src/line_index/tests.rs b/crates/ide_db/src/line_index/tests.rs new file mode 100644 index 000000000..05f7484e8 --- /dev/null +++ b/crates/ide_db/src/line_index/tests.rs | |||
@@ -0,0 +1,128 @@ | |||
1 | use super::*; | ||
2 | |||
3 | #[test] | ||
4 | fn test_line_index() { | ||
5 | let text = "hello\nworld"; | ||
6 | let index = LineIndex::new(text); | ||
7 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | ||
8 | assert_eq!(index.line_col(1.into()), LineCol { line: 0, col_utf16: 1 }); | ||
9 | assert_eq!(index.line_col(5.into()), LineCol { line: 0, col_utf16: 5 }); | ||
10 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 0 }); | ||
11 | assert_eq!(index.line_col(7.into()), LineCol { line: 1, col_utf16: 1 }); | ||
12 | assert_eq!(index.line_col(8.into()), LineCol { line: 1, col_utf16: 2 }); | ||
13 | assert_eq!(index.line_col(10.into()), LineCol { line: 1, col_utf16: 4 }); | ||
14 | assert_eq!(index.line_col(11.into()), LineCol { line: 1, col_utf16: 5 }); | ||
15 | assert_eq!(index.line_col(12.into()), LineCol { line: 1, col_utf16: 6 }); | ||
16 | |||
17 | let text = "\nhello\nworld"; | ||
18 | let index = LineIndex::new(text); | ||
19 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | ||
20 | assert_eq!(index.line_col(1.into()), LineCol { line: 1, col_utf16: 0 }); | ||
21 | assert_eq!(index.line_col(2.into()), LineCol { line: 1, col_utf16: 1 }); | ||
22 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 5 }); | ||
23 | assert_eq!(index.line_col(7.into()), LineCol { line: 2, col_utf16: 0 }); | ||
24 | } | ||
25 | |||
26 | #[test] | ||
27 | fn test_char_len() { | ||
28 | assert_eq!('メ'.len_utf8(), 3); | ||
29 | assert_eq!('メ'.len_utf16(), 1); | ||
30 | } | ||
31 | |||
32 | #[test] | ||
33 | fn test_empty_index() { | ||
34 | let col_index = LineIndex::new( | ||
35 | " | ||
36 | const C: char = 'x'; | ||
37 | ", | ||
38 | ); | ||
39 | assert_eq!(col_index.utf16_lines.len(), 0); | ||
40 | } | ||
41 | |||
42 | #[test] | ||
43 | fn test_single_char() { | ||
44 | let col_index = LineIndex::new( | ||
45 | " | ||
46 | const C: char = 'メ'; | ||
47 | ", | ||
48 | ); | ||
49 | |||
50 | assert_eq!(col_index.utf16_lines.len(), 1); | ||
51 | assert_eq!(col_index.utf16_lines[&1].len(), 1); | ||
52 | assert_eq!(col_index.utf16_lines[&1][0], Utf16Char { start: 17.into(), end: 20.into() }); | ||
53 | |||
54 | // UTF-8 to UTF-16, no changes | ||
55 | assert_eq!(col_index.utf8_to_utf16_col(1, 15.into()), 15); | ||
56 | |||
57 | // UTF-8 to UTF-16 | ||
58 | assert_eq!(col_index.utf8_to_utf16_col(1, 22.into()), 20); | ||
59 | |||
60 | // UTF-16 to UTF-8, no changes | ||
61 | assert_eq!(col_index.utf16_to_utf8_col(1, 15), TextSize::from(15)); | ||
62 | |||
63 | // UTF-16 to UTF-8 | ||
64 | assert_eq!(col_index.utf16_to_utf8_col(1, 19), TextSize::from(21)); | ||
65 | |||
66 | let col_index = LineIndex::new("a𐐏b"); | ||
67 | assert_eq!(col_index.utf16_to_utf8_col(0, 3), TextSize::from(5)); | ||
68 | } | ||
69 | |||
70 | #[test] | ||
71 | fn test_string() { | ||
72 | let col_index = LineIndex::new( | ||
73 | " | ||
74 | const C: char = \"メ メ\"; | ||
75 | ", | ||
76 | ); | ||
77 | |||
78 | assert_eq!(col_index.utf16_lines.len(), 1); | ||
79 | assert_eq!(col_index.utf16_lines[&1].len(), 2); | ||
80 | assert_eq!(col_index.utf16_lines[&1][0], Utf16Char { start: 17.into(), end: 20.into() }); | ||
81 | assert_eq!(col_index.utf16_lines[&1][1], Utf16Char { start: 21.into(), end: 24.into() }); | ||
82 | |||
83 | // UTF-8 to UTF-16 | ||
84 | assert_eq!(col_index.utf8_to_utf16_col(1, 15.into()), 15); | ||
85 | |||
86 | assert_eq!(col_index.utf8_to_utf16_col(1, 21.into()), 19); | ||
87 | assert_eq!(col_index.utf8_to_utf16_col(1, 25.into()), 21); | ||
88 | |||
89 | assert!(col_index.utf8_to_utf16_col(2, 15.into()) == 15); | ||
90 | |||
91 | // UTF-16 to UTF-8 | ||
92 | assert_eq!(col_index.utf16_to_utf8_col(1, 15), TextSize::from(15)); | ||
93 | |||
94 | // メ UTF-8: 0xE3 0x83 0xA1, UTF-16: 0x30E1 | ||
95 | assert_eq!(col_index.utf16_to_utf8_col(1, 17), TextSize::from(17)); // first メ at 17..20 | ||
96 | assert_eq!(col_index.utf16_to_utf8_col(1, 18), TextSize::from(20)); // space | ||
97 | assert_eq!(col_index.utf16_to_utf8_col(1, 19), TextSize::from(21)); // second メ at 21..24 | ||
98 | |||
99 | assert_eq!(col_index.utf16_to_utf8_col(2, 15), TextSize::from(15)); | ||
100 | } | ||
101 | |||
102 | #[test] | ||
103 | fn test_splitlines() { | ||
104 | fn r(lo: u32, hi: u32) -> TextRange { | ||
105 | TextRange::new(lo.into(), hi.into()) | ||
106 | } | ||
107 | |||
108 | let text = "a\nbb\nccc\n"; | ||
109 | let line_index = LineIndex::new(text); | ||
110 | |||
111 | let actual = line_index.lines(r(0, 9)).collect::<Vec<_>>(); | ||
112 | let expected = vec![r(0, 2), r(2, 5), r(5, 9)]; | ||
113 | assert_eq!(actual, expected); | ||
114 | |||
115 | let text = ""; | ||
116 | let line_index = LineIndex::new(text); | ||
117 | |||
118 | let actual = line_index.lines(r(0, 0)).collect::<Vec<_>>(); | ||
119 | let expected = vec![]; | ||
120 | assert_eq!(actual, expected); | ||
121 | |||
122 | let text = "\n"; | ||
123 | let line_index = LineIndex::new(text); | ||
124 | |||
125 | let actual = line_index.lines(r(0, 1)).collect::<Vec<_>>(); | ||
126 | let expected = vec![r(0, 1)]; | ||
127 | assert_eq!(actual, expected) | ||
128 | } | ||
diff --git a/crates/ide_db/src/traits.rs b/crates/ide_db/src/traits.rs index f57b6dd91..78a43f587 100644 --- a/crates/ide_db/src/traits.rs +++ b/crates/ide_db/src/traits.rs | |||
@@ -78,150 +78,4 @@ pub fn get_missing_assoc_items( | |||
78 | } | 78 | } |
79 | 79 | ||
80 | #[cfg(test)] | 80 | #[cfg(test)] |
81 | mod tests { | 81 | mod tests; |
82 | use crate::RootDatabase; | ||
83 | use base_db::{fixture::ChangeFixture, FilePosition}; | ||
84 | use expect_test::{expect, Expect}; | ||
85 | use hir::Semantics; | ||
86 | use syntax::ast::{self, AstNode}; | ||
87 | use test_utils::RangeOrOffset; | ||
88 | |||
89 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. | ||
90 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { | ||
91 | let change_fixture = ChangeFixture::parse(ra_fixture); | ||
92 | let mut database = RootDatabase::default(); | ||
93 | database.apply_change(change_fixture.change); | ||
94 | let (file_id, range_or_offset) = | ||
95 | change_fixture.file_position.expect("expected a marker (<|>)"); | ||
96 | let offset = match range_or_offset { | ||
97 | RangeOrOffset::Range(_) => panic!(), | ||
98 | RangeOrOffset::Offset(it) => it, | ||
99 | }; | ||
100 | (database, FilePosition { file_id, offset }) | ||
101 | } | ||
102 | |||
103 | fn check_trait(ra_fixture: &str, expect: Expect) { | ||
104 | let (db, position) = position(ra_fixture); | ||
105 | let sema = Semantics::new(&db); | ||
106 | let file = sema.parse(position.file_id); | ||
107 | let impl_block: ast::Impl = | ||
108 | sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap(); | ||
109 | let trait_ = crate::traits::resolve_target_trait(&sema, &impl_block); | ||
110 | let actual = match trait_ { | ||
111 | Some(trait_) => trait_.name(&db).to_string(), | ||
112 | None => String::new(), | ||
113 | }; | ||
114 | expect.assert_eq(&actual); | ||
115 | } | ||
116 | |||
117 | fn check_missing_assoc(ra_fixture: &str, expect: Expect) { | ||
118 | let (db, position) = position(ra_fixture); | ||
119 | let sema = Semantics::new(&db); | ||
120 | let file = sema.parse(position.file_id); | ||
121 | let impl_block: ast::Impl = | ||
122 | sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap(); | ||
123 | let items = crate::traits::get_missing_assoc_items(&sema, &impl_block); | ||
124 | let actual = items | ||
125 | .into_iter() | ||
126 | .map(|item| item.name(&db).unwrap().to_string()) | ||
127 | .collect::<Vec<_>>() | ||
128 | .join("\n"); | ||
129 | expect.assert_eq(&actual); | ||
130 | } | ||
131 | |||
132 | #[test] | ||
133 | fn resolve_trait() { | ||
134 | check_trait( | ||
135 | r#" | ||
136 | pub trait Foo { | ||
137 | fn bar(); | ||
138 | } | ||
139 | impl Foo for u8 { | ||
140 | <|> | ||
141 | } | ||
142 | "#, | ||
143 | expect![["Foo"]], | ||
144 | ); | ||
145 | check_trait( | ||
146 | r#" | ||
147 | pub trait Foo { | ||
148 | fn bar(); | ||
149 | } | ||
150 | impl Foo for u8 { | ||
151 | fn bar() { | ||
152 | fn baz() { | ||
153 | <|> | ||
154 | } | ||
155 | baz(); | ||
156 | } | ||
157 | } | ||
158 | "#, | ||
159 | expect![["Foo"]], | ||
160 | ); | ||
161 | check_trait( | ||
162 | r#" | ||
163 | pub trait Foo { | ||
164 | fn bar(); | ||
165 | } | ||
166 | pub struct Bar; | ||
167 | impl Bar { | ||
168 | <|> | ||
169 | } | ||
170 | "#, | ||
171 | expect![[""]], | ||
172 | ); | ||
173 | } | ||
174 | |||
175 | #[test] | ||
176 | fn missing_assoc_items() { | ||
177 | check_missing_assoc( | ||
178 | r#" | ||
179 | pub trait Foo { | ||
180 | const FOO: u8; | ||
181 | fn bar(); | ||
182 | } | ||
183 | impl Foo for u8 { | ||
184 | <|> | ||
185 | }"#, | ||
186 | expect![[r#" | ||
187 | FOO | ||
188 | bar"#]], | ||
189 | ); | ||
190 | |||
191 | check_missing_assoc( | ||
192 | r#" | ||
193 | pub trait Foo { | ||
194 | const FOO: u8; | ||
195 | fn bar(); | ||
196 | } | ||
197 | impl Foo for u8 { | ||
198 | const FOO: u8 = 10; | ||
199 | <|> | ||
200 | }"#, | ||
201 | expect![[r#" | ||
202 | bar"#]], | ||
203 | ); | ||
204 | |||
205 | check_missing_assoc( | ||
206 | r#" | ||
207 | pub trait Foo { | ||
208 | const FOO: u8; | ||
209 | fn bar(); | ||
210 | } | ||
211 | impl Foo for u8 { | ||
212 | const FOO: u8 = 10; | ||
213 | fn bar() {<|>} | ||
214 | }"#, | ||
215 | expect![[r#""#]], | ||
216 | ); | ||
217 | |||
218 | check_missing_assoc( | ||
219 | r#" | ||
220 | pub struct Foo; | ||
221 | impl Foo { | ||
222 | fn bar() {<|>} | ||
223 | }"#, | ||
224 | expect![[r#""#]], | ||
225 | ); | ||
226 | } | ||
227 | } | ||
diff --git a/crates/ide_db/src/traits/tests.rs b/crates/ide_db/src/traits/tests.rs new file mode 100644 index 000000000..09c7ac3ec --- /dev/null +++ b/crates/ide_db/src/traits/tests.rs | |||
@@ -0,0 +1,144 @@ | |||
1 | use crate::RootDatabase; | ||
2 | use base_db::{fixture::ChangeFixture, FilePosition}; | ||
3 | use expect_test::{expect, Expect}; | ||
4 | use hir::Semantics; | ||
5 | use syntax::ast::{self, AstNode}; | ||
6 | use test_utils::RangeOrOffset; | ||
7 | |||
8 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. | ||
9 | pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { | ||
10 | let change_fixture = ChangeFixture::parse(ra_fixture); | ||
11 | let mut database = RootDatabase::default(); | ||
12 | database.apply_change(change_fixture.change); | ||
13 | let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); | ||
14 | let offset = match range_or_offset { | ||
15 | RangeOrOffset::Range(_) => panic!(), | ||
16 | RangeOrOffset::Offset(it) => it, | ||
17 | }; | ||
18 | (database, FilePosition { file_id, offset }) | ||
19 | } | ||
20 | |||
21 | fn check_trait(ra_fixture: &str, expect: Expect) { | ||
22 | let (db, position) = position(ra_fixture); | ||
23 | let sema = Semantics::new(&db); | ||
24 | let file = sema.parse(position.file_id); | ||
25 | let impl_block: ast::Impl = | ||
26 | sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap(); | ||
27 | let trait_ = crate::traits::resolve_target_trait(&sema, &impl_block); | ||
28 | let actual = match trait_ { | ||
29 | Some(trait_) => trait_.name(&db).to_string(), | ||
30 | None => String::new(), | ||
31 | }; | ||
32 | expect.assert_eq(&actual); | ||
33 | } | ||
34 | |||
35 | fn check_missing_assoc(ra_fixture: &str, expect: Expect) { | ||
36 | let (db, position) = position(ra_fixture); | ||
37 | let sema = Semantics::new(&db); | ||
38 | let file = sema.parse(position.file_id); | ||
39 | let impl_block: ast::Impl = | ||
40 | sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap(); | ||
41 | let items = crate::traits::get_missing_assoc_items(&sema, &impl_block); | ||
42 | let actual = items | ||
43 | .into_iter() | ||
44 | .map(|item| item.name(&db).unwrap().to_string()) | ||
45 | .collect::<Vec<_>>() | ||
46 | .join("\n"); | ||
47 | expect.assert_eq(&actual); | ||
48 | } | ||
49 | |||
50 | #[test] | ||
51 | fn resolve_trait() { | ||
52 | check_trait( | ||
53 | r#" | ||
54 | pub trait Foo { | ||
55 | fn bar(); | ||
56 | } | ||
57 | impl Foo for u8 { | ||
58 | <|> | ||
59 | } | ||
60 | "#, | ||
61 | expect![["Foo"]], | ||
62 | ); | ||
63 | check_trait( | ||
64 | r#" | ||
65 | pub trait Foo { | ||
66 | fn bar(); | ||
67 | } | ||
68 | impl Foo for u8 { | ||
69 | fn bar() { | ||
70 | fn baz() { | ||
71 | <|> | ||
72 | } | ||
73 | baz(); | ||
74 | } | ||
75 | } | ||
76 | "#, | ||
77 | expect![["Foo"]], | ||
78 | ); | ||
79 | check_trait( | ||
80 | r#" | ||
81 | pub trait Foo { | ||
82 | fn bar(); | ||
83 | } | ||
84 | pub struct Bar; | ||
85 | impl Bar { | ||
86 | <|> | ||
87 | } | ||
88 | "#, | ||
89 | expect![[""]], | ||
90 | ); | ||
91 | } | ||
92 | |||
93 | #[test] | ||
94 | fn missing_assoc_items() { | ||
95 | check_missing_assoc( | ||
96 | r#" | ||
97 | pub trait Foo { | ||
98 | const FOO: u8; | ||
99 | fn bar(); | ||
100 | } | ||
101 | impl Foo for u8 { | ||
102 | <|> | ||
103 | }"#, | ||
104 | expect![[r#" | ||
105 | FOO | ||
106 | bar"#]], | ||
107 | ); | ||
108 | |||
109 | check_missing_assoc( | ||
110 | r#" | ||
111 | pub trait Foo { | ||
112 | const FOO: u8; | ||
113 | fn bar(); | ||
114 | } | ||
115 | impl Foo for u8 { | ||
116 | const FOO: u8 = 10; | ||
117 | <|> | ||
118 | }"#, | ||
119 | expect![[r#" | ||
120 | bar"#]], | ||
121 | ); | ||
122 | |||
123 | check_missing_assoc( | ||
124 | r#" | ||
125 | pub trait Foo { | ||
126 | const FOO: u8; | ||
127 | fn bar(); | ||
128 | } | ||
129 | impl Foo for u8 { | ||
130 | const FOO: u8 = 10; | ||
131 | fn bar() {<|>} | ||
132 | }"#, | ||
133 | expect![[r#""#]], | ||
134 | ); | ||
135 | |||
136 | check_missing_assoc( | ||
137 | r#" | ||
138 | pub struct Foo; | ||
139 | impl Foo { | ||
140 | fn bar() {<|>} | ||
141 | }"#, | ||
142 | expect![[r#""#]], | ||
143 | ); | ||
144 | } | ||
diff --git a/crates/proc_macro_api/Cargo.toml b/crates/proc_macro_api/Cargo.toml index 3863e5189..1af2bbca7 100644 --- a/crates/proc_macro_api/Cargo.toml +++ b/crates/proc_macro_api/Cargo.toml | |||
@@ -17,3 +17,4 @@ crossbeam-channel = "0.5.0" | |||
17 | jod-thread = "0.1.1" | 17 | jod-thread = "0.1.1" |
18 | 18 | ||
19 | tt = { path = "../tt", version = "0.0.0" } | 19 | tt = { path = "../tt", version = "0.0.0" } |
20 | base_db = { path = "../base_db", version = "0.0.0" } | ||
diff --git a/crates/proc_macro_api/src/lib.rs b/crates/proc_macro_api/src/lib.rs index d5e87cf7d..0d061fd53 100644 --- a/crates/proc_macro_api/src/lib.rs +++ b/crates/proc_macro_api/src/lib.rs | |||
@@ -16,6 +16,7 @@ use std::{ | |||
16 | sync::Arc, | 16 | sync::Arc, |
17 | }; | 17 | }; |
18 | 18 | ||
19 | use base_db::ProcMacro; | ||
19 | use tt::{SmolStr, Subtree}; | 20 | use tt::{SmolStr, Subtree}; |
20 | 21 | ||
21 | use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; | 22 | use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; |
@@ -23,7 +24,7 @@ use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; | |||
23 | pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}; | 24 | pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}; |
24 | 25 | ||
25 | #[derive(Debug, Clone)] | 26 | #[derive(Debug, Clone)] |
26 | pub struct ProcMacroProcessExpander { | 27 | struct ProcMacroProcessExpander { |
27 | process: Arc<ProcMacroProcessSrv>, | 28 | process: Arc<ProcMacroProcessSrv>, |
28 | dylib_path: PathBuf, | 29 | dylib_path: PathBuf, |
29 | name: SmolStr, | 30 | name: SmolStr, |
@@ -42,21 +43,24 @@ impl tt::TokenExpander for ProcMacroProcessExpander { | |||
42 | fn expand( | 43 | fn expand( |
43 | &self, | 44 | &self, |
44 | subtree: &Subtree, | 45 | subtree: &Subtree, |
45 | _attr: Option<&Subtree>, | 46 | attr: Option<&Subtree>, |
46 | ) -> Result<Subtree, tt::ExpansionError> { | 47 | ) -> Result<Subtree, tt::ExpansionError> { |
47 | self.process.custom_derive(&self.dylib_path, subtree, &self.name) | 48 | let task = ExpansionTask { |
48 | } | 49 | macro_body: subtree.clone(), |
49 | } | 50 | macro_name: self.name.to_string(), |
51 | attributes: attr.cloned(), | ||
52 | lib: self.dylib_path.to_path_buf(), | ||
53 | }; | ||
50 | 54 | ||
51 | #[derive(Debug)] | 55 | let result: ExpansionResult = self.process.send_task(msg::Request::ExpansionMacro(task))?; |
52 | enum ProcMacroClientKind { | 56 | Ok(result.expansion) |
53 | Process { process: Arc<ProcMacroProcessSrv>, thread: ProcMacroProcessThread }, | 57 | } |
54 | Dummy, | ||
55 | } | 58 | } |
56 | 59 | ||
57 | #[derive(Debug)] | 60 | #[derive(Debug)] |
58 | pub struct ProcMacroClient { | 61 | pub struct ProcMacroClient { |
59 | kind: ProcMacroClientKind, | 62 | process: Arc<ProcMacroProcessSrv>, |
63 | thread: ProcMacroProcessThread, | ||
60 | } | 64 | } |
61 | 65 | ||
62 | impl ProcMacroClient { | 66 | impl ProcMacroClient { |
@@ -65,47 +69,35 @@ impl ProcMacroClient { | |||
65 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | 69 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
66 | ) -> io::Result<ProcMacroClient> { | 70 | ) -> io::Result<ProcMacroClient> { |
67 | let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; | 71 | let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; |
68 | Ok(ProcMacroClient { | 72 | Ok(ProcMacroClient { process: Arc::new(process), thread }) |
69 | kind: ProcMacroClientKind::Process { process: Arc::new(process), thread }, | ||
70 | }) | ||
71 | } | 73 | } |
72 | 74 | ||
73 | pub fn dummy() -> ProcMacroClient { | 75 | pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<ProcMacro> { |
74 | ProcMacroClient { kind: ProcMacroClientKind::Dummy } | 76 | let macros = match self.process.find_proc_macros(dylib_path) { |
75 | } | 77 | Err(err) => { |
78 | eprintln!("Failed to find proc macros. Error: {:#?}", err); | ||
79 | return vec![]; | ||
80 | } | ||
81 | Ok(macros) => macros, | ||
82 | }; | ||
76 | 83 | ||
77 | pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc<dyn tt::TokenExpander>)> { | 84 | macros |
78 | match &self.kind { | 85 | .into_iter() |
79 | ProcMacroClientKind::Dummy => vec![], | 86 | .map(|(name, kind)| { |
80 | ProcMacroClientKind::Process { process, .. } => { | 87 | let name = SmolStr::new(&name); |
81 | let macros = match process.find_proc_macros(dylib_path) { | 88 | let kind = match kind { |
82 | Err(err) => { | 89 | ProcMacroKind::CustomDerive => base_db::ProcMacroKind::CustomDerive, |
83 | eprintln!("Failed to find proc macros. Error: {:#?}", err); | 90 | ProcMacroKind::FuncLike => base_db::ProcMacroKind::FuncLike, |
84 | return vec![]; | 91 | ProcMacroKind::Attr => base_db::ProcMacroKind::Attr, |
85 | } | ||
86 | Ok(macros) => macros, | ||
87 | }; | 92 | }; |
93 | let expander: Arc<dyn tt::TokenExpander> = Arc::new(ProcMacroProcessExpander { | ||
94 | process: self.process.clone(), | ||
95 | name: name.clone(), | ||
96 | dylib_path: dylib_path.into(), | ||
97 | }); | ||
88 | 98 | ||
89 | macros | 99 | ProcMacro { name, kind, expander } |
90 | .into_iter() | 100 | }) |
91 | .filter_map(|(name, kind)| { | 101 | .collect() |
92 | match kind { | ||
93 | ProcMacroKind::CustomDerive | ProcMacroKind::FuncLike => { | ||
94 | let name = SmolStr::new(&name); | ||
95 | let expander: Arc<dyn tt::TokenExpander> = | ||
96 | Arc::new(ProcMacroProcessExpander { | ||
97 | process: process.clone(), | ||
98 | name: name.clone(), | ||
99 | dylib_path: dylib_path.into(), | ||
100 | }); | ||
101 | Some((name, expander)) | ||
102 | } | ||
103 | // FIXME: Attribute macro are currently unsupported. | ||
104 | ProcMacroKind::Attr => None, | ||
105 | } | ||
106 | }) | ||
107 | .collect() | ||
108 | } | ||
109 | } | ||
110 | } | 102 | } |
111 | } | 103 | } |
diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index 907cb3db7..d68723ada 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs | |||
@@ -10,16 +10,15 @@ use std::{ | |||
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crossbeam_channel::{bounded, Receiver, Sender}; | 12 | use crossbeam_channel::{bounded, Receiver, Sender}; |
13 | use tt::Subtree; | ||
14 | 13 | ||
15 | use crate::{ | 14 | use crate::{ |
16 | msg::{ErrorCode, Message, Request, Response, ResponseError}, | 15 | msg::{ErrorCode, Message, Request, Response, ResponseError}, |
17 | rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}, | 16 | rpc::{ListMacrosResult, ListMacrosTask, ProcMacroKind}, |
18 | }; | 17 | }; |
19 | 18 | ||
20 | #[derive(Debug, Default)] | 19 | #[derive(Debug, Default)] |
21 | pub(crate) struct ProcMacroProcessSrv { | 20 | pub(crate) struct ProcMacroProcessSrv { |
22 | inner: Option<Weak<Sender<Task>>>, | 21 | inner: Weak<Sender<Task>>, |
23 | } | 22 | } |
24 | 23 | ||
25 | #[derive(Debug)] | 24 | #[derive(Debug)] |
@@ -42,7 +41,7 @@ impl ProcMacroProcessSrv { | |||
42 | }); | 41 | }); |
43 | 42 | ||
44 | let task_tx = Arc::new(task_tx); | 43 | let task_tx = Arc::new(task_tx); |
45 | let srv = ProcMacroProcessSrv { inner: Some(Arc::downgrade(&task_tx)) }; | 44 | let srv = ProcMacroProcessSrv { inner: Arc::downgrade(&task_tx) }; |
46 | let thread = ProcMacroProcessThread { handle, sender: task_tx }; | 45 | let thread = ProcMacroProcessThread { handle, sender: task_tx }; |
47 | 46 | ||
48 | Ok((thread, srv)) | 47 | Ok((thread, srv)) |
@@ -58,43 +57,22 @@ impl ProcMacroProcessSrv { | |||
58 | Ok(result.macros) | 57 | Ok(result.macros) |
59 | } | 58 | } |
60 | 59 | ||
61 | pub(crate) fn custom_derive( | ||
62 | &self, | ||
63 | dylib_path: &Path, | ||
64 | subtree: &Subtree, | ||
65 | derive_name: &str, | ||
66 | ) -> Result<Subtree, tt::ExpansionError> { | ||
67 | let task = ExpansionTask { | ||
68 | macro_body: subtree.clone(), | ||
69 | macro_name: derive_name.to_string(), | ||
70 | attributes: None, | ||
71 | lib: dylib_path.to_path_buf(), | ||
72 | }; | ||
73 | |||
74 | let result: ExpansionResult = self.send_task(Request::ExpansionMacro(task))?; | ||
75 | Ok(result.expansion) | ||
76 | } | ||
77 | |||
78 | pub(crate) fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError> | 60 | pub(crate) fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError> |
79 | where | 61 | where |
80 | R: TryFrom<Response, Error = &'static str>, | 62 | R: TryFrom<Response, Error = &'static str>, |
81 | { | 63 | { |
82 | let sender = match &self.inner { | ||
83 | None => return Err(tt::ExpansionError::Unknown("No sender is found.".to_string())), | ||
84 | Some(it) => it, | ||
85 | }; | ||
86 | |||
87 | let (result_tx, result_rx) = bounded(0); | 64 | let (result_tx, result_rx) = bounded(0); |
88 | let sender = match sender.upgrade() { | 65 | let sender = match self.inner.upgrade() { |
89 | None => { | 66 | None => return Err(tt::ExpansionError::Unknown("proc macro process is closed".into())), |
90 | return Err(tt::ExpansionError::Unknown("Proc macro process is closed.".into())) | ||
91 | } | ||
92 | Some(it) => it, | 67 | Some(it) => it, |
93 | }; | 68 | }; |
94 | sender.send(Task { req, result_tx }).unwrap(); | 69 | sender |
70 | .send(Task { req, result_tx }) | ||
71 | .map_err(|_| tt::ExpansionError::Unknown("proc macro server crashed".into()))?; | ||
72 | |||
95 | let res = result_rx | 73 | let res = result_rx |
96 | .recv() | 74 | .recv() |
97 | .map_err(|_| tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; | 75 | .map_err(|_| tt::ExpansionError::Unknown("proc macro server crashed".into()))?; |
98 | 76 | ||
99 | match res { | 77 | match res { |
100 | Some(Response::Error(err)) => { | 78 | Some(Response::Error(err)) => { |
@@ -109,32 +87,23 @@ impl ProcMacroProcessSrv { | |||
109 | } | 87 | } |
110 | 88 | ||
111 | fn client_loop(task_rx: Receiver<Task>, mut process: Process) { | 89 | fn client_loop(task_rx: Receiver<Task>, mut process: Process) { |
112 | let (mut stdin, mut stdout) = match process.stdio() { | 90 | let (mut stdin, mut stdout) = process.stdio().expect("couldn't access child stdio"); |
113 | None => return, | ||
114 | Some(it) => it, | ||
115 | }; | ||
116 | |||
117 | for task in task_rx { | ||
118 | let Task { req, result_tx } = task; | ||
119 | 91 | ||
92 | for Task { req, result_tx } in task_rx { | ||
120 | match send_request(&mut stdin, &mut stdout, req) { | 93 | match send_request(&mut stdin, &mut stdout, req) { |
121 | Ok(res) => result_tx.send(res).unwrap(), | 94 | Ok(res) => result_tx.send(res).unwrap(), |
122 | Err(_err) => { | 95 | Err(_err) => { |
96 | log::error!( | ||
97 | "proc macro server crashed, server process state: {:?}", | ||
98 | process.child.try_wait() | ||
99 | ); | ||
123 | let res = Response::Error(ResponseError { | 100 | let res = Response::Error(ResponseError { |
124 | code: ErrorCode::ServerErrorEnd, | 101 | code: ErrorCode::ServerErrorEnd, |
125 | message: "Server closed".into(), | 102 | message: "proc macro server crashed".into(), |
126 | }); | 103 | }); |
127 | result_tx.send(res.into()).unwrap(); | 104 | result_tx.send(res.into()).unwrap(); |
128 | // Restart the process | 105 | // Exit the thread. |
129 | if process.restart().is_err() { | 106 | break; |
130 | break; | ||
131 | } | ||
132 | let stdio = match process.stdio() { | ||
133 | None => break, | ||
134 | Some(it) => it, | ||
135 | }; | ||
136 | stdin = stdio.0; | ||
137 | stdout = stdio.1; | ||
138 | } | 107 | } |
139 | } | 108 | } |
140 | } | 109 | } |
@@ -146,8 +115,6 @@ struct Task { | |||
146 | } | 115 | } |
147 | 116 | ||
148 | struct Process { | 117 | struct Process { |
149 | path: PathBuf, | ||
150 | args: Vec<OsString>, | ||
151 | child: Child, | 118 | child: Child, |
152 | } | 119 | } |
153 | 120 | ||
@@ -162,15 +129,9 @@ impl Process { | |||
162 | path: PathBuf, | 129 | path: PathBuf, |
163 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | 130 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
164 | ) -> io::Result<Process> { | 131 | ) -> io::Result<Process> { |
165 | let args = args.into_iter().map(|s| s.as_ref().into()).collect(); | 132 | let args: Vec<OsString> = args.into_iter().map(|s| s.as_ref().into()).collect(); |
166 | let child = mk_child(&path, &args)?; | 133 | let child = mk_child(&path, &args)?; |
167 | Ok(Process { path, args, child }) | 134 | Ok(Process { child }) |
168 | } | ||
169 | |||
170 | fn restart(&mut self) -> io::Result<()> { | ||
171 | let _ = self.child.kill(); | ||
172 | self.child = mk_child(&self.path, &self.args)?; | ||
173 | Ok(()) | ||
174 | } | 135 | } |
175 | 136 | ||
176 | fn stdio(&mut self) -> Option<(impl Write, impl BufRead)> { | 137 | fn stdio(&mut self) -> Option<(impl Write, impl BufRead)> { |
diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs index 203109ca4..b85f92eea 100644 --- a/crates/proc_macro_api/src/rpc.rs +++ b/crates/proc_macro_api/src/rpc.rs | |||
@@ -19,7 +19,7 @@ pub struct ListMacrosTask { | |||
19 | pub lib: PathBuf, | 19 | pub lib: PathBuf, |
20 | } | 20 | } |
21 | 21 | ||
22 | #[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] | 22 | #[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] |
23 | pub enum ProcMacroKind { | 23 | pub enum ProcMacroKind { |
24 | CustomDerive, | 24 | CustomDerive, |
25 | FuncLike, | 25 | FuncLike, |
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs index a71f96164..ab5cbae11 100644 --- a/crates/project_model/src/workspace.rs +++ b/crates/project_model/src/workspace.rs | |||
@@ -2,10 +2,14 @@ | |||
2 | //! metadata` or `rust-project.json`) into representation stored in the salsa | 2 | //! metadata` or `rust-project.json`) into representation stored in the salsa |
3 | //! database -- `CrateGraph`. | 3 | //! database -- `CrateGraph`. |
4 | 4 | ||
5 | use std::{fmt, fs, path::Component, process::Command}; | 5 | use std::{ |
6 | fmt, fs, | ||
7 | path::{Component, Path}, | ||
8 | process::Command, | ||
9 | }; | ||
6 | 10 | ||
7 | use anyhow::{Context, Result}; | 11 | use anyhow::{Context, Result}; |
8 | use base_db::{CrateDisplayName, CrateGraph, CrateId, CrateName, Edition, Env, FileId}; | 12 | use base_db::{CrateDisplayName, CrateGraph, CrateId, CrateName, Edition, Env, FileId, ProcMacro}; |
9 | use cfg::CfgOptions; | 13 | use cfg::CfgOptions; |
10 | use paths::{AbsPath, AbsPathBuf}; | 14 | use paths::{AbsPath, AbsPathBuf}; |
11 | use proc_macro_api::ProcMacroClient; | 15 | use proc_macro_api::ProcMacroClient; |
@@ -194,15 +198,20 @@ impl ProjectWorkspace { | |||
194 | pub fn to_crate_graph( | 198 | pub fn to_crate_graph( |
195 | &self, | 199 | &self, |
196 | target: Option<&str>, | 200 | target: Option<&str>, |
197 | proc_macro_client: &ProcMacroClient, | 201 | proc_macro_client: Option<&ProcMacroClient>, |
198 | load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, | 202 | load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, |
199 | ) -> CrateGraph { | 203 | ) -> CrateGraph { |
204 | let proc_macro_loader = |path: &Path| match proc_macro_client { | ||
205 | Some(client) => client.by_dylib_path(path), | ||
206 | None => Vec::new(), | ||
207 | }; | ||
208 | |||
200 | let mut crate_graph = match self { | 209 | let mut crate_graph = match self { |
201 | ProjectWorkspace::Json { project, sysroot } => { | 210 | ProjectWorkspace::Json { project, sysroot } => { |
202 | project_json_to_crate_graph(target, proc_macro_client, load, project, sysroot) | 211 | project_json_to_crate_graph(target, &proc_macro_loader, load, project, sysroot) |
203 | } | 212 | } |
204 | ProjectWorkspace::Cargo { cargo, sysroot, rustc } => { | 213 | ProjectWorkspace::Cargo { cargo, sysroot, rustc } => { |
205 | cargo_to_crate_graph(target, proc_macro_client, load, cargo, sysroot, rustc) | 214 | cargo_to_crate_graph(target, &proc_macro_loader, load, cargo, sysroot, rustc) |
206 | } | 215 | } |
207 | }; | 216 | }; |
208 | if crate_graph.patch_cfg_if() { | 217 | if crate_graph.patch_cfg_if() { |
@@ -216,7 +225,7 @@ impl ProjectWorkspace { | |||
216 | 225 | ||
217 | fn project_json_to_crate_graph( | 226 | fn project_json_to_crate_graph( |
218 | target: Option<&str>, | 227 | target: Option<&str>, |
219 | proc_macro_client: &ProcMacroClient, | 228 | proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>, |
220 | load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, | 229 | load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, |
221 | project: &ProjectJson, | 230 | project: &ProjectJson, |
222 | sysroot: &Option<Sysroot>, | 231 | sysroot: &Option<Sysroot>, |
@@ -236,8 +245,7 @@ fn project_json_to_crate_graph( | |||
236 | }) | 245 | }) |
237 | .map(|(crate_id, krate, file_id)| { | 246 | .map(|(crate_id, krate, file_id)| { |
238 | let env = krate.env.clone().into_iter().collect(); | 247 | let env = krate.env.clone().into_iter().collect(); |
239 | let proc_macro = | 248 | let proc_macro = krate.proc_macro_dylib_path.clone().map(|it| proc_macro_loader(&it)); |
240 | krate.proc_macro_dylib_path.clone().map(|it| proc_macro_client.by_dylib_path(&it)); | ||
241 | 249 | ||
242 | let target = krate.target.as_deref().or(target); | 250 | let target = krate.target.as_deref().or(target); |
243 | let target_cfgs = | 251 | let target_cfgs = |
@@ -279,7 +287,7 @@ fn project_json_to_crate_graph( | |||
279 | 287 | ||
280 | fn cargo_to_crate_graph( | 288 | fn cargo_to_crate_graph( |
281 | target: Option<&str>, | 289 | target: Option<&str>, |
282 | proc_macro_client: &ProcMacroClient, | 290 | proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>, |
283 | load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, | 291 | load: &mut dyn FnMut(&AbsPath) -> Option<FileId>, |
284 | cargo: &CargoWorkspace, | 292 | cargo: &CargoWorkspace, |
285 | sysroot: &Sysroot, | 293 | sysroot: &Sysroot, |
@@ -309,7 +317,7 @@ fn cargo_to_crate_graph( | |||
309 | &mut crate_graph, | 317 | &mut crate_graph, |
310 | &cargo[pkg], | 318 | &cargo[pkg], |
311 | &cfg_options, | 319 | &cfg_options, |
312 | proc_macro_client, | 320 | proc_macro_loader, |
313 | file_id, | 321 | file_id, |
314 | ); | 322 | ); |
315 | if cargo[tgt].kind == TargetKind::Lib { | 323 | if cargo[tgt].kind == TargetKind::Lib { |
@@ -385,7 +393,7 @@ fn cargo_to_crate_graph( | |||
385 | &mut crate_graph, | 393 | &mut crate_graph, |
386 | &rustc_workspace[pkg], | 394 | &rustc_workspace[pkg], |
387 | &cfg_options, | 395 | &cfg_options, |
388 | proc_macro_client, | 396 | proc_macro_loader, |
389 | file_id, | 397 | file_id, |
390 | ); | 398 | ); |
391 | pkg_to_lib_crate.insert(pkg, crate_id); | 399 | pkg_to_lib_crate.insert(pkg, crate_id); |
@@ -433,7 +441,7 @@ fn add_target_crate_root( | |||
433 | crate_graph: &mut CrateGraph, | 441 | crate_graph: &mut CrateGraph, |
434 | pkg: &cargo_workspace::PackageData, | 442 | pkg: &cargo_workspace::PackageData, |
435 | cfg_options: &CfgOptions, | 443 | cfg_options: &CfgOptions, |
436 | proc_macro_client: &ProcMacroClient, | 444 | proc_macro_loader: &dyn Fn(&Path) -> Vec<ProcMacro>, |
437 | file_id: FileId, | 445 | file_id: FileId, |
438 | ) -> CrateId { | 446 | ) -> CrateId { |
439 | let edition = pkg.edition; | 447 | let edition = pkg.edition; |
@@ -452,11 +460,8 @@ fn add_target_crate_root( | |||
452 | env.set("OUT_DIR", out_dir); | 460 | env.set("OUT_DIR", out_dir); |
453 | } | 461 | } |
454 | } | 462 | } |
455 | let proc_macro = pkg | 463 | let proc_macro = |
456 | .proc_macro_dylib_path | 464 | pkg.proc_macro_dylib_path.as_ref().map(|it| proc_macro_loader(&it)).unwrap_or_default(); |
457 | .as_ref() | ||
458 | .map(|it| proc_macro_client.by_dylib_path(&it)) | ||
459 | .unwrap_or_default(); | ||
460 | 465 | ||
461 | let display_name = CrateDisplayName::from_canonical_name(pkg.name.clone()); | 466 | let display_name = CrateDisplayName::from_canonical_name(pkg.name.clone()); |
462 | let crate_id = crate_graph.add_crate_root( | 467 | let crate_id = crate_graph.add_crate_root( |
diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs index 368f627ac..0090fd2c2 100644 --- a/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/crates/rust-analyzer/src/cli/diagnostics.rs | |||
@@ -6,12 +6,25 @@ use std::path::Path; | |||
6 | use anyhow::anyhow; | 6 | use anyhow::anyhow; |
7 | use rustc_hash::FxHashSet; | 7 | use rustc_hash::FxHashSet; |
8 | 8 | ||
9 | use hir::Crate; | 9 | use hir::{db::HirDatabase, Crate, Module}; |
10 | use ide::{DiagnosticsConfig, Severity}; | 10 | use ide::{DiagnosticsConfig, Severity}; |
11 | use ide_db::base_db::SourceDatabaseExt; | 11 | use ide_db::base_db::SourceDatabaseExt; |
12 | 12 | ||
13 | use crate::cli::{load_cargo::load_cargo, Result}; | 13 | use crate::cli::{load_cargo::load_cargo, Result}; |
14 | 14 | ||
15 | fn all_modules(db: &dyn HirDatabase) -> Vec<Module> { | ||
16 | let mut worklist: Vec<_> = | ||
17 | Crate::all(db).into_iter().map(|krate| krate.root_module(db)).collect(); | ||
18 | let mut modules = Vec::new(); | ||
19 | |||
20 | while let Some(module) = worklist.pop() { | ||
21 | modules.push(module); | ||
22 | worklist.extend(module.children(db)); | ||
23 | } | ||
24 | |||
25 | modules | ||
26 | } | ||
27 | |||
15 | pub fn diagnostics(path: &Path, load_output_dirs: bool, with_proc_macro: bool) -> Result<()> { | 28 | pub fn diagnostics(path: &Path, load_output_dirs: bool, with_proc_macro: bool) -> Result<()> { |
16 | let (host, _vfs) = load_cargo(path, load_output_dirs, with_proc_macro)?; | 29 | let (host, _vfs) = load_cargo(path, load_output_dirs, with_proc_macro)?; |
17 | let db = host.raw_database(); | 30 | let db = host.raw_database(); |
@@ -20,18 +33,12 @@ pub fn diagnostics(path: &Path, load_output_dirs: bool, with_proc_macro: bool) - | |||
20 | let mut found_error = false; | 33 | let mut found_error = false; |
21 | let mut visited_files = FxHashSet::default(); | 34 | let mut visited_files = FxHashSet::default(); |
22 | 35 | ||
23 | let mut work = Vec::new(); | 36 | let work = all_modules(db).into_iter().filter(|module| { |
24 | let krates = Crate::all(db); | 37 | let file_id = module.definition_source(db).file_id.original_file(db); |
25 | for krate in krates { | ||
26 | let module = krate.root_module(db); | ||
27 | let file_id = module.definition_source(db).file_id; | ||
28 | let file_id = file_id.original_file(db); | ||
29 | let source_root = db.file_source_root(file_id); | 38 | let source_root = db.file_source_root(file_id); |
30 | let source_root = db.source_root(source_root); | 39 | let source_root = db.source_root(source_root); |
31 | if !source_root.is_library { | 40 | !source_root.is_library |
32 | work.push(module); | 41 | }); |
33 | } | ||
34 | } | ||
35 | 42 | ||
36 | for module in work { | 43 | for module in work { |
37 | let file_id = module.definition_source(db).file_id.original_file(db); | 44 | let file_id = module.definition_source(db).file_id.original_file(db); |
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 76526c66c..d51f4a93a 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs | |||
@@ -33,12 +33,12 @@ pub fn load_cargo( | |||
33 | 33 | ||
34 | let proc_macro_client = if with_proc_macro { | 34 | let proc_macro_client = if with_proc_macro { |
35 | let path = std::env::current_exe()?; | 35 | let path = std::env::current_exe()?; |
36 | ProcMacroClient::extern_process(path, &["proc-macro"]).unwrap() | 36 | Some(ProcMacroClient::extern_process(path, &["proc-macro"]).unwrap()) |
37 | } else { | 37 | } else { |
38 | ProcMacroClient::dummy() | 38 | None |
39 | }; | 39 | }; |
40 | 40 | ||
41 | let crate_graph = ws.to_crate_graph(None, &proc_macro_client, &mut |path: &AbsPath| { | 41 | let crate_graph = ws.to_crate_graph(None, proc_macro_client.as_ref(), &mut |path: &AbsPath| { |
42 | let contents = loader.load_sync(path); | 42 | let contents = loader.load_sync(path); |
43 | let path = vfs::VfsPath::from(path.to_path_buf()); | 43 | let path = vfs::VfsPath::from(path.to_path_buf()); |
44 | vfs.set_file_contents(path.clone(), contents); | 44 | vfs.set_file_contents(path.clone(), contents); |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt index 72f6c5725..7576097b3 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt | |||
@@ -104,4 +104,168 @@ | |||
104 | }, | 104 | }, |
105 | fixes: [], | 105 | fixes: [], |
106 | }, | 106 | }, |
107 | MappedRustDiagnostic { | ||
108 | url: Url { | ||
109 | scheme: "file", | ||
110 | host: None, | ||
111 | port: None, | ||
112 | path: "/test/compiler/lib.rs", | ||
113 | query: None, | ||
114 | fragment: None, | ||
115 | }, | ||
116 | diagnostic: Diagnostic { | ||
117 | range: Range { | ||
118 | start: Position { | ||
119 | line: 0, | ||
120 | character: 8, | ||
121 | }, | ||
122 | end: Position { | ||
123 | line: 0, | ||
124 | character: 19, | ||
125 | }, | ||
126 | }, | ||
127 | severity: Some( | ||
128 | Hint, | ||
129 | ), | ||
130 | code: Some( | ||
131 | String( | ||
132 | "trivially_copy_pass_by_ref", | ||
133 | ), | ||
134 | ), | ||
135 | code_description: Some( | ||
136 | CodeDescription { | ||
137 | href: Url { | ||
138 | scheme: "https", | ||
139 | host: Some( | ||
140 | Domain( | ||
141 | "rust-lang.github.io", | ||
142 | ), | ||
143 | ), | ||
144 | port: None, | ||
145 | path: "/rust-clippy/master/index.html", | ||
146 | query: None, | ||
147 | fragment: Some( | ||
148 | "trivially_copy_pass_by_ref", | ||
149 | ), | ||
150 | }, | ||
151 | }, | ||
152 | ), | ||
153 | source: Some( | ||
154 | "clippy", | ||
155 | ), | ||
156 | message: "lint level defined here", | ||
157 | related_information: Some( | ||
158 | [ | ||
159 | DiagnosticRelatedInformation { | ||
160 | location: Location { | ||
161 | uri: Url { | ||
162 | scheme: "file", | ||
163 | host: None, | ||
164 | port: None, | ||
165 | path: "/test/compiler/mir/tagset.rs", | ||
166 | query: None, | ||
167 | fragment: None, | ||
168 | }, | ||
169 | range: Range { | ||
170 | start: Position { | ||
171 | line: 41, | ||
172 | character: 23, | ||
173 | }, | ||
174 | end: Position { | ||
175 | line: 41, | ||
176 | character: 28, | ||
177 | }, | ||
178 | }, | ||
179 | }, | ||
180 | message: "original diagnostic", | ||
181 | }, | ||
182 | ], | ||
183 | ), | ||
184 | tags: None, | ||
185 | data: None, | ||
186 | }, | ||
187 | fixes: [], | ||
188 | }, | ||
189 | MappedRustDiagnostic { | ||
190 | url: Url { | ||
191 | scheme: "file", | ||
192 | host: None, | ||
193 | port: None, | ||
194 | path: "/test/compiler/mir/tagset.rs", | ||
195 | query: None, | ||
196 | fragment: None, | ||
197 | }, | ||
198 | diagnostic: Diagnostic { | ||
199 | range: Range { | ||
200 | start: Position { | ||
201 | line: 41, | ||
202 | character: 23, | ||
203 | }, | ||
204 | end: Position { | ||
205 | line: 41, | ||
206 | character: 28, | ||
207 | }, | ||
208 | }, | ||
209 | severity: Some( | ||
210 | Hint, | ||
211 | ), | ||
212 | code: Some( | ||
213 | String( | ||
214 | "trivially_copy_pass_by_ref", | ||
215 | ), | ||
216 | ), | ||
217 | code_description: Some( | ||
218 | CodeDescription { | ||
219 | href: Url { | ||
220 | scheme: "https", | ||
221 | host: Some( | ||
222 | Domain( | ||
223 | "rust-lang.github.io", | ||
224 | ), | ||
225 | ), | ||
226 | port: None, | ||
227 | path: "/rust-clippy/master/index.html", | ||
228 | query: None, | ||
229 | fragment: Some( | ||
230 | "trivially_copy_pass_by_ref", | ||
231 | ), | ||
232 | }, | ||
233 | }, | ||
234 | ), | ||
235 | source: Some( | ||
236 | "clippy", | ||
237 | ), | ||
238 | message: "consider passing by value instead", | ||
239 | related_information: Some( | ||
240 | [ | ||
241 | DiagnosticRelatedInformation { | ||
242 | location: Location { | ||
243 | uri: Url { | ||
244 | scheme: "file", | ||
245 | host: None, | ||
246 | port: None, | ||
247 | path: "/test/compiler/mir/tagset.rs", | ||
248 | query: None, | ||
249 | fragment: None, | ||
250 | }, | ||
251 | range: Range { | ||
252 | start: Position { | ||
253 | line: 41, | ||
254 | character: 23, | ||
255 | }, | ||
256 | end: Position { | ||
257 | line: 41, | ||
258 | character: 28, | ||
259 | }, | ||
260 | }, | ||
261 | }, | ||
262 | message: "original diagnostic", | ||
263 | }, | ||
264 | ], | ||
265 | ), | ||
266 | tags: None, | ||
267 | data: None, | ||
268 | }, | ||
269 | fixes: [], | ||
270 | }, | ||
107 | ] | 271 | ] |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt index bbec6a796..bdcf2a38f 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt | |||
@@ -4,19 +4,19 @@ | |||
4 | scheme: "file", | 4 | scheme: "file", |
5 | host: None, | 5 | host: None, |
6 | port: None, | 6 | port: None, |
7 | path: "/test/crates/hir_def/src/data.rs", | 7 | path: "/test/crates/hir_def/src/path.rs", |
8 | query: None, | 8 | query: None, |
9 | fragment: None, | 9 | fragment: None, |
10 | }, | 10 | }, |
11 | diagnostic: Diagnostic { | 11 | diagnostic: Diagnostic { |
12 | range: Range { | 12 | range: Range { |
13 | start: Position { | 13 | start: Position { |
14 | line: 79, | 14 | line: 264, |
15 | character: 15, | 15 | character: 8, |
16 | }, | 16 | }, |
17 | end: Position { | 17 | end: Position { |
18 | line: 79, | 18 | line: 264, |
19 | character: 41, | 19 | character: 76, |
20 | }, | 20 | }, |
21 | }, | 21 | }, |
22 | severity: Some( | 22 | severity: Some( |
@@ -36,22 +36,22 @@ | |||
36 | scheme: "file", | 36 | scheme: "file", |
37 | host: None, | 37 | host: None, |
38 | port: None, | 38 | port: None, |
39 | path: "/test/crates/hir_def/src/path.rs", | 39 | path: "/test/crates/hir_def/src/data.rs", |
40 | query: None, | 40 | query: None, |
41 | fragment: None, | 41 | fragment: None, |
42 | }, | 42 | }, |
43 | range: Range { | 43 | range: Range { |
44 | start: Position { | 44 | start: Position { |
45 | line: 264, | 45 | line: 79, |
46 | character: 8, | 46 | character: 15, |
47 | }, | 47 | }, |
48 | end: Position { | 48 | end: Position { |
49 | line: 264, | 49 | line: 79, |
50 | character: 76, | 50 | character: 41, |
51 | }, | 51 | }, |
52 | }, | 52 | }, |
53 | }, | 53 | }, |
54 | message: "Error originated from macro here", | 54 | message: "Exact error occurred here", |
55 | }, | 55 | }, |
56 | ], | 56 | ], |
57 | ), | 57 | ), |
@@ -65,19 +65,19 @@ | |||
65 | scheme: "file", | 65 | scheme: "file", |
66 | host: None, | 66 | host: None, |
67 | port: None, | 67 | port: None, |
68 | path: "/test/crates/hir_def/src/path.rs", | 68 | path: "/test/crates/hir_def/src/data.rs", |
69 | query: None, | 69 | query: None, |
70 | fragment: None, | 70 | fragment: None, |
71 | }, | 71 | }, |
72 | diagnostic: Diagnostic { | 72 | diagnostic: Diagnostic { |
73 | range: Range { | 73 | range: Range { |
74 | start: Position { | 74 | start: Position { |
75 | line: 264, | 75 | line: 79, |
76 | character: 8, | 76 | character: 15, |
77 | }, | 77 | }, |
78 | end: Position { | 78 | end: Position { |
79 | line: 264, | 79 | line: 79, |
80 | character: 76, | 80 | character: 41, |
81 | }, | 81 | }, |
82 | }, | 82 | }, |
83 | severity: Some( | 83 | severity: Some( |
@@ -89,33 +89,7 @@ | |||
89 | "rustc", | 89 | "rustc", |
90 | ), | 90 | ), |
91 | message: "Please register your known path in the path module", | 91 | message: "Please register your known path in the path module", |
92 | related_information: Some( | 92 | related_information: None, |
93 | [ | ||
94 | DiagnosticRelatedInformation { | ||
95 | location: Location { | ||
96 | uri: Url { | ||
97 | scheme: "file", | ||
98 | host: None, | ||
99 | port: None, | ||
100 | path: "/test/crates/hir_def/src/data.rs", | ||
101 | query: None, | ||
102 | fragment: None, | ||
103 | }, | ||
104 | range: Range { | ||
105 | start: Position { | ||
106 | line: 79, | ||
107 | character: 15, | ||
108 | }, | ||
109 | end: Position { | ||
110 | line: 79, | ||
111 | character: 41, | ||
112 | }, | ||
113 | }, | ||
114 | }, | ||
115 | message: "Exact error occured here", | ||
116 | }, | ||
117 | ], | ||
118 | ), | ||
119 | tags: None, | 93 | tags: None, |
120 | data: None, | 94 | data: None, |
121 | }, | 95 | }, |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt index c709de95f..23d42b4d0 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt | |||
@@ -32,7 +32,33 @@ | |||
32 | "rustc", | 32 | "rustc", |
33 | ), | 33 | ), |
34 | message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", | 34 | message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", |
35 | related_information: None, | 35 | related_information: Some( |
36 | [ | ||
37 | DiagnosticRelatedInformation { | ||
38 | location: Location { | ||
39 | uri: Url { | ||
40 | scheme: "file", | ||
41 | host: None, | ||
42 | port: None, | ||
43 | path: "/test/driver/subcommand/repl.rs", | ||
44 | query: None, | ||
45 | fragment: None, | ||
46 | }, | ||
47 | range: Range { | ||
48 | start: Position { | ||
49 | line: 290, | ||
50 | character: 8, | ||
51 | }, | ||
52 | end: Position { | ||
53 | line: 290, | ||
54 | character: 11, | ||
55 | }, | ||
56 | }, | ||
57 | }, | ||
58 | message: "consider prefixing with an underscore", | ||
59 | }, | ||
60 | ], | ||
61 | ), | ||
36 | tags: Some( | 62 | tags: Some( |
37 | [ | 63 | [ |
38 | Unnecessary, | 64 | Unnecessary, |
@@ -87,4 +113,114 @@ | |||
87 | }, | 113 | }, |
88 | ], | 114 | ], |
89 | }, | 115 | }, |
116 | MappedRustDiagnostic { | ||
117 | url: Url { | ||
118 | scheme: "file", | ||
119 | host: None, | ||
120 | port: None, | ||
121 | path: "/test/driver/subcommand/repl.rs", | ||
122 | query: None, | ||
123 | fragment: None, | ||
124 | }, | ||
125 | diagnostic: Diagnostic { | ||
126 | range: Range { | ||
127 | start: Position { | ||
128 | line: 290, | ||
129 | character: 8, | ||
130 | }, | ||
131 | end: Position { | ||
132 | line: 290, | ||
133 | character: 11, | ||
134 | }, | ||
135 | }, | ||
136 | severity: Some( | ||
137 | Hint, | ||
138 | ), | ||
139 | code: Some( | ||
140 | String( | ||
141 | "unused_variables", | ||
142 | ), | ||
143 | ), | ||
144 | code_description: None, | ||
145 | source: Some( | ||
146 | "rustc", | ||
147 | ), | ||
148 | message: "consider prefixing with an underscore", | ||
149 | related_information: Some( | ||
150 | [ | ||
151 | DiagnosticRelatedInformation { | ||
152 | location: Location { | ||
153 | uri: Url { | ||
154 | scheme: "file", | ||
155 | host: None, | ||
156 | port: None, | ||
157 | path: "/test/driver/subcommand/repl.rs", | ||
158 | query: None, | ||
159 | fragment: None, | ||
160 | }, | ||
161 | range: Range { | ||
162 | start: Position { | ||
163 | line: 290, | ||
164 | character: 8, | ||
165 | }, | ||
166 | end: Position { | ||
167 | line: 290, | ||
168 | character: 11, | ||
169 | }, | ||
170 | }, | ||
171 | }, | ||
172 | message: "original diagnostic", | ||
173 | }, | ||
174 | ], | ||
175 | ), | ||
176 | tags: None, | ||
177 | data: None, | ||
178 | }, | ||
179 | fixes: [ | ||
180 | CodeAction { | ||
181 | title: "consider prefixing with an underscore", | ||
182 | group: None, | ||
183 | kind: Some( | ||
184 | CodeActionKind( | ||
185 | "quickfix", | ||
186 | ), | ||
187 | ), | ||
188 | edit: Some( | ||
189 | SnippetWorkspaceEdit { | ||
190 | changes: Some( | ||
191 | { | ||
192 | Url { | ||
193 | scheme: "file", | ||
194 | host: None, | ||
195 | port: None, | ||
196 | path: "/test/driver/subcommand/repl.rs", | ||
197 | query: None, | ||
198 | fragment: None, | ||
199 | }: [ | ||
200 | TextEdit { | ||
201 | range: Range { | ||
202 | start: Position { | ||
203 | line: 290, | ||
204 | character: 8, | ||
205 | }, | ||
206 | end: Position { | ||
207 | line: 290, | ||
208 | character: 11, | ||
209 | }, | ||
210 | }, | ||
211 | new_text: "_foo", | ||
212 | }, | ||
213 | ], | ||
214 | }, | ||
215 | ), | ||
216 | document_changes: None, | ||
217 | }, | ||
218 | ), | ||
219 | is_preferred: Some( | ||
220 | true, | ||
221 | ), | ||
222 | data: None, | ||
223 | }, | ||
224 | ], | ||
225 | }, | ||
90 | ] | 226 | ] |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt index 632f438d7..4e428bedc 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt | |||
@@ -32,7 +32,33 @@ | |||
32 | "rustc", | 32 | "rustc", |
33 | ), | 33 | ), |
34 | message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", | 34 | message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", |
35 | related_information: None, | 35 | related_information: Some( |
36 | [ | ||
37 | DiagnosticRelatedInformation { | ||
38 | location: Location { | ||
39 | uri: Url { | ||
40 | scheme: "file", | ||
41 | host: None, | ||
42 | port: None, | ||
43 | path: "/test/driver/subcommand/repl.rs", | ||
44 | query: None, | ||
45 | fragment: None, | ||
46 | }, | ||
47 | range: Range { | ||
48 | start: Position { | ||
49 | line: 290, | ||
50 | character: 8, | ||
51 | }, | ||
52 | end: Position { | ||
53 | line: 290, | ||
54 | character: 11, | ||
55 | }, | ||
56 | }, | ||
57 | }, | ||
58 | message: "consider prefixing with an underscore", | ||
59 | }, | ||
60 | ], | ||
61 | ), | ||
36 | tags: Some( | 62 | tags: Some( |
37 | [ | 63 | [ |
38 | Unnecessary, | 64 | Unnecessary, |
@@ -87,4 +113,114 @@ | |||
87 | }, | 113 | }, |
88 | ], | 114 | ], |
89 | }, | 115 | }, |
116 | MappedRustDiagnostic { | ||
117 | url: Url { | ||
118 | scheme: "file", | ||
119 | host: None, | ||
120 | port: None, | ||
121 | path: "/test/driver/subcommand/repl.rs", | ||
122 | query: None, | ||
123 | fragment: None, | ||
124 | }, | ||
125 | diagnostic: Diagnostic { | ||
126 | range: Range { | ||
127 | start: Position { | ||
128 | line: 290, | ||
129 | character: 8, | ||
130 | }, | ||
131 | end: Position { | ||
132 | line: 290, | ||
133 | character: 11, | ||
134 | }, | ||
135 | }, | ||
136 | severity: Some( | ||
137 | Hint, | ||
138 | ), | ||
139 | code: Some( | ||
140 | String( | ||
141 | "unused_variables", | ||
142 | ), | ||
143 | ), | ||
144 | code_description: None, | ||
145 | source: Some( | ||
146 | "rustc", | ||
147 | ), | ||
148 | message: "consider prefixing with an underscore", | ||
149 | related_information: Some( | ||
150 | [ | ||
151 | DiagnosticRelatedInformation { | ||
152 | location: Location { | ||
153 | uri: Url { | ||
154 | scheme: "file", | ||
155 | host: None, | ||
156 | port: None, | ||
157 | path: "/test/driver/subcommand/repl.rs", | ||
158 | query: None, | ||
159 | fragment: None, | ||
160 | }, | ||
161 | range: Range { | ||
162 | start: Position { | ||
163 | line: 290, | ||
164 | character: 8, | ||
165 | }, | ||
166 | end: Position { | ||
167 | line: 290, | ||
168 | character: 11, | ||
169 | }, | ||
170 | }, | ||
171 | }, | ||
172 | message: "original diagnostic", | ||
173 | }, | ||
174 | ], | ||
175 | ), | ||
176 | tags: None, | ||
177 | data: None, | ||
178 | }, | ||
179 | fixes: [ | ||
180 | CodeAction { | ||
181 | title: "consider prefixing with an underscore", | ||
182 | group: None, | ||
183 | kind: Some( | ||
184 | CodeActionKind( | ||
185 | "quickfix", | ||
186 | ), | ||
187 | ), | ||
188 | edit: Some( | ||
189 | SnippetWorkspaceEdit { | ||
190 | changes: Some( | ||
191 | { | ||
192 | Url { | ||
193 | scheme: "file", | ||
194 | host: None, | ||
195 | port: None, | ||
196 | path: "/test/driver/subcommand/repl.rs", | ||
197 | query: None, | ||
198 | fragment: None, | ||
199 | }: [ | ||
200 | TextEdit { | ||
201 | range: Range { | ||
202 | start: Position { | ||
203 | line: 290, | ||
204 | character: 8, | ||
205 | }, | ||
206 | end: Position { | ||
207 | line: 290, | ||
208 | character: 11, | ||
209 | }, | ||
210 | }, | ||
211 | new_text: "_foo", | ||
212 | }, | ||
213 | ], | ||
214 | }, | ||
215 | ), | ||
216 | document_changes: None, | ||
217 | }, | ||
218 | ), | ||
219 | is_preferred: Some( | ||
220 | true, | ||
221 | ), | ||
222 | data: None, | ||
223 | }, | ||
224 | ], | ||
225 | }, | ||
90 | ] | 226 | ] |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt index c0b79428d..4ddd7efae 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt | |||
@@ -32,7 +32,33 @@ | |||
32 | "rustc", | 32 | "rustc", |
33 | ), | 33 | ), |
34 | message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", | 34 | message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", |
35 | related_information: None, | 35 | related_information: Some( |
36 | [ | ||
37 | DiagnosticRelatedInformation { | ||
38 | location: Location { | ||
39 | uri: Url { | ||
40 | scheme: "file", | ||
41 | host: None, | ||
42 | port: None, | ||
43 | path: "/test/driver/subcommand/repl.rs", | ||
44 | query: None, | ||
45 | fragment: None, | ||
46 | }, | ||
47 | range: Range { | ||
48 | start: Position { | ||
49 | line: 290, | ||
50 | character: 8, | ||
51 | }, | ||
52 | end: Position { | ||
53 | line: 290, | ||
54 | character: 11, | ||
55 | }, | ||
56 | }, | ||
57 | }, | ||
58 | message: "consider prefixing with an underscore", | ||
59 | }, | ||
60 | ], | ||
61 | ), | ||
36 | tags: Some( | 62 | tags: Some( |
37 | [ | 63 | [ |
38 | Unnecessary, | 64 | Unnecessary, |
@@ -87,4 +113,114 @@ | |||
87 | }, | 113 | }, |
88 | ], | 114 | ], |
89 | }, | 115 | }, |
116 | MappedRustDiagnostic { | ||
117 | url: Url { | ||
118 | scheme: "file", | ||
119 | host: None, | ||
120 | port: None, | ||
121 | path: "/test/driver/subcommand/repl.rs", | ||
122 | query: None, | ||
123 | fragment: None, | ||
124 | }, | ||
125 | diagnostic: Diagnostic { | ||
126 | range: Range { | ||
127 | start: Position { | ||
128 | line: 290, | ||
129 | character: 8, | ||
130 | }, | ||
131 | end: Position { | ||
132 | line: 290, | ||
133 | character: 11, | ||
134 | }, | ||
135 | }, | ||
136 | severity: Some( | ||
137 | Hint, | ||
138 | ), | ||
139 | code: Some( | ||
140 | String( | ||
141 | "unused_variables", | ||
142 | ), | ||
143 | ), | ||
144 | code_description: None, | ||
145 | source: Some( | ||
146 | "rustc", | ||
147 | ), | ||
148 | message: "consider prefixing with an underscore", | ||
149 | related_information: Some( | ||
150 | [ | ||
151 | DiagnosticRelatedInformation { | ||
152 | location: Location { | ||
153 | uri: Url { | ||
154 | scheme: "file", | ||
155 | host: None, | ||
156 | port: None, | ||
157 | path: "/test/driver/subcommand/repl.rs", | ||
158 | query: None, | ||
159 | fragment: None, | ||
160 | }, | ||
161 | range: Range { | ||
162 | start: Position { | ||
163 | line: 290, | ||
164 | character: 8, | ||
165 | }, | ||
166 | end: Position { | ||
167 | line: 290, | ||
168 | character: 11, | ||
169 | }, | ||
170 | }, | ||
171 | }, | ||
172 | message: "original diagnostic", | ||
173 | }, | ||
174 | ], | ||
175 | ), | ||
176 | tags: None, | ||
177 | data: None, | ||
178 | }, | ||
179 | fixes: [ | ||
180 | CodeAction { | ||
181 | title: "consider prefixing with an underscore", | ||
182 | group: None, | ||
183 | kind: Some( | ||
184 | CodeActionKind( | ||
185 | "quickfix", | ||
186 | ), | ||
187 | ), | ||
188 | edit: Some( | ||
189 | SnippetWorkspaceEdit { | ||
190 | changes: Some( | ||
191 | { | ||
192 | Url { | ||
193 | scheme: "file", | ||
194 | host: None, | ||
195 | port: None, | ||
196 | path: "/test/driver/subcommand/repl.rs", | ||
197 | query: None, | ||
198 | fragment: None, | ||
199 | }: [ | ||
200 | TextEdit { | ||
201 | range: Range { | ||
202 | start: Position { | ||
203 | line: 290, | ||
204 | character: 8, | ||
205 | }, | ||
206 | end: Position { | ||
207 | line: 290, | ||
208 | character: 11, | ||
209 | }, | ||
210 | }, | ||
211 | new_text: "_foo", | ||
212 | }, | ||
213 | ], | ||
214 | }, | ||
215 | ), | ||
216 | document_changes: None, | ||
217 | }, | ||
218 | ), | ||
219 | is_preferred: Some( | ||
220 | true, | ||
221 | ), | ||
222 | data: None, | ||
223 | }, | ||
224 | ], | ||
225 | }, | ||
90 | ] | 226 | ] |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt index b9650f3e4..f455cf25e 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt | |||
@@ -81,4 +81,86 @@ | |||
81 | }, | 81 | }, |
82 | fixes: [], | 82 | fixes: [], |
83 | }, | 83 | }, |
84 | MappedRustDiagnostic { | ||
85 | url: Url { | ||
86 | scheme: "file", | ||
87 | host: None, | ||
88 | port: None, | ||
89 | path: "/test/compiler/ty/select.rs", | ||
90 | query: None, | ||
91 | fragment: None, | ||
92 | }, | ||
93 | diagnostic: Diagnostic { | ||
94 | range: Range { | ||
95 | start: Position { | ||
96 | line: 218, | ||
97 | character: 4, | ||
98 | }, | ||
99 | end: Position { | ||
100 | line: 230, | ||
101 | character: 5, | ||
102 | }, | ||
103 | }, | ||
104 | severity: Some( | ||
105 | Hint, | ||
106 | ), | ||
107 | code: Some( | ||
108 | String( | ||
109 | "E0061", | ||
110 | ), | ||
111 | ), | ||
112 | code_description: Some( | ||
113 | CodeDescription { | ||
114 | href: Url { | ||
115 | scheme: "https", | ||
116 | host: Some( | ||
117 | Domain( | ||
118 | "doc.rust-lang.org", | ||
119 | ), | ||
120 | ), | ||
121 | port: None, | ||
122 | path: "/error-index.html", | ||
123 | query: None, | ||
124 | fragment: Some( | ||
125 | "E0061", | ||
126 | ), | ||
127 | }, | ||
128 | }, | ||
129 | ), | ||
130 | source: Some( | ||
131 | "rustc", | ||
132 | ), | ||
133 | message: "defined here", | ||
134 | related_information: Some( | ||
135 | [ | ||
136 | DiagnosticRelatedInformation { | ||
137 | location: Location { | ||
138 | uri: Url { | ||
139 | scheme: "file", | ||
140 | host: None, | ||
141 | port: None, | ||
142 | path: "/test/compiler/ty/select.rs", | ||
143 | query: None, | ||
144 | fragment: None, | ||
145 | }, | ||
146 | range: Range { | ||
147 | start: Position { | ||
148 | line: 103, | ||
149 | character: 17, | ||
150 | }, | ||
151 | end: Position { | ||
152 | line: 103, | ||
153 | character: 29, | ||
154 | }, | ||
155 | }, | ||
156 | }, | ||
157 | message: "original diagnostic", | ||
158 | }, | ||
159 | ], | ||
160 | ), | ||
161 | tags: None, | ||
162 | data: None, | ||
163 | }, | ||
164 | fixes: [], | ||
165 | }, | ||
84 | ] | 166 | ] |
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt index c45f68a91..4cbdb3b92 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt | |||
@@ -74,6 +74,309 @@ | |||
74 | }, | 74 | }, |
75 | message: "unnecessary let binding", | 75 | message: "unnecessary let binding", |
76 | }, | 76 | }, |
77 | DiagnosticRelatedInformation { | ||
78 | location: Location { | ||
79 | uri: Url { | ||
80 | scheme: "file", | ||
81 | host: None, | ||
82 | port: None, | ||
83 | path: "/test/src/main.rs", | ||
84 | query: None, | ||
85 | fragment: None, | ||
86 | }, | ||
87 | range: Range { | ||
88 | start: Position { | ||
89 | line: 2, | ||
90 | character: 4, | ||
91 | }, | ||
92 | end: Position { | ||
93 | line: 2, | ||
94 | character: 30, | ||
95 | }, | ||
96 | }, | ||
97 | }, | ||
98 | message: "return the expression directly", | ||
99 | }, | ||
100 | ], | ||
101 | ), | ||
102 | tags: None, | ||
103 | data: None, | ||
104 | }, | ||
105 | fixes: [ | ||
106 | CodeAction { | ||
107 | title: "return the expression directly", | ||
108 | group: None, | ||
109 | kind: Some( | ||
110 | CodeActionKind( | ||
111 | "quickfix", | ||
112 | ), | ||
113 | ), | ||
114 | edit: Some( | ||
115 | SnippetWorkspaceEdit { | ||
116 | changes: Some( | ||
117 | { | ||
118 | Url { | ||
119 | scheme: "file", | ||
120 | host: None, | ||
121 | port: None, | ||
122 | path: "/test/src/main.rs", | ||
123 | query: None, | ||
124 | fragment: None, | ||
125 | }: [ | ||
126 | TextEdit { | ||
127 | range: Range { | ||
128 | start: Position { | ||
129 | line: 2, | ||
130 | character: 4, | ||
131 | }, | ||
132 | end: Position { | ||
133 | line: 2, | ||
134 | character: 30, | ||
135 | }, | ||
136 | }, | ||
137 | new_text: "", | ||
138 | }, | ||
139 | TextEdit { | ||
140 | range: Range { | ||
141 | start: Position { | ||
142 | line: 3, | ||
143 | character: 4, | ||
144 | }, | ||
145 | end: Position { | ||
146 | line: 3, | ||
147 | character: 5, | ||
148 | }, | ||
149 | }, | ||
150 | new_text: "(0..10).collect()", | ||
151 | }, | ||
152 | ], | ||
153 | }, | ||
154 | ), | ||
155 | document_changes: None, | ||
156 | }, | ||
157 | ), | ||
158 | is_preferred: Some( | ||
159 | true, | ||
160 | ), | ||
161 | data: None, | ||
162 | }, | ||
163 | ], | ||
164 | }, | ||
165 | MappedRustDiagnostic { | ||
166 | url: Url { | ||
167 | scheme: "file", | ||
168 | host: None, | ||
169 | port: None, | ||
170 | path: "/test/src/main.rs", | ||
171 | query: None, | ||
172 | fragment: None, | ||
173 | }, | ||
174 | diagnostic: Diagnostic { | ||
175 | range: Range { | ||
176 | start: Position { | ||
177 | line: 2, | ||
178 | character: 4, | ||
179 | }, | ||
180 | end: Position { | ||
181 | line: 2, | ||
182 | character: 30, | ||
183 | }, | ||
184 | }, | ||
185 | severity: Some( | ||
186 | Hint, | ||
187 | ), | ||
188 | code: Some( | ||
189 | String( | ||
190 | "let_and_return", | ||
191 | ), | ||
192 | ), | ||
193 | code_description: Some( | ||
194 | CodeDescription { | ||
195 | href: Url { | ||
196 | scheme: "https", | ||
197 | host: Some( | ||
198 | Domain( | ||
199 | "rust-lang.github.io", | ||
200 | ), | ||
201 | ), | ||
202 | port: None, | ||
203 | path: "/rust-clippy/master/index.html", | ||
204 | query: None, | ||
205 | fragment: Some( | ||
206 | "let_and_return", | ||
207 | ), | ||
208 | }, | ||
209 | }, | ||
210 | ), | ||
211 | source: Some( | ||
212 | "clippy", | ||
213 | ), | ||
214 | message: "unnecessary let binding", | ||
215 | related_information: Some( | ||
216 | [ | ||
217 | DiagnosticRelatedInformation { | ||
218 | location: Location { | ||
219 | uri: Url { | ||
220 | scheme: "file", | ||
221 | host: None, | ||
222 | port: None, | ||
223 | path: "/test/src/main.rs", | ||
224 | query: None, | ||
225 | fragment: None, | ||
226 | }, | ||
227 | range: Range { | ||
228 | start: Position { | ||
229 | line: 3, | ||
230 | character: 4, | ||
231 | }, | ||
232 | end: Position { | ||
233 | line: 3, | ||
234 | character: 5, | ||
235 | }, | ||
236 | }, | ||
237 | }, | ||
238 | message: "original diagnostic", | ||
239 | }, | ||
240 | ], | ||
241 | ), | ||
242 | tags: None, | ||
243 | data: None, | ||
244 | }, | ||
245 | fixes: [ | ||
246 | CodeAction { | ||
247 | title: "return the expression directly", | ||
248 | group: None, | ||
249 | kind: Some( | ||
250 | CodeActionKind( | ||
251 | "quickfix", | ||
252 | ), | ||
253 | ), | ||
254 | edit: Some( | ||
255 | SnippetWorkspaceEdit { | ||
256 | changes: Some( | ||
257 | { | ||
258 | Url { | ||
259 | scheme: "file", | ||
260 | host: None, | ||
261 | port: None, | ||
262 | path: "/test/src/main.rs", | ||
263 | query: None, | ||
264 | fragment: None, | ||
265 | }: [ | ||
266 | TextEdit { | ||
267 | range: Range { | ||
268 | start: Position { | ||
269 | line: 2, | ||
270 | character: 4, | ||
271 | }, | ||
272 | end: Position { | ||
273 | line: 2, | ||
274 | character: 30, | ||
275 | }, | ||
276 | }, | ||
277 | new_text: "", | ||
278 | }, | ||
279 | TextEdit { | ||
280 | range: Range { | ||
281 | start: Position { | ||
282 | line: 3, | ||
283 | character: 4, | ||
284 | }, | ||
285 | end: Position { | ||
286 | line: 3, | ||
287 | character: 5, | ||
288 | }, | ||
289 | }, | ||
290 | new_text: "(0..10).collect()", | ||
291 | }, | ||
292 | ], | ||
293 | }, | ||
294 | ), | ||
295 | document_changes: None, | ||
296 | }, | ||
297 | ), | ||
298 | is_preferred: Some( | ||
299 | true, | ||
300 | ), | ||
301 | data: None, | ||
302 | }, | ||
303 | ], | ||
304 | }, | ||
305 | MappedRustDiagnostic { | ||
306 | url: Url { | ||
307 | scheme: "file", | ||
308 | host: None, | ||
309 | port: None, | ||
310 | path: "/test/src/main.rs", | ||
311 | query: None, | ||
312 | fragment: None, | ||
313 | }, | ||
314 | diagnostic: Diagnostic { | ||
315 | range: Range { | ||
316 | start: Position { | ||
317 | line: 2, | ||
318 | character: 4, | ||
319 | }, | ||
320 | end: Position { | ||
321 | line: 2, | ||
322 | character: 30, | ||
323 | }, | ||
324 | }, | ||
325 | severity: Some( | ||
326 | Hint, | ||
327 | ), | ||
328 | code: Some( | ||
329 | String( | ||
330 | "let_and_return", | ||
331 | ), | ||
332 | ), | ||
333 | code_description: Some( | ||
334 | CodeDescription { | ||
335 | href: Url { | ||
336 | scheme: "https", | ||
337 | host: Some( | ||
338 | Domain( | ||
339 | "rust-lang.github.io", | ||
340 | ), | ||
341 | ), | ||
342 | port: None, | ||
343 | path: "/rust-clippy/master/index.html", | ||
344 | query: None, | ||
345 | fragment: Some( | ||
346 | "let_and_return", | ||
347 | ), | ||
348 | }, | ||
349 | }, | ||
350 | ), | ||
351 | source: Some( | ||
352 | "clippy", | ||
353 | ), | ||
354 | message: "return the expression directly", | ||
355 | related_information: Some( | ||
356 | [ | ||
357 | DiagnosticRelatedInformation { | ||
358 | location: Location { | ||
359 | uri: Url { | ||
360 | scheme: "file", | ||
361 | host: None, | ||
362 | port: None, | ||
363 | path: "/test/src/main.rs", | ||
364 | query: None, | ||
365 | fragment: None, | ||
366 | }, | ||
367 | range: Range { | ||
368 | start: Position { | ||
369 | line: 3, | ||
370 | character: 4, | ||
371 | }, | ||
372 | end: Position { | ||
373 | line: 3, | ||
374 | character: 5, | ||
375 | }, | ||
376 | }, | ||
377 | }, | ||
378 | message: "original diagnostic", | ||
379 | }, | ||
77 | ], | 380 | ], |
78 | ), | 381 | ), |
79 | tags: None, | 382 | tags: None, |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 324019614..f16f97131 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -75,8 +75,10 @@ fn diagnostic_related_information( | |||
75 | } | 75 | } |
76 | 76 | ||
77 | enum MappedRustChildDiagnostic { | 77 | enum MappedRustChildDiagnostic { |
78 | Related(lsp_types::DiagnosticRelatedInformation), | 78 | Related { |
79 | SuggestedFix(lsp_ext::CodeAction), | 79 | related: lsp_types::DiagnosticRelatedInformation, |
80 | suggested_fix: Option<lsp_ext::CodeAction>, | ||
81 | }, | ||
80 | MessageLine(String), | 82 | MessageLine(String), |
81 | } | 83 | } |
82 | 84 | ||
@@ -103,23 +105,32 @@ fn map_rust_child_diagnostic( | |||
103 | } | 105 | } |
104 | 106 | ||
105 | if edit_map.is_empty() { | 107 | if edit_map.is_empty() { |
106 | MappedRustChildDiagnostic::Related(lsp_types::DiagnosticRelatedInformation { | 108 | MappedRustChildDiagnostic::Related { |
107 | location: location(workspace_root, spans[0]), | 109 | related: lsp_types::DiagnosticRelatedInformation { |
108 | message: rd.message.clone(), | 110 | location: location(workspace_root, spans[0]), |
109 | }) | 111 | message: rd.message.clone(), |
112 | }, | ||
113 | suggested_fix: None, | ||
114 | } | ||
110 | } else { | 115 | } else { |
111 | MappedRustChildDiagnostic::SuggestedFix(lsp_ext::CodeAction { | 116 | MappedRustChildDiagnostic::Related { |
112 | title: rd.message.clone(), | 117 | related: lsp_types::DiagnosticRelatedInformation { |
113 | group: None, | 118 | location: location(workspace_root, spans[0]), |
114 | kind: Some(lsp_types::CodeActionKind::QUICKFIX), | 119 | message: rd.message.clone(), |
115 | edit: Some(lsp_ext::SnippetWorkspaceEdit { | 120 | }, |
116 | // FIXME: there's no good reason to use edit_map here.... | 121 | suggested_fix: Some(lsp_ext::CodeAction { |
117 | changes: Some(edit_map), | 122 | title: rd.message.clone(), |
118 | document_changes: None, | 123 | group: None, |
124 | kind: Some(lsp_types::CodeActionKind::QUICKFIX), | ||
125 | edit: Some(lsp_ext::SnippetWorkspaceEdit { | ||
126 | // FIXME: there's no good reason to use edit_map here.... | ||
127 | changes: Some(edit_map), | ||
128 | document_changes: None, | ||
129 | }), | ||
130 | is_preferred: Some(true), | ||
131 | data: None, | ||
119 | }), | 132 | }), |
120 | is_preferred: Some(true), | 133 | } |
121 | data: None, | ||
122 | }) | ||
123 | } | 134 | } |
124 | } | 135 | } |
125 | 136 | ||
@@ -179,8 +190,12 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
179 | for child in &rd.children { | 190 | for child in &rd.children { |
180 | let child = map_rust_child_diagnostic(workspace_root, &child); | 191 | let child = map_rust_child_diagnostic(workspace_root, &child); |
181 | match child { | 192 | match child { |
182 | MappedRustChildDiagnostic::Related(related) => related_information.push(related), | 193 | MappedRustChildDiagnostic::Related { related, suggested_fix } => { |
183 | MappedRustChildDiagnostic::SuggestedFix(code_action) => fixes.push(code_action), | 194 | related_information.push(related); |
195 | if let Some(code_action) = suggested_fix { | ||
196 | fixes.push(code_action); | ||
197 | } | ||
198 | } | ||
184 | MappedRustChildDiagnostic::MessageLine(message_line) => { | 199 | MappedRustChildDiagnostic::MessageLine(message_line) => { |
185 | format_to!(message, "\n{}", message_line); | 200 | format_to!(message, "\n{}", message_line); |
186 | 201 | ||
@@ -219,7 +234,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
219 | 234 | ||
220 | primary_spans | 235 | primary_spans |
221 | .iter() | 236 | .iter() |
222 | .map(|primary_span| { | 237 | .flat_map(|primary_span| { |
223 | let location = location(workspace_root, &primary_span); | 238 | let location = location(workspace_root, &primary_span); |
224 | 239 | ||
225 | let mut message = message.clone(); | 240 | let mut message = message.clone(); |
@@ -229,72 +244,100 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
229 | } | 244 | } |
230 | } | 245 | } |
231 | 246 | ||
247 | // Each primary diagnostic span may result in multiple LSP diagnostics. | ||
248 | let mut diagnostics = Vec::new(); | ||
249 | |||
250 | let mut related_macro_info = None; | ||
251 | |||
232 | // If error occurs from macro expansion, add related info pointing to | 252 | // If error occurs from macro expansion, add related info pointing to |
233 | // where the error originated | 253 | // where the error originated |
234 | // Also, we would generate an additional diagnostic, so that exact place of macro | 254 | // Also, we would generate an additional diagnostic, so that exact place of macro |
235 | // will be highlighted in the error origin place. | 255 | // will be highlighted in the error origin place. |
236 | let additional_diagnostic = | 256 | if !is_from_macro(&primary_span.file_name) && primary_span.expansion.is_some() { |
237 | if !is_from_macro(&primary_span.file_name) && primary_span.expansion.is_some() { | 257 | let in_macro_location = location_naive(workspace_root, &primary_span); |
238 | let in_macro_location = location_naive(workspace_root, &primary_span); | ||
239 | 258 | ||
240 | // Add related information for the main disagnostic. | 259 | // Add related information for the main disagnostic. |
241 | related_information.push(lsp_types::DiagnosticRelatedInformation { | 260 | related_macro_info = Some(lsp_types::DiagnosticRelatedInformation { |
242 | location: in_macro_location.clone(), | 261 | location: in_macro_location.clone(), |
243 | message: "Error originated from macro here".to_string(), | 262 | message: "Error originated from macro here".to_string(), |
244 | }); | 263 | }); |
245 | 264 | ||
246 | // For the additional in-macro diagnostic we add the inverse message pointing to the error location in code. | 265 | // For the additional in-macro diagnostic we add the inverse message pointing to the error location in code. |
247 | let information_for_additional_diagnostic = | 266 | let information_for_additional_diagnostic = |
248 | vec![lsp_types::DiagnosticRelatedInformation { | 267 | vec![lsp_types::DiagnosticRelatedInformation { |
249 | location: location.clone(), | 268 | location: location.clone(), |
250 | message: "Exact error occured here".to_string(), | 269 | message: "Exact error occurred here".to_string(), |
251 | }]; | 270 | }]; |
252 | 271 | ||
253 | let diagnostic = lsp_types::Diagnostic { | 272 | let diagnostic = lsp_types::Diagnostic { |
254 | range: in_macro_location.range, | 273 | range: in_macro_location.range, |
255 | severity, | 274 | severity, |
256 | code: code.clone().map(lsp_types::NumberOrString::String), | 275 | code: code.clone().map(lsp_types::NumberOrString::String), |
257 | code_description: code_description.clone(), | 276 | code_description: code_description.clone(), |
258 | source: Some(source.clone()), | 277 | source: Some(source.clone()), |
259 | message: message.clone(), | 278 | message: message.clone(), |
260 | related_information: Some(information_for_additional_diagnostic), | 279 | related_information: Some(information_for_additional_diagnostic), |
261 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, | 280 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, |
262 | data: None, | 281 | data: None, |
263 | }; | ||
264 | |||
265 | Some(MappedRustDiagnostic { | ||
266 | url: in_macro_location.uri, | ||
267 | diagnostic, | ||
268 | fixes: fixes.clone(), | ||
269 | }) | ||
270 | } else { | ||
271 | None | ||
272 | }; | 282 | }; |
273 | 283 | ||
274 | let diagnostic = lsp_types::Diagnostic { | 284 | diagnostics.push(MappedRustDiagnostic { |
275 | range: location.range, | 285 | url: in_macro_location.uri, |
276 | severity, | 286 | diagnostic, |
277 | code: code.clone().map(lsp_types::NumberOrString::String), | 287 | fixes: fixes.clone(), |
278 | code_description: code_description.clone(), | 288 | }); |
279 | source: Some(source.clone()), | 289 | } |
280 | message, | 290 | |
281 | related_information: if related_information.is_empty() { | 291 | // Emit the primary diagnostic. |
282 | None | 292 | diagnostics.push(MappedRustDiagnostic { |
283 | } else { | 293 | url: location.uri.clone(), |
284 | Some(related_information.clone()) | 294 | diagnostic: lsp_types::Diagnostic { |
295 | range: location.range, | ||
296 | severity, | ||
297 | code: code.clone().map(lsp_types::NumberOrString::String), | ||
298 | code_description: code_description.clone(), | ||
299 | source: Some(source.clone()), | ||
300 | message, | ||
301 | related_information: if related_information.is_empty() { | ||
302 | None | ||
303 | } else { | ||
304 | let mut related = related_information.clone(); | ||
305 | related.extend(related_macro_info); | ||
306 | Some(related) | ||
307 | }, | ||
308 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, | ||
309 | data: None, | ||
285 | }, | 310 | }, |
286 | tags: if tags.is_empty() { None } else { Some(tags.clone()) }, | 311 | fixes: fixes.clone(), |
287 | data: None, | 312 | }); |
288 | }; | ||
289 | 313 | ||
290 | let main_diagnostic = | 314 | // Emit hint-level diagnostics for all `related_information` entries such as "help"s. |
291 | MappedRustDiagnostic { url: location.uri, diagnostic, fixes: fixes.clone() }; | 315 | // This is useful because they will show up in the user's editor, unlike |
292 | match additional_diagnostic { | 316 | // `related_information`, which just produces hard-to-read links, at least in VS Code. |
293 | None => vec![main_diagnostic], | 317 | let back_ref = lsp_types::DiagnosticRelatedInformation { |
294 | Some(additional_diagnostic) => vec![main_diagnostic, additional_diagnostic], | 318 | location, |
319 | message: "original diagnostic".to_string(), | ||
320 | }; | ||
321 | for info in &related_information { | ||
322 | diagnostics.push(MappedRustDiagnostic { | ||
323 | url: info.location.uri.clone(), | ||
324 | fixes: fixes.clone(), // share fixes to make them easier to apply | ||
325 | diagnostic: lsp_types::Diagnostic { | ||
326 | range: info.location.range, | ||
327 | severity: Some(lsp_types::DiagnosticSeverity::Hint), | ||
328 | code: code.clone().map(lsp_types::NumberOrString::String), | ||
329 | code_description: code_description.clone(), | ||
330 | source: Some(source.clone()), | ||
331 | message: info.message.clone(), | ||
332 | related_information: Some(vec![back_ref.clone()]), | ||
333 | tags: None, // don't apply modifiers again | ||
334 | data: None, | ||
335 | }, | ||
336 | }); | ||
295 | } | 337 | } |
338 | |||
339 | diagnostics | ||
296 | }) | 340 | }) |
297 | .flatten() | ||
298 | .collect() | 341 | .collect() |
299 | } | 342 | } |
300 | 343 | ||
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index defe11c55..a27495d0d 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -75,7 +75,7 @@ pub(crate) struct GlobalState { | |||
75 | pub(crate) shutdown_requested: bool, | 75 | pub(crate) shutdown_requested: bool, |
76 | pub(crate) status: Status, | 76 | pub(crate) status: Status, |
77 | pub(crate) source_root_config: SourceRootConfig, | 77 | pub(crate) source_root_config: SourceRootConfig, |
78 | pub(crate) proc_macro_client: ProcMacroClient, | 78 | pub(crate) proc_macro_client: Option<ProcMacroClient>, |
79 | pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>, | 79 | pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>, |
80 | latest_requests: Arc<RwLock<LatestRequests>>, | 80 | latest_requests: Arc<RwLock<LatestRequests>>, |
81 | } | 81 | } |
@@ -127,7 +127,7 @@ impl GlobalState { | |||
127 | shutdown_requested: false, | 127 | shutdown_requested: false, |
128 | status: Status::default(), | 128 | status: Status::default(), |
129 | source_root_config: SourceRootConfig::default(), | 129 | source_root_config: SourceRootConfig::default(), |
130 | proc_macro_client: ProcMacroClient::dummy(), | 130 | proc_macro_client: None, |
131 | workspaces: Arc::new(Vec::new()), | 131 | workspaces: Arc::new(Vec::new()), |
132 | latest_requests: Default::default(), | 132 | latest_requests: Default::default(), |
133 | } | 133 | } |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index f349b0810..55d46b09e 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -506,7 +506,7 @@ impl GlobalState { | |||
506 | .write() | 506 | .write() |
507 | .0 | 507 | .0 |
508 | .set_file_contents(path, Some(params.text_document.text.into_bytes())); | 508 | .set_file_contents(path, Some(params.text_document.text.into_bytes())); |
509 | this.update_file_notifications_on_threadpool(); | 509 | this.maybe_update_diagnostics(); |
510 | } | 510 | } |
511 | Ok(()) | 511 | Ok(()) |
512 | })? | 512 | })? |
@@ -616,6 +616,23 @@ impl GlobalState { | |||
616 | Ok(()) | 616 | Ok(()) |
617 | } | 617 | } |
618 | fn update_file_notifications_on_threadpool(&mut self) { | 618 | fn update_file_notifications_on_threadpool(&mut self) { |
619 | self.maybe_update_diagnostics(); | ||
620 | self.task_pool.handle.spawn_with_sender({ | ||
621 | let snap = self.snapshot(); | ||
622 | move |sender| { | ||
623 | snap.analysis | ||
624 | .prime_caches(|progress| { | ||
625 | sender.send(Task::PrimeCaches(progress)).unwrap(); | ||
626 | }) | ||
627 | .unwrap_or_else(|_: Canceled| { | ||
628 | // Pretend that we're done, so that the progress bar is removed. Otherwise | ||
629 | // the editor may complain about it already existing. | ||
630 | sender.send(Task::PrimeCaches(PrimeCachesProgress::Finished)).unwrap() | ||
631 | }); | ||
632 | } | ||
633 | }); | ||
634 | } | ||
635 | fn maybe_update_diagnostics(&mut self) { | ||
619 | let subscriptions = self | 636 | let subscriptions = self |
620 | .mem_docs | 637 | .mem_docs |
621 | .keys() | 638 | .keys() |
@@ -644,19 +661,5 @@ impl GlobalState { | |||
644 | Task::Diagnostics(diagnostics) | 661 | Task::Diagnostics(diagnostics) |
645 | }) | 662 | }) |
646 | } | 663 | } |
647 | self.task_pool.handle.spawn_with_sender({ | ||
648 | let snap = self.snapshot(); | ||
649 | move |sender| { | ||
650 | snap.analysis | ||
651 | .prime_caches(|progress| { | ||
652 | sender.send(Task::PrimeCaches(progress)).unwrap(); | ||
653 | }) | ||
654 | .unwrap_or_else(|_: Canceled| { | ||
655 | // Pretend that we're done, so that the progress bar is removed. Otherwise | ||
656 | // the editor may complain about it already existing. | ||
657 | sender.send(Task::PrimeCaches(PrimeCachesProgress::Finished)).unwrap() | ||
658 | }); | ||
659 | } | ||
660 | }); | ||
661 | } | 664 | } |
662 | } | 665 | } |
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index b2d35f535..79e39e3a5 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -171,16 +171,16 @@ impl GlobalState { | |||
171 | let project_folders = ProjectFolders::new(&workspaces); | 171 | let project_folders = ProjectFolders::new(&workspaces); |
172 | 172 | ||
173 | self.proc_macro_client = match &self.config.proc_macro_srv { | 173 | self.proc_macro_client = match &self.config.proc_macro_srv { |
174 | None => ProcMacroClient::dummy(), | 174 | None => None, |
175 | Some((path, args)) => match ProcMacroClient::extern_process(path.into(), args) { | 175 | Some((path, args)) => match ProcMacroClient::extern_process(path.into(), args) { |
176 | Ok(it) => it, | 176 | Ok(it) => Some(it), |
177 | Err(err) => { | 177 | Err(err) => { |
178 | log::error!( | 178 | log::error!( |
179 | "Failed to run proc_macro_srv from path {}, error: {:?}", | 179 | "Failed to run proc_macro_srv from path {}, error: {:?}", |
180 | path.display(), | 180 | path.display(), |
181 | err | 181 | err |
182 | ); | 182 | ); |
183 | ProcMacroClient::dummy() | 183 | None |
184 | } | 184 | } |
185 | }, | 185 | }, |
186 | }; | 186 | }; |
@@ -212,7 +212,7 @@ impl GlobalState { | |||
212 | for ws in workspaces.iter() { | 212 | for ws in workspaces.iter() { |
213 | crate_graph.extend(ws.to_crate_graph( | 213 | crate_graph.extend(ws.to_crate_graph( |
214 | self.config.cargo.target.as_deref(), | 214 | self.config.cargo.target.as_deref(), |
215 | &self.proc_macro_client, | 215 | self.proc_macro_client.as_ref(), |
216 | &mut load, | 216 | &mut load, |
217 | )); | 217 | )); |
218 | } | 218 | } |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 2052b800c..01eabe852 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -381,6 +381,7 @@ fn semantic_token_type_and_modifiers( | |||
381 | HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, | 381 | HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, |
382 | HighlightTag::Generic => semantic_tokens::GENERIC, | 382 | HighlightTag::Generic => semantic_tokens::GENERIC, |
383 | HighlightTag::Module => lsp_types::SemanticTokenType::NAMESPACE, | 383 | HighlightTag::Module => lsp_types::SemanticTokenType::NAMESPACE, |
384 | HighlightTag::Method => lsp_types::SemanticTokenType::METHOD, | ||
384 | HighlightTag::Constant => { | 385 | HighlightTag::Constant => { |
385 | mods |= semantic_tokens::CONSTANT; | 386 | mods |= semantic_tokens::CONSTANT; |
386 | mods |= lsp_types::SemanticTokenModifier::STATIC; | 387 | mods |= lsp_types::SemanticTokenModifier::STATIC; |
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 876659a2b..cc09b77a5 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -171,8 +171,17 @@ pub fn expr_return() -> ast::Expr { | |||
171 | pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::Expr { | 171 | pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::Expr { |
172 | expr_from_text(&format!("match {} {}", expr, match_arm_list)) | 172 | expr_from_text(&format!("match {} {}", expr, match_arm_list)) |
173 | } | 173 | } |
174 | pub fn expr_if(condition: ast::Condition, then_branch: ast::BlockExpr) -> ast::Expr { | 174 | pub fn expr_if( |
175 | expr_from_text(&format!("if {} {}", condition, then_branch)) | 175 | condition: ast::Condition, |
176 | then_branch: ast::BlockExpr, | ||
177 | else_branch: Option<ast::ElseBranch>, | ||
178 | ) -> ast::Expr { | ||
179 | let else_branch = match else_branch { | ||
180 | Some(ast::ElseBranch::Block(block)) => format!("else {}", block), | ||
181 | Some(ast::ElseBranch::IfExpr(if_expr)) => format!("else {}", if_expr), | ||
182 | None => String::new(), | ||
183 | }; | ||
184 | expr_from_text(&format!("if {} {} {}", condition, then_branch, else_branch)) | ||
176 | } | 185 | } |
177 | pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { | 186 | pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { |
178 | let token = token(op); | 187 | let token = token(op); |
diff --git a/docs/dev/README.md b/docs/dev/README.md index abb387e8e..ca324493f 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -170,6 +170,22 @@ In general, API is centered around UI concerns -- the result of the call is what | |||
170 | The results are 100% Rust specific though. | 170 | The results are 100% Rust specific though. |
171 | Shout outs to LSP developers for popularizing the idea that "UI" is a good place to draw a boundary at. | 171 | Shout outs to LSP developers for popularizing the idea that "UI" is a good place to draw a boundary at. |
172 | 172 | ||
173 | ## LSP is sateless | ||
174 | |||
175 | The protocol is implemented in the mostly stateless way. | ||
176 | A good mental model is HTTP, which doesn't store per-client state, and instead relies on devices like cookies to maintain an illusion of state. | ||
177 | If some action requires multi-step protocol, each step should be self-contained. | ||
178 | |||
179 | A good example here is code action resolving process. | ||
180 | TO display the lightbulb, we compute the list of code actions without computing edits. | ||
181 | Figuring out the edit is done in a separate `codeAction/resolve` call. | ||
182 | Rather than storing some `lazy_edit: Box<dyn FnOnce() -> Edit>` somewhere, we use a string ID of action to re-compute the list of actions during the resolve process. | ||
183 | (See [this post](https://rust-analyzer.github.io/blog/2020/09/28/how-to-make-a-light-bulb.html) for more details.) | ||
184 | The benefit here is that, generally speaking, the state of the world might change between `codeAction` and `codeAction` resolve requests, so any closure we store might become invalid. | ||
185 | |||
186 | While we don't currently implement any complicated refactors with complex GUI, I imagine we'd use the same techniques for refactors. | ||
187 | After clicking each "Next" button during refactor, the client would send all the info which server needs to re-recreate the context from scratch. | ||
188 | |||
173 | ## CI | 189 | ## CI |
174 | 190 | ||
175 | CI does not test rust-analyzer, CI is a core part of rust-analyzer, and is maintained with above average standard of quality. | 191 | CI does not test rust-analyzer, CI is a core part of rust-analyzer, and is maintained with above average standard of quality. |
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index a60d3668b..e83b116a7 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -28,86 +28,113 @@ | |||
28 | "@babel/helper-validator-identifier": "^7.10.4", | 28 | "@babel/helper-validator-identifier": "^7.10.4", |
29 | "chalk": "^2.0.0", | 29 | "chalk": "^2.0.0", |
30 | "js-tokens": "^4.0.0" | 30 | "js-tokens": "^4.0.0" |
31 | }, | ||
32 | "dependencies": { | ||
33 | "chalk": { | ||
34 | "version": "2.4.2", | ||
35 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", | ||
36 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", | ||
37 | "dev": true, | ||
38 | "requires": { | ||
39 | "ansi-styles": "^3.2.1", | ||
40 | "escape-string-regexp": "^1.0.5", | ||
41 | "supports-color": "^5.3.0" | ||
42 | } | ||
43 | } | ||
31 | } | 44 | } |
32 | }, | 45 | }, |
33 | "@eslint/eslintrc": { | 46 | "@eslint/eslintrc": { |
34 | "version": "0.1.0", | 47 | "version": "0.2.2", |
35 | "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.0.tgz", | 48 | "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.2.tgz", |
36 | "integrity": "sha512-bfL5365QSCmH6cPeFT7Ywclj8C7LiF7sO6mUGzZhtAMV7iID1Euq6740u/SRi4C80NOnVz/CEfK8/HO+nCAPJg==", | 49 | "integrity": "sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ==", |
37 | "dev": true, | 50 | "dev": true, |
38 | "requires": { | 51 | "requires": { |
39 | "ajv": "^6.12.4", | 52 | "ajv": "^6.12.4", |
40 | "debug": "^4.1.1", | 53 | "debug": "^4.1.1", |
54 | "espree": "^7.3.0", | ||
55 | "globals": "^12.1.0", | ||
56 | "ignore": "^4.0.6", | ||
41 | "import-fresh": "^3.2.1", | 57 | "import-fresh": "^3.2.1", |
58 | "js-yaml": "^3.13.1", | ||
59 | "lodash": "^4.17.19", | ||
60 | "minimatch": "^3.0.4", | ||
42 | "strip-json-comments": "^3.1.1" | 61 | "strip-json-comments": "^3.1.1" |
43 | } | 62 | } |
44 | }, | 63 | }, |
64 | "@nodelib/fs.scandir": { | ||
65 | "version": "2.1.3", | ||
66 | "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", | ||
67 | "integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==", | ||
68 | "dev": true, | ||
69 | "requires": { | ||
70 | "@nodelib/fs.stat": "2.0.3", | ||
71 | "run-parallel": "^1.1.9" | ||
72 | } | ||
73 | }, | ||
74 | "@nodelib/fs.stat": { | ||
75 | "version": "2.0.3", | ||
76 | "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz", | ||
77 | "integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==", | ||
78 | "dev": true | ||
79 | }, | ||
80 | "@nodelib/fs.walk": { | ||
81 | "version": "1.2.4", | ||
82 | "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz", | ||
83 | "integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==", | ||
84 | "dev": true, | ||
85 | "requires": { | ||
86 | "@nodelib/fs.scandir": "2.1.3", | ||
87 | "fastq": "^1.6.0" | ||
88 | } | ||
89 | }, | ||
45 | "@rollup/plugin-commonjs": { | 90 | "@rollup/plugin-commonjs": { |
46 | "version": "13.0.2", | 91 | "version": "17.0.0", |
47 | "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-13.0.2.tgz", | 92 | "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.0.0.tgz", |
48 | "integrity": "sha512-9JXf2k8xqvMYfqmhgtB6eCgMN9fbxwF1XDF3mGKJc6pkAmt0jnsqurxQ0tC1akQKNSXCm7c3unQxa3zuxtZ7mQ==", | 93 | "integrity": "sha512-/omBIJG1nHQc+bgkYDuLpb/V08QyutP9amOrJRUSlYJZP+b/68gM//D8sxJe3Yry2QnYIr3QjR3x4AlxJEN3GA==", |
49 | "dev": true, | 94 | "dev": true, |
50 | "requires": { | 95 | "requires": { |
51 | "@rollup/pluginutils": "^3.0.8", | 96 | "@rollup/pluginutils": "^3.1.0", |
52 | "commondir": "^1.0.1", | 97 | "commondir": "^1.0.1", |
53 | "estree-walker": "^1.0.1", | 98 | "estree-walker": "^2.0.1", |
54 | "glob": "^7.1.2", | 99 | "glob": "^7.1.6", |
55 | "is-reference": "^1.1.2", | 100 | "is-reference": "^1.2.1", |
56 | "magic-string": "^0.25.2", | 101 | "magic-string": "^0.25.7", |
57 | "resolve": "^1.11.0" | 102 | "resolve": "^1.17.0" |
58 | } | 103 | } |
59 | }, | 104 | }, |
60 | "@rollup/plugin-node-resolve": { | 105 | "@rollup/plugin-node-resolve": { |
61 | "version": "8.4.0", | 106 | "version": "11.0.0", |
62 | "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-8.4.0.tgz", | 107 | "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.0.0.tgz", |
63 | "integrity": "sha512-LFqKdRLn0ShtQyf6SBYO69bGE1upV6wUhBX0vFOUnLAyzx5cwp8svA0eHUnu8+YU57XOkrMtfG63QOpQx25pHQ==", | 108 | "integrity": "sha512-8Hrmwjn1pLYjUxcv7U7IPP0qfnzEJWHyHE6CaZ8jbLM+8axaarJRB1jB6JgKTDp5gNga+TpsgX6F8iuvgOerKQ==", |
64 | "dev": true, | 109 | "dev": true, |
65 | "requires": { | 110 | "requires": { |
66 | "@rollup/pluginutils": "^3.1.0", | 111 | "@rollup/pluginutils": "^3.1.0", |
67 | "@types/resolve": "1.17.1", | 112 | "@types/resolve": "1.17.1", |
68 | "builtin-modules": "^3.1.0", | 113 | "builtin-modules": "^3.1.0", |
69 | "deep-freeze": "^0.0.1", | ||
70 | "deepmerge": "^4.2.2", | 114 | "deepmerge": "^4.2.2", |
71 | "is-module": "^1.0.0", | 115 | "is-module": "^1.0.0", |
72 | "resolve": "^1.17.0" | 116 | "resolve": "^1.19.0" |
73 | }, | ||
74 | "dependencies": { | ||
75 | "@rollup/pluginutils": { | ||
76 | "version": "3.1.0", | ||
77 | "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", | ||
78 | "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", | ||
79 | "dev": true, | ||
80 | "requires": { | ||
81 | "@types/estree": "0.0.39", | ||
82 | "estree-walker": "^1.0.1", | ||
83 | "picomatch": "^2.2.2" | ||
84 | } | ||
85 | } | ||
86 | } | 117 | } |
87 | }, | 118 | }, |
88 | "@rollup/pluginutils": { | 119 | "@rollup/pluginutils": { |
89 | "version": "3.0.10", | 120 | "version": "3.1.0", |
90 | "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.10.tgz", | 121 | "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", |
91 | "integrity": "sha512-d44M7t+PjmMrASHbhgpSbVgtL6EFyX7J4mYxwQ/c5eoaE6N2VgCgEcWVzNnwycIloti+/MpwFr8qfw+nRw00sw==", | 122 | "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", |
92 | "dev": true, | 123 | "dev": true, |
93 | "requires": { | 124 | "requires": { |
94 | "@types/estree": "0.0.39", | 125 | "@types/estree": "0.0.39", |
95 | "estree-walker": "^1.0.1", | 126 | "estree-walker": "^1.0.1", |
96 | "picomatch": "^2.2.2" | 127 | "picomatch": "^2.2.2" |
128 | }, | ||
129 | "dependencies": { | ||
130 | "estree-walker": { | ||
131 | "version": "1.0.1", | ||
132 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", | ||
133 | "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", | ||
134 | "dev": true | ||
135 | } | ||
97 | } | 136 | } |
98 | }, | 137 | }, |
99 | "@types/color-name": { | ||
100 | "version": "1.1.1", | ||
101 | "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", | ||
102 | "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", | ||
103 | "dev": true | ||
104 | }, | ||
105 | "@types/eslint-visitor-keys": { | ||
106 | "version": "1.0.0", | ||
107 | "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", | ||
108 | "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", | ||
109 | "dev": true | ||
110 | }, | ||
111 | "@types/estree": { | 138 | "@types/estree": { |
112 | "version": "0.0.39", | 139 | "version": "0.0.39", |
113 | "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", | 140 | "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", |
@@ -137,15 +164,15 @@ | |||
137 | "dev": true | 164 | "dev": true |
138 | }, | 165 | }, |
139 | "@types/mocha": { | 166 | "@types/mocha": { |
140 | "version": "7.0.2", | 167 | "version": "8.0.4", |
141 | "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-7.0.2.tgz", | 168 | "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.4.tgz", |
142 | "integrity": "sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==", | 169 | "integrity": "sha512-M4BwiTJjHmLq6kjON7ZoI2JMlBvpY3BYSdiP6s/qCT3jb1s9/DeJF0JELpAxiVSIxXDzfNKe+r7yedMIoLbknQ==", |
143 | "dev": true | 170 | "dev": true |
144 | }, | 171 | }, |
145 | "@types/node": { | 172 | "@types/node": { |
146 | "version": "12.7.12", | 173 | "version": "12.12.70", |
147 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", | 174 | "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.70.tgz", |
148 | "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==", | 175 | "integrity": "sha512-i5y7HTbvhonZQE+GnUM2rz1Bi8QkzxdQmEv1LKOv4nWyaQk/gdeiTApuQR3PDJHX7WomAbpx2wlWSEpxXGZ/UQ==", |
149 | "dev": true | 176 | "dev": true |
150 | }, | 177 | }, |
151 | "@types/node-fetch": { | 178 | "@types/node-fetch": { |
@@ -168,18 +195,19 @@ | |||
168 | } | 195 | } |
169 | }, | 196 | }, |
170 | "@types/vscode": { | 197 | "@types/vscode": { |
171 | "version": "1.48.0", | 198 | "version": "1.51.0", |
172 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.48.0.tgz", | 199 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.51.0.tgz", |
173 | "integrity": "sha512-sZJKzsJz1gSoFXcOJWw3fnKl2sseUgZmvB4AJZS+Fea+bC/jfGPVhmFL/FfQHld/TKtukVONsmoD3Pkyx9iadg==", | 200 | "integrity": "sha512-C/jZ35OT5k/rsJyAK8mS1kM++vMcm89oSWegkzxRCvHllIq0cToZAkIDs6eCY4SKrvik3nrhELizyLcM0onbQA==", |
174 | "dev": true | 201 | "dev": true |
175 | }, | 202 | }, |
176 | "@typescript-eslint/eslint-plugin": { | 203 | "@typescript-eslint/eslint-plugin": { |
177 | "version": "3.10.1", | 204 | "version": "4.9.0", |
178 | "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz", | 205 | "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.9.0.tgz", |
179 | "integrity": "sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==", | 206 | "integrity": "sha512-WrVzGMzzCrgrpnQMQm4Tnf+dk+wdl/YbgIgd5hKGa2P+lnJ2MON+nQnbwgbxtN9QDLi8HO+JAq0/krMnjQK6Cw==", |
180 | "dev": true, | 207 | "dev": true, |
181 | "requires": { | 208 | "requires": { |
182 | "@typescript-eslint/experimental-utils": "3.10.1", | 209 | "@typescript-eslint/experimental-utils": "4.9.0", |
210 | "@typescript-eslint/scope-manager": "4.9.0", | ||
183 | "debug": "^4.1.1", | 211 | "debug": "^4.1.1", |
184 | "functional-red-black-tree": "^1.0.1", | 212 | "functional-red-black-tree": "^1.0.1", |
185 | "regexpp": "^3.0.0", | 213 | "regexpp": "^3.0.0", |
@@ -187,89 +215,150 @@ | |||
187 | "tsutils": "^3.17.1" | 215 | "tsutils": "^3.17.1" |
188 | }, | 216 | }, |
189 | "dependencies": { | 217 | "dependencies": { |
218 | "lru-cache": { | ||
219 | "version": "6.0.0", | ||
220 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", | ||
221 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", | ||
222 | "dev": true, | ||
223 | "requires": { | ||
224 | "yallist": "^4.0.0" | ||
225 | } | ||
226 | }, | ||
190 | "semver": { | 227 | "semver": { |
191 | "version": "7.3.2", | 228 | "version": "7.3.4", |
192 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", | 229 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", |
193 | "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", | 230 | "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", |
231 | "dev": true, | ||
232 | "requires": { | ||
233 | "lru-cache": "^6.0.0" | ||
234 | } | ||
235 | }, | ||
236 | "yallist": { | ||
237 | "version": "4.0.0", | ||
238 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", | ||
239 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", | ||
194 | "dev": true | 240 | "dev": true |
195 | } | 241 | } |
196 | } | 242 | } |
197 | }, | 243 | }, |
198 | "@typescript-eslint/experimental-utils": { | 244 | "@typescript-eslint/experimental-utils": { |
199 | "version": "3.10.1", | 245 | "version": "4.9.0", |
200 | "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz", | 246 | "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.9.0.tgz", |
201 | "integrity": "sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==", | 247 | "integrity": "sha512-0p8GnDWB3R2oGhmRXlEnCvYOtaBCijtA5uBfH5GxQKsukdSQyI4opC4NGTUb88CagsoNQ4rb/hId2JuMbzWKFQ==", |
202 | "dev": true, | 248 | "dev": true, |
203 | "requires": { | 249 | "requires": { |
204 | "@types/json-schema": "^7.0.3", | 250 | "@types/json-schema": "^7.0.3", |
205 | "@typescript-eslint/types": "3.10.1", | 251 | "@typescript-eslint/scope-manager": "4.9.0", |
206 | "@typescript-eslint/typescript-estree": "3.10.1", | 252 | "@typescript-eslint/types": "4.9.0", |
253 | "@typescript-eslint/typescript-estree": "4.9.0", | ||
207 | "eslint-scope": "^5.0.0", | 254 | "eslint-scope": "^5.0.0", |
208 | "eslint-utils": "^2.0.0" | 255 | "eslint-utils": "^2.0.0" |
209 | } | 256 | } |
210 | }, | 257 | }, |
211 | "@typescript-eslint/parser": { | 258 | "@typescript-eslint/parser": { |
212 | "version": "3.10.1", | 259 | "version": "4.9.0", |
213 | "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.10.1.tgz", | 260 | "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.9.0.tgz", |
214 | "integrity": "sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==", | 261 | "integrity": "sha512-QRSDAV8tGZoQye/ogp28ypb8qpsZPV6FOLD+tbN4ohKUWHD2n/u0Q2tIBnCsGwQCiD94RdtLkcqpdK4vKcLCCw==", |
215 | "dev": true, | 262 | "dev": true, |
216 | "requires": { | 263 | "requires": { |
217 | "@types/eslint-visitor-keys": "^1.0.0", | 264 | "@typescript-eslint/scope-manager": "4.9.0", |
218 | "@typescript-eslint/experimental-utils": "3.10.1", | 265 | "@typescript-eslint/types": "4.9.0", |
219 | "@typescript-eslint/types": "3.10.1", | 266 | "@typescript-eslint/typescript-estree": "4.9.0", |
220 | "@typescript-eslint/typescript-estree": "3.10.1", | 267 | "debug": "^4.1.1" |
221 | "eslint-visitor-keys": "^1.1.0" | 268 | } |
269 | }, | ||
270 | "@typescript-eslint/scope-manager": { | ||
271 | "version": "4.9.0", | ||
272 | "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.9.0.tgz", | ||
273 | "integrity": "sha512-q/81jtmcDtMRE+nfFt5pWqO0R41k46gpVLnuefqVOXl4QV1GdQoBWfk5REcipoJNQH9+F5l+dwa9Li5fbALjzg==", | ||
274 | "dev": true, | ||
275 | "requires": { | ||
276 | "@typescript-eslint/types": "4.9.0", | ||
277 | "@typescript-eslint/visitor-keys": "4.9.0" | ||
222 | } | 278 | } |
223 | }, | 279 | }, |
224 | "@typescript-eslint/types": { | 280 | "@typescript-eslint/types": { |
225 | "version": "3.10.1", | 281 | "version": "4.9.0", |
226 | "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz", | 282 | "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.9.0.tgz", |
227 | "integrity": "sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==", | 283 | "integrity": "sha512-luzLKmowfiM/IoJL/rus1K9iZpSJK6GlOS/1ezKplb7MkORt2dDcfi8g9B0bsF6JoRGhqn0D3Va55b+vredFHA==", |
228 | "dev": true | 284 | "dev": true |
229 | }, | 285 | }, |
230 | "@typescript-eslint/typescript-estree": { | 286 | "@typescript-eslint/typescript-estree": { |
231 | "version": "3.10.1", | 287 | "version": "4.9.0", |
232 | "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz", | 288 | "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.9.0.tgz", |
233 | "integrity": "sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==", | 289 | "integrity": "sha512-rmDR++PGrIyQzAtt3pPcmKWLr7MA+u/Cmq9b/rON3//t5WofNR4m/Ybft2vOLj0WtUzjn018ekHjTsnIyBsQug==", |
234 | "dev": true, | 290 | "dev": true, |
235 | "requires": { | 291 | "requires": { |
236 | "@typescript-eslint/types": "3.10.1", | 292 | "@typescript-eslint/types": "4.9.0", |
237 | "@typescript-eslint/visitor-keys": "3.10.1", | 293 | "@typescript-eslint/visitor-keys": "4.9.0", |
238 | "debug": "^4.1.1", | 294 | "debug": "^4.1.1", |
239 | "glob": "^7.1.6", | 295 | "globby": "^11.0.1", |
240 | "is-glob": "^4.0.1", | 296 | "is-glob": "^4.0.1", |
241 | "lodash": "^4.17.15", | 297 | "lodash": "^4.17.15", |
242 | "semver": "^7.3.2", | 298 | "semver": "^7.3.2", |
243 | "tsutils": "^3.17.1" | 299 | "tsutils": "^3.17.1" |
244 | }, | 300 | }, |
245 | "dependencies": { | 301 | "dependencies": { |
302 | "lru-cache": { | ||
303 | "version": "6.0.0", | ||
304 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", | ||
305 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", | ||
306 | "dev": true, | ||
307 | "requires": { | ||
308 | "yallist": "^4.0.0" | ||
309 | } | ||
310 | }, | ||
246 | "semver": { | 311 | "semver": { |
247 | "version": "7.3.2", | 312 | "version": "7.3.4", |
248 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", | 313 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", |
249 | "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", | 314 | "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", |
315 | "dev": true, | ||
316 | "requires": { | ||
317 | "lru-cache": "^6.0.0" | ||
318 | } | ||
319 | }, | ||
320 | "yallist": { | ||
321 | "version": "4.0.0", | ||
322 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", | ||
323 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", | ||
250 | "dev": true | 324 | "dev": true |
251 | } | 325 | } |
252 | } | 326 | } |
253 | }, | 327 | }, |
254 | "@typescript-eslint/visitor-keys": { | 328 | "@typescript-eslint/visitor-keys": { |
255 | "version": "3.10.1", | 329 | "version": "4.9.0", |
256 | "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz", | 330 | "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.9.0.tgz", |
257 | "integrity": "sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==", | 331 | "integrity": "sha512-sV45zfdRqQo1A97pOSx3fsjR+3blmwtdCt8LDrXgCX36v4Vmz4KHrhpV6Fo2cRdXmyumxx11AHw0pNJqCNpDyg==", |
258 | "dev": true, | 332 | "dev": true, |
259 | "requires": { | 333 | "requires": { |
260 | "eslint-visitor-keys": "^1.1.0" | 334 | "@typescript-eslint/types": "4.9.0", |
335 | "eslint-visitor-keys": "^2.0.0" | ||
336 | }, | ||
337 | "dependencies": { | ||
338 | "eslint-visitor-keys": { | ||
339 | "version": "2.0.0", | ||
340 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", | ||
341 | "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", | ||
342 | "dev": true | ||
343 | } | ||
261 | } | 344 | } |
262 | }, | 345 | }, |
346 | "@ungap/promise-all-settled": { | ||
347 | "version": "1.1.2", | ||
348 | "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", | ||
349 | "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", | ||
350 | "dev": true | ||
351 | }, | ||
263 | "acorn": { | 352 | "acorn": { |
264 | "version": "7.4.0", | 353 | "version": "7.4.1", |
265 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", | 354 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", |
266 | "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", | 355 | "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", |
267 | "dev": true | 356 | "dev": true |
268 | }, | 357 | }, |
269 | "acorn-jsx": { | 358 | "acorn-jsx": { |
270 | "version": "5.2.0", | 359 | "version": "5.3.1", |
271 | "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", | 360 | "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", |
272 | "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", | 361 | "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", |
273 | "dev": true | 362 | "dev": true |
274 | }, | 363 | }, |
275 | "agent-base": { | 364 | "agent-base": { |
@@ -282,9 +371,9 @@ | |||
282 | } | 371 | } |
283 | }, | 372 | }, |
284 | "ajv": { | 373 | "ajv": { |
285 | "version": "6.12.4", | 374 | "version": "6.12.6", |
286 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", | 375 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", |
287 | "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", | 376 | "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", |
288 | "dev": true, | 377 | "dev": true, |
289 | "requires": { | 378 | "requires": { |
290 | "fast-deep-equal": "^3.1.1", | 379 | "fast-deep-equal": "^3.1.1", |
@@ -333,17 +422,11 @@ | |||
333 | "sprintf-js": "~1.0.2" | 422 | "sprintf-js": "~1.0.2" |
334 | } | 423 | } |
335 | }, | 424 | }, |
336 | "array.prototype.map": { | 425 | "array-union": { |
337 | "version": "1.0.2", | 426 | "version": "2.1.0", |
338 | "resolved": "https://registry.npmjs.org/array.prototype.map/-/array.prototype.map-1.0.2.tgz", | 427 | "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", |
339 | "integrity": "sha512-Az3OYxgsa1g7xDYp86l0nnN4bcmuEITGe1rbdEBVkrqkzMgDcbdQ2R7r41pNzti+4NMces3H8gMmuioZUilLgw==", | 428 | "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", |
340 | "dev": true, | 429 | "dev": true |
341 | "requires": { | ||
342 | "define-properties": "^1.1.3", | ||
343 | "es-abstract": "^1.17.0-next.1", | ||
344 | "es-array-method-boxes-properly": "^1.0.0", | ||
345 | "is-string": "^1.0.4" | ||
346 | } | ||
347 | }, | 430 | }, |
348 | "astral-regex": { | 431 | "astral-regex": { |
349 | "version": "1.0.0", | 432 | "version": "1.0.0", |
@@ -437,14 +520,54 @@ | |||
437 | "dev": true | 520 | "dev": true |
438 | }, | 521 | }, |
439 | "chalk": { | 522 | "chalk": { |
440 | "version": "2.4.2", | 523 | "version": "4.1.0", |
441 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", | 524 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", |
442 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", | 525 | "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", |
443 | "dev": true, | 526 | "dev": true, |
444 | "requires": { | 527 | "requires": { |
445 | "ansi-styles": "^3.2.1", | 528 | "ansi-styles": "^4.1.0", |
446 | "escape-string-regexp": "^1.0.5", | 529 | "supports-color": "^7.1.0" |
447 | "supports-color": "^5.3.0" | 530 | }, |
531 | "dependencies": { | ||
532 | "ansi-styles": { | ||
533 | "version": "4.3.0", | ||
534 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", | ||
535 | "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", | ||
536 | "dev": true, | ||
537 | "requires": { | ||
538 | "color-convert": "^2.0.1" | ||
539 | } | ||
540 | }, | ||
541 | "color-convert": { | ||
542 | "version": "2.0.1", | ||
543 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", | ||
544 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", | ||
545 | "dev": true, | ||
546 | "requires": { | ||
547 | "color-name": "~1.1.4" | ||
548 | } | ||
549 | }, | ||
550 | "color-name": { | ||
551 | "version": "1.1.4", | ||
552 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", | ||
553 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", | ||
554 | "dev": true | ||
555 | }, | ||
556 | "has-flag": { | ||
557 | "version": "4.0.0", | ||
558 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", | ||
559 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | ||
560 | "dev": true | ||
561 | }, | ||
562 | "supports-color": { | ||
563 | "version": "7.2.0", | ||
564 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", | ||
565 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", | ||
566 | "dev": true, | ||
567 | "requires": { | ||
568 | "has-flag": "^4.0.0" | ||
569 | } | ||
570 | } | ||
448 | } | 571 | } |
449 | }, | 572 | }, |
450 | "cheerio": { | 573 | "cheerio": { |
@@ -462,9 +585,9 @@ | |||
462 | } | 585 | } |
463 | }, | 586 | }, |
464 | "chokidar": { | 587 | "chokidar": { |
465 | "version": "3.4.2", | 588 | "version": "3.4.3", |
466 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.2.tgz", | 589 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz", |
467 | "integrity": "sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A==", | 590 | "integrity": "sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ==", |
468 | "dev": true, | 591 | "dev": true, |
469 | "requires": { | 592 | "requires": { |
470 | "anymatch": "~3.1.1", | 593 | "anymatch": "~3.1.1", |
@@ -474,7 +597,7 @@ | |||
474 | "is-binary-path": "~2.1.0", | 597 | "is-binary-path": "~2.1.0", |
475 | "is-glob": "~4.0.1", | 598 | "is-glob": "~4.0.1", |
476 | "normalize-path": "~3.0.0", | 599 | "normalize-path": "~3.0.0", |
477 | "readdirp": "~3.4.0" | 600 | "readdirp": "~3.5.0" |
478 | } | 601 | } |
479 | }, | 602 | }, |
480 | "cliui": { | 603 | "cliui": { |
@@ -597,12 +720,6 @@ | |||
597 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", | 720 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", |
598 | "dev": true | 721 | "dev": true |
599 | }, | 722 | }, |
600 | "deep-freeze": { | ||
601 | "version": "0.0.1", | ||
602 | "resolved": "https://registry.npmjs.org/deep-freeze/-/deep-freeze-0.0.1.tgz", | ||
603 | "integrity": "sha1-OgsABd4YZygZ39OM0x+RF5yJPoQ=", | ||
604 | "dev": true | ||
605 | }, | ||
606 | "deep-is": { | 723 | "deep-is": { |
607 | "version": "0.1.3", | 724 | "version": "0.1.3", |
608 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", | 725 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", |
@@ -615,15 +732,6 @@ | |||
615 | "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", | 732 | "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", |
616 | "dev": true | 733 | "dev": true |
617 | }, | 734 | }, |
618 | "define-properties": { | ||
619 | "version": "1.1.3", | ||
620 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", | ||
621 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", | ||
622 | "dev": true, | ||
623 | "requires": { | ||
624 | "object-keys": "^1.0.12" | ||
625 | } | ||
626 | }, | ||
627 | "delayed-stream": { | 735 | "delayed-stream": { |
628 | "version": "1.0.0", | 736 | "version": "1.0.0", |
629 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", | 737 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", |
@@ -642,6 +750,15 @@ | |||
642 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", | 750 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", |
643 | "dev": true | 751 | "dev": true |
644 | }, | 752 | }, |
753 | "dir-glob": { | ||
754 | "version": "3.0.1", | ||
755 | "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", | ||
756 | "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", | ||
757 | "dev": true, | ||
758 | "requires": { | ||
759 | "path-type": "^4.0.0" | ||
760 | } | ||
761 | }, | ||
645 | "doctrine": { | 762 | "doctrine": { |
646 | "version": "3.0.0", | 763 | "version": "3.0.0", |
647 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", | 764 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", |
@@ -727,57 +844,6 @@ | |||
727 | "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", | 844 | "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", |
728 | "dev": true | 845 | "dev": true |
729 | }, | 846 | }, |
730 | "es-abstract": { | ||
731 | "version": "1.17.6", | ||
732 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", | ||
733 | "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", | ||
734 | "dev": true, | ||
735 | "requires": { | ||
736 | "es-to-primitive": "^1.2.1", | ||
737 | "function-bind": "^1.1.1", | ||
738 | "has": "^1.0.3", | ||
739 | "has-symbols": "^1.0.1", | ||
740 | "is-callable": "^1.2.0", | ||
741 | "is-regex": "^1.1.0", | ||
742 | "object-inspect": "^1.7.0", | ||
743 | "object-keys": "^1.1.1", | ||
744 | "object.assign": "^4.1.0", | ||
745 | "string.prototype.trimend": "^1.0.1", | ||
746 | "string.prototype.trimstart": "^1.0.1" | ||
747 | } | ||
748 | }, | ||
749 | "es-array-method-boxes-properly": { | ||
750 | "version": "1.0.0", | ||
751 | "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", | ||
752 | "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==", | ||
753 | "dev": true | ||
754 | }, | ||
755 | "es-get-iterator": { | ||
756 | "version": "1.1.0", | ||
757 | "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.0.tgz", | ||
758 | "integrity": "sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==", | ||
759 | "dev": true, | ||
760 | "requires": { | ||
761 | "es-abstract": "^1.17.4", | ||
762 | "has-symbols": "^1.0.1", | ||
763 | "is-arguments": "^1.0.4", | ||
764 | "is-map": "^2.0.1", | ||
765 | "is-set": "^2.0.1", | ||
766 | "is-string": "^1.0.5", | ||
767 | "isarray": "^2.0.5" | ||
768 | } | ||
769 | }, | ||
770 | "es-to-primitive": { | ||
771 | "version": "1.2.1", | ||
772 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", | ||
773 | "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", | ||
774 | "dev": true, | ||
775 | "requires": { | ||
776 | "is-callable": "^1.1.4", | ||
777 | "is-date-object": "^1.0.1", | ||
778 | "is-symbol": "^1.0.2" | ||
779 | } | ||
780 | }, | ||
781 | "es6-promise": { | 847 | "es6-promise": { |
782 | "version": "4.2.8", | 848 | "version": "4.2.8", |
783 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", | 849 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", |
@@ -800,26 +866,26 @@ | |||
800 | "dev": true | 866 | "dev": true |
801 | }, | 867 | }, |
802 | "eslint": { | 868 | "eslint": { |
803 | "version": "7.8.0", | 869 | "version": "7.15.0", |
804 | "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.0.tgz", | 870 | "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.15.0.tgz", |
805 | "integrity": "sha512-qgtVyLZqKd2ZXWnLQA4NtVbOyH56zivOAdBFWE54RFkSZjokzNrcP4Z0eVWsZ+84ByXv+jL9k/wE1ENYe8xRFw==", | 871 | "integrity": "sha512-Vr64xFDT8w30wFll643e7cGrIkPEU50yIiI36OdSIDoSGguIeaLzBo0vpGvzo9RECUqq7htURfwEtKqwytkqzA==", |
806 | "dev": true, | 872 | "dev": true, |
807 | "requires": { | 873 | "requires": { |
808 | "@babel/code-frame": "^7.0.0", | 874 | "@babel/code-frame": "^7.0.0", |
809 | "@eslint/eslintrc": "^0.1.0", | 875 | "@eslint/eslintrc": "^0.2.2", |
810 | "ajv": "^6.10.0", | 876 | "ajv": "^6.10.0", |
811 | "chalk": "^4.0.0", | 877 | "chalk": "^4.0.0", |
812 | "cross-spawn": "^7.0.2", | 878 | "cross-spawn": "^7.0.2", |
813 | "debug": "^4.0.1", | 879 | "debug": "^4.0.1", |
814 | "doctrine": "^3.0.0", | 880 | "doctrine": "^3.0.0", |
815 | "enquirer": "^2.3.5", | 881 | "enquirer": "^2.3.5", |
816 | "eslint-scope": "^5.1.0", | 882 | "eslint-scope": "^5.1.1", |
817 | "eslint-utils": "^2.1.0", | 883 | "eslint-utils": "^2.1.0", |
818 | "eslint-visitor-keys": "^1.3.0", | 884 | "eslint-visitor-keys": "^2.0.0", |
819 | "espree": "^7.3.0", | 885 | "espree": "^7.3.1", |
820 | "esquery": "^1.2.0", | 886 | "esquery": "^1.2.0", |
821 | "esutils": "^2.0.2", | 887 | "esutils": "^2.0.2", |
822 | "file-entry-cache": "^5.0.1", | 888 | "file-entry-cache": "^6.0.0", |
823 | "functional-red-black-tree": "^1.0.1", | 889 | "functional-red-black-tree": "^1.0.1", |
824 | "glob-parent": "^5.0.0", | 890 | "glob-parent": "^5.0.0", |
825 | "globals": "^12.1.0", | 891 | "globals": "^12.1.0", |
@@ -844,96 +910,72 @@ | |||
844 | "v8-compile-cache": "^2.0.3" | 910 | "v8-compile-cache": "^2.0.3" |
845 | }, | 911 | }, |
846 | "dependencies": { | 912 | "dependencies": { |
847 | "ansi-styles": { | 913 | "eslint-scope": { |
848 | "version": "4.2.1", | 914 | "version": "5.1.1", |
849 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", | 915 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", |
850 | "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", | 916 | "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", |
851 | "dev": true, | 917 | "dev": true, |
852 | "requires": { | 918 | "requires": { |
853 | "@types/color-name": "^1.1.1", | 919 | "esrecurse": "^4.3.0", |
854 | "color-convert": "^2.0.1" | 920 | "estraverse": "^4.1.1" |
855 | } | 921 | } |
856 | }, | 922 | }, |
857 | "chalk": { | 923 | "eslint-visitor-keys": { |
858 | "version": "4.1.0", | 924 | "version": "2.0.0", |
859 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", | 925 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", |
860 | "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", | 926 | "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", |
861 | "dev": true, | 927 | "dev": true |
862 | "requires": { | ||
863 | "ansi-styles": "^4.1.0", | ||
864 | "supports-color": "^7.1.0" | ||
865 | } | ||
866 | }, | 928 | }, |
867 | "color-convert": { | 929 | "esrecurse": { |
868 | "version": "2.0.1", | 930 | "version": "4.3.0", |
869 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", | 931 | "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", |
870 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", | 932 | "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", |
871 | "dev": true, | 933 | "dev": true, |
872 | "requires": { | 934 | "requires": { |
873 | "color-name": "~1.1.4" | 935 | "estraverse": "^5.2.0" |
936 | }, | ||
937 | "dependencies": { | ||
938 | "estraverse": { | ||
939 | "version": "5.2.0", | ||
940 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", | ||
941 | "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", | ||
942 | "dev": true | ||
943 | } | ||
874 | } | 944 | } |
875 | }, | 945 | }, |
876 | "color-name": { | 946 | "lru-cache": { |
877 | "version": "1.1.4", | 947 | "version": "6.0.0", |
878 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", | 948 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", |
879 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", | 949 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", |
880 | "dev": true | ||
881 | }, | ||
882 | "eslint-scope": { | ||
883 | "version": "5.1.0", | ||
884 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", | ||
885 | "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", | ||
886 | "dev": true, | 950 | "dev": true, |
887 | "requires": { | 951 | "requires": { |
888 | "esrecurse": "^4.1.0", | 952 | "yallist": "^4.0.0" |
889 | "estraverse": "^4.1.1" | ||
890 | } | 953 | } |
891 | }, | 954 | }, |
892 | "eslint-utils": { | 955 | "semver": { |
893 | "version": "2.1.0", | 956 | "version": "7.3.4", |
894 | "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", | 957 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", |
895 | "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", | 958 | "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", |
896 | "dev": true, | 959 | "dev": true, |
897 | "requires": { | 960 | "requires": { |
898 | "eslint-visitor-keys": "^1.1.0" | 961 | "lru-cache": "^6.0.0" |
899 | } | 962 | } |
900 | }, | 963 | }, |
901 | "eslint-visitor-keys": { | 964 | "yallist": { |
902 | "version": "1.3.0", | ||
903 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", | ||
904 | "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", | ||
905 | "dev": true | ||
906 | }, | ||
907 | "has-flag": { | ||
908 | "version": "4.0.0", | 965 | "version": "4.0.0", |
909 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", | 966 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", |
910 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | 967 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", |
911 | "dev": true | ||
912 | }, | ||
913 | "semver": { | ||
914 | "version": "7.3.2", | ||
915 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", | ||
916 | "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", | ||
917 | "dev": true | 968 | "dev": true |
918 | }, | ||
919 | "supports-color": { | ||
920 | "version": "7.2.0", | ||
921 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", | ||
922 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", | ||
923 | "dev": true, | ||
924 | "requires": { | ||
925 | "has-flag": "^4.0.0" | ||
926 | } | ||
927 | } | 969 | } |
928 | } | 970 | } |
929 | }, | 971 | }, |
930 | "eslint-scope": { | 972 | "eslint-scope": { |
931 | "version": "5.1.0", | 973 | "version": "5.1.1", |
932 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", | 974 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", |
933 | "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", | 975 | "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", |
934 | "dev": true, | 976 | "dev": true, |
935 | "requires": { | 977 | "requires": { |
936 | "esrecurse": "^4.1.0", | 978 | "esrecurse": "^4.3.0", |
937 | "estraverse": "^4.1.1" | 979 | "estraverse": "^4.1.1" |
938 | } | 980 | } |
939 | }, | 981 | }, |
@@ -953,22 +995,14 @@ | |||
953 | "dev": true | 995 | "dev": true |
954 | }, | 996 | }, |
955 | "espree": { | 997 | "espree": { |
956 | "version": "7.3.0", | 998 | "version": "7.3.1", |
957 | "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz", | 999 | "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", |
958 | "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==", | 1000 | "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", |
959 | "dev": true, | 1001 | "dev": true, |
960 | "requires": { | 1002 | "requires": { |
961 | "acorn": "^7.4.0", | 1003 | "acorn": "^7.4.0", |
962 | "acorn-jsx": "^5.2.0", | 1004 | "acorn-jsx": "^5.3.1", |
963 | "eslint-visitor-keys": "^1.3.0" | 1005 | "eslint-visitor-keys": "^1.3.0" |
964 | }, | ||
965 | "dependencies": { | ||
966 | "eslint-visitor-keys": { | ||
967 | "version": "1.3.0", | ||
968 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", | ||
969 | "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", | ||
970 | "dev": true | ||
971 | } | ||
972 | } | 1006 | } |
973 | }, | 1007 | }, |
974 | "esprima": { | 1008 | "esprima": { |
@@ -995,12 +1029,20 @@ | |||
995 | } | 1029 | } |
996 | }, | 1030 | }, |
997 | "esrecurse": { | 1031 | "esrecurse": { |
998 | "version": "4.2.1", | 1032 | "version": "4.3.0", |
999 | "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", | 1033 | "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", |
1000 | "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", | 1034 | "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", |
1001 | "dev": true, | 1035 | "dev": true, |
1002 | "requires": { | 1036 | "requires": { |
1003 | "estraverse": "^4.1.0" | 1037 | "estraverse": "^5.2.0" |
1038 | }, | ||
1039 | "dependencies": { | ||
1040 | "estraverse": { | ||
1041 | "version": "5.2.0", | ||
1042 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", | ||
1043 | "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", | ||
1044 | "dev": true | ||
1045 | } | ||
1004 | } | 1046 | } |
1005 | }, | 1047 | }, |
1006 | "estraverse": { | 1048 | "estraverse": { |
@@ -1010,9 +1052,9 @@ | |||
1010 | "dev": true | 1052 | "dev": true |
1011 | }, | 1053 | }, |
1012 | "estree-walker": { | 1054 | "estree-walker": { |
1013 | "version": "1.0.1", | 1055 | "version": "2.0.1", |
1014 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", | 1056 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.1.tgz", |
1015 | "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", | 1057 | "integrity": "sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg==", |
1016 | "dev": true | 1058 | "dev": true |
1017 | }, | 1059 | }, |
1018 | "esutils": { | 1060 | "esutils": { |
@@ -1027,6 +1069,20 @@ | |||
1027 | "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", | 1069 | "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", |
1028 | "dev": true | 1070 | "dev": true |
1029 | }, | 1071 | }, |
1072 | "fast-glob": { | ||
1073 | "version": "3.2.4", | ||
1074 | "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", | ||
1075 | "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", | ||
1076 | "dev": true, | ||
1077 | "requires": { | ||
1078 | "@nodelib/fs.stat": "^2.0.2", | ||
1079 | "@nodelib/fs.walk": "^1.2.3", | ||
1080 | "glob-parent": "^5.1.0", | ||
1081 | "merge2": "^1.3.0", | ||
1082 | "micromatch": "^4.0.2", | ||
1083 | "picomatch": "^2.2.1" | ||
1084 | } | ||
1085 | }, | ||
1030 | "fast-json-stable-stringify": { | 1086 | "fast-json-stable-stringify": { |
1031 | "version": "2.1.0", | 1087 | "version": "2.1.0", |
1032 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", | 1088 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", |
@@ -1039,6 +1095,15 @@ | |||
1039 | "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", | 1095 | "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", |
1040 | "dev": true | 1096 | "dev": true |
1041 | }, | 1097 | }, |
1098 | "fastq": { | ||
1099 | "version": "1.9.0", | ||
1100 | "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.9.0.tgz", | ||
1101 | "integrity": "sha512-i7FVWL8HhVY+CTkwFxkN2mk3h+787ixS5S63eb78diVRc1MCssarHq3W5cj0av7YDSwmaV928RNag+U1etRQ7w==", | ||
1102 | "dev": true, | ||
1103 | "requires": { | ||
1104 | "reusify": "^1.0.4" | ||
1105 | } | ||
1106 | }, | ||
1042 | "fd-slicer": { | 1107 | "fd-slicer": { |
1043 | "version": "1.1.0", | 1108 | "version": "1.1.0", |
1044 | "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", | 1109 | "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", |
@@ -1049,12 +1114,12 @@ | |||
1049 | } | 1114 | } |
1050 | }, | 1115 | }, |
1051 | "file-entry-cache": { | 1116 | "file-entry-cache": { |
1052 | "version": "5.0.1", | 1117 | "version": "6.0.0", |
1053 | "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", | 1118 | "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.0.tgz", |
1054 | "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", | 1119 | "integrity": "sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA==", |
1055 | "dev": true, | 1120 | "dev": true, |
1056 | "requires": { | 1121 | "requires": { |
1057 | "flat-cache": "^2.0.1" | 1122 | "flat-cache": "^3.0.4" |
1058 | } | 1123 | } |
1059 | }, | 1124 | }, |
1060 | "fill-range": { | 1125 | "fill-range": { |
@@ -1077,29 +1142,25 @@ | |||
1077 | } | 1142 | } |
1078 | }, | 1143 | }, |
1079 | "flat": { | 1144 | "flat": { |
1080 | "version": "4.1.0", | 1145 | "version": "5.0.2", |
1081 | "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", | 1146 | "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", |
1082 | "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", | 1147 | "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", |
1083 | "dev": true, | 1148 | "dev": true |
1084 | "requires": { | ||
1085 | "is-buffer": "~2.0.3" | ||
1086 | } | ||
1087 | }, | 1149 | }, |
1088 | "flat-cache": { | 1150 | "flat-cache": { |
1089 | "version": "2.0.1", | 1151 | "version": "3.0.4", |
1090 | "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", | 1152 | "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", |
1091 | "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", | 1153 | "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", |
1092 | "dev": true, | 1154 | "dev": true, |
1093 | "requires": { | 1155 | "requires": { |
1094 | "flatted": "^2.0.0", | 1156 | "flatted": "^3.1.0", |
1095 | "rimraf": "2.6.3", | 1157 | "rimraf": "^3.0.2" |
1096 | "write": "1.0.3" | ||
1097 | } | 1158 | } |
1098 | }, | 1159 | }, |
1099 | "flatted": { | 1160 | "flatted": { |
1100 | "version": "2.0.2", | 1161 | "version": "3.1.0", |
1101 | "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", | 1162 | "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.0.tgz", |
1102 | "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", | 1163 | "integrity": "sha512-tW+UkmtNg/jv9CSofAKvgVcO7c2URjhTdW1ZTkcAritblu8tajiYy7YisnIflEwtKssCtOxpnBRoCB7iap0/TA==", |
1103 | "dev": true | 1164 | "dev": true |
1104 | }, | 1165 | }, |
1105 | "form-data": { | 1166 | "form-data": { |
@@ -1176,6 +1237,28 @@ | |||
1176 | "type-fest": "^0.8.1" | 1237 | "type-fest": "^0.8.1" |
1177 | } | 1238 | } |
1178 | }, | 1239 | }, |
1240 | "globby": { | ||
1241 | "version": "11.0.1", | ||
1242 | "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz", | ||
1243 | "integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==", | ||
1244 | "dev": true, | ||
1245 | "requires": { | ||
1246 | "array-union": "^2.1.0", | ||
1247 | "dir-glob": "^3.0.1", | ||
1248 | "fast-glob": "^3.1.1", | ||
1249 | "ignore": "^5.1.4", | ||
1250 | "merge2": "^1.3.0", | ||
1251 | "slash": "^3.0.0" | ||
1252 | }, | ||
1253 | "dependencies": { | ||
1254 | "ignore": { | ||
1255 | "version": "5.1.8", | ||
1256 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", | ||
1257 | "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", | ||
1258 | "dev": true | ||
1259 | } | ||
1260 | } | ||
1261 | }, | ||
1179 | "growl": { | 1262 | "growl": { |
1180 | "version": "1.10.5", | 1263 | "version": "1.10.5", |
1181 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", | 1264 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", |
@@ -1197,12 +1280,6 @@ | |||
1197 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", | 1280 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", |
1198 | "dev": true | 1281 | "dev": true |
1199 | }, | 1282 | }, |
1200 | "has-symbols": { | ||
1201 | "version": "1.0.1", | ||
1202 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", | ||
1203 | "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", | ||
1204 | "dev": true | ||
1205 | }, | ||
1206 | "he": { | 1283 | "he": { |
1207 | "version": "1.2.0", | 1284 | "version": "1.2.0", |
1208 | "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", | 1285 | "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", |
@@ -1261,9 +1338,9 @@ | |||
1261 | }, | 1338 | }, |
1262 | "dependencies": { | 1339 | "dependencies": { |
1263 | "debug": { | 1340 | "debug": { |
1264 | "version": "3.2.6", | 1341 | "version": "3.2.7", |
1265 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", | 1342 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", |
1266 | "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", | 1343 | "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", |
1267 | "dev": true, | 1344 | "dev": true, |
1268 | "requires": { | 1345 | "requires": { |
1269 | "ms": "^2.1.1" | 1346 | "ms": "^2.1.1" |
@@ -1278,9 +1355,9 @@ | |||
1278 | "dev": true | 1355 | "dev": true |
1279 | }, | 1356 | }, |
1280 | "import-fresh": { | 1357 | "import-fresh": { |
1281 | "version": "3.2.1", | 1358 | "version": "3.2.2", |
1282 | "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", | 1359 | "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.2.tgz", |
1283 | "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", | 1360 | "integrity": "sha512-cTPNrlvJT6twpYy+YmKUKrTSjWFs3bjYjAhCwm+z4EOCubZxAuO+hHpRN64TqjEaYSHs7tJAE0w1CKMGmsG/lw==", |
1284 | "dev": true, | 1361 | "dev": true, |
1285 | "requires": { | 1362 | "requires": { |
1286 | "parent-module": "^1.0.0", | 1363 | "parent-module": "^1.0.0", |
@@ -1309,12 +1386,6 @@ | |||
1309 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", | 1386 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", |
1310 | "dev": true | 1387 | "dev": true |
1311 | }, | 1388 | }, |
1312 | "is-arguments": { | ||
1313 | "version": "1.0.4", | ||
1314 | "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", | ||
1315 | "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", | ||
1316 | "dev": true | ||
1317 | }, | ||
1318 | "is-binary-path": { | 1389 | "is-binary-path": { |
1319 | "version": "2.1.0", | 1390 | "version": "2.1.0", |
1320 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", | 1391 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", |
@@ -1324,23 +1395,14 @@ | |||
1324 | "binary-extensions": "^2.0.0" | 1395 | "binary-extensions": "^2.0.0" |
1325 | } | 1396 | } |
1326 | }, | 1397 | }, |
1327 | "is-buffer": { | 1398 | "is-core-module": { |
1328 | "version": "2.0.4", | 1399 | "version": "2.2.0", |
1329 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", | 1400 | "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", |
1330 | "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", | 1401 | "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", |
1331 | "dev": true | 1402 | "dev": true, |
1332 | }, | 1403 | "requires": { |
1333 | "is-callable": { | 1404 | "has": "^1.0.3" |
1334 | "version": "1.2.0", | 1405 | } |
1335 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", | ||
1336 | "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", | ||
1337 | "dev": true | ||
1338 | }, | ||
1339 | "is-date-object": { | ||
1340 | "version": "1.0.2", | ||
1341 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", | ||
1342 | "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", | ||
1343 | "dev": true | ||
1344 | }, | 1406 | }, |
1345 | "is-extglob": { | 1407 | "is-extglob": { |
1346 | "version": "2.1.1", | 1408 | "version": "2.1.1", |
@@ -1363,12 +1425,6 @@ | |||
1363 | "is-extglob": "^2.1.1" | 1425 | "is-extglob": "^2.1.1" |
1364 | } | 1426 | } |
1365 | }, | 1427 | }, |
1366 | "is-map": { | ||
1367 | "version": "2.0.1", | ||
1368 | "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz", | ||
1369 | "integrity": "sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==", | ||
1370 | "dev": true | ||
1371 | }, | ||
1372 | "is-module": { | 1428 | "is-module": { |
1373 | "version": "1.0.0", | 1429 | "version": "1.0.0", |
1374 | "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", | 1430 | "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", |
@@ -1382,9 +1438,9 @@ | |||
1382 | "dev": true | 1438 | "dev": true |
1383 | }, | 1439 | }, |
1384 | "is-plain-obj": { | 1440 | "is-plain-obj": { |
1385 | "version": "1.1.0", | 1441 | "version": "2.1.0", |
1386 | "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", | 1442 | "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", |
1387 | "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", | 1443 | "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", |
1388 | "dev": true | 1444 | "dev": true |
1389 | }, | 1445 | }, |
1390 | "is-reference": { | 1446 | "is-reference": { |
@@ -1396,64 +1452,12 @@ | |||
1396 | "@types/estree": "*" | 1452 | "@types/estree": "*" |
1397 | } | 1453 | } |
1398 | }, | 1454 | }, |
1399 | "is-regex": { | ||
1400 | "version": "1.1.1", | ||
1401 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", | ||
1402 | "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", | ||
1403 | "dev": true, | ||
1404 | "requires": { | ||
1405 | "has-symbols": "^1.0.1" | ||
1406 | } | ||
1407 | }, | ||
1408 | "is-set": { | ||
1409 | "version": "2.0.1", | ||
1410 | "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.1.tgz", | ||
1411 | "integrity": "sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==", | ||
1412 | "dev": true | ||
1413 | }, | ||
1414 | "is-string": { | ||
1415 | "version": "1.0.5", | ||
1416 | "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", | ||
1417 | "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", | ||
1418 | "dev": true | ||
1419 | }, | ||
1420 | "is-symbol": { | ||
1421 | "version": "1.0.3", | ||
1422 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", | ||
1423 | "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", | ||
1424 | "dev": true, | ||
1425 | "requires": { | ||
1426 | "has-symbols": "^1.0.1" | ||
1427 | } | ||
1428 | }, | ||
1429 | "isarray": { | ||
1430 | "version": "2.0.5", | ||
1431 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", | ||
1432 | "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", | ||
1433 | "dev": true | ||
1434 | }, | ||
1435 | "isexe": { | 1455 | "isexe": { |
1436 | "version": "2.0.0", | 1456 | "version": "2.0.0", |
1437 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", | 1457 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", |
1438 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", | 1458 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", |
1439 | "dev": true | 1459 | "dev": true |
1440 | }, | 1460 | }, |
1441 | "iterate-iterator": { | ||
1442 | "version": "1.0.1", | ||
1443 | "resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.1.tgz", | ||
1444 | "integrity": "sha512-3Q6tudGN05kbkDQDI4CqjaBf4qf85w6W6GnuZDtUVYwKgtC1q8yxYX7CZed7N+tLzQqS6roujWvszf13T+n9aw==", | ||
1445 | "dev": true | ||
1446 | }, | ||
1447 | "iterate-value": { | ||
1448 | "version": "1.0.2", | ||
1449 | "resolved": "https://registry.npmjs.org/iterate-value/-/iterate-value-1.0.2.tgz", | ||
1450 | "integrity": "sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ==", | ||
1451 | "dev": true, | ||
1452 | "requires": { | ||
1453 | "es-get-iterator": "^1.0.2", | ||
1454 | "iterate-iterator": "^1.0.1" | ||
1455 | } | ||
1456 | }, | ||
1457 | "js-tokens": { | 1461 | "js-tokens": { |
1458 | "version": "4.0.0", | 1462 | "version": "4.0.0", |
1459 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", | 1463 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", |
@@ -1529,58 +1533,6 @@ | |||
1529 | "dev": true, | 1533 | "dev": true, |
1530 | "requires": { | 1534 | "requires": { |
1531 | "chalk": "^4.0.0" | 1535 | "chalk": "^4.0.0" |
1532 | }, | ||
1533 | "dependencies": { | ||
1534 | "ansi-styles": { | ||
1535 | "version": "4.2.1", | ||
1536 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", | ||
1537 | "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", | ||
1538 | "dev": true, | ||
1539 | "requires": { | ||
1540 | "@types/color-name": "^1.1.1", | ||
1541 | "color-convert": "^2.0.1" | ||
1542 | } | ||
1543 | }, | ||
1544 | "chalk": { | ||
1545 | "version": "4.1.0", | ||
1546 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", | ||
1547 | "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", | ||
1548 | "dev": true, | ||
1549 | "requires": { | ||
1550 | "ansi-styles": "^4.1.0", | ||
1551 | "supports-color": "^7.1.0" | ||
1552 | } | ||
1553 | }, | ||
1554 | "color-convert": { | ||
1555 | "version": "2.0.1", | ||
1556 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", | ||
1557 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", | ||
1558 | "dev": true, | ||
1559 | "requires": { | ||
1560 | "color-name": "~1.1.4" | ||
1561 | } | ||
1562 | }, | ||
1563 | "color-name": { | ||
1564 | "version": "1.1.4", | ||
1565 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", | ||
1566 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", | ||
1567 | "dev": true | ||
1568 | }, | ||
1569 | "has-flag": { | ||
1570 | "version": "4.0.0", | ||
1571 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", | ||
1572 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | ||
1573 | "dev": true | ||
1574 | }, | ||
1575 | "supports-color": { | ||
1576 | "version": "7.2.0", | ||
1577 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", | ||
1578 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", | ||
1579 | "dev": true, | ||
1580 | "requires": { | ||
1581 | "has-flag": "^4.0.0" | ||
1582 | } | ||
1583 | } | ||
1584 | } | 1536 | } |
1585 | }, | 1537 | }, |
1586 | "lru-cache": { | 1538 | "lru-cache": { |
@@ -1629,6 +1581,22 @@ | |||
1629 | "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", | 1581 | "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", |
1630 | "dev": true | 1582 | "dev": true |
1631 | }, | 1583 | }, |
1584 | "merge2": { | ||
1585 | "version": "1.4.1", | ||
1586 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", | ||
1587 | "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", | ||
1588 | "dev": true | ||
1589 | }, | ||
1590 | "micromatch": { | ||
1591 | "version": "4.0.2", | ||
1592 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", | ||
1593 | "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", | ||
1594 | "dev": true, | ||
1595 | "requires": { | ||
1596 | "braces": "^3.0.1", | ||
1597 | "picomatch": "^2.0.5" | ||
1598 | } | ||
1599 | }, | ||
1632 | "mime": { | 1600 | "mime": { |
1633 | "version": "1.6.0", | 1601 | "version": "1.6.0", |
1634 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", | 1602 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", |
@@ -1659,31 +1627,17 @@ | |||
1659 | "brace-expansion": "^1.1.7" | 1627 | "brace-expansion": "^1.1.7" |
1660 | } | 1628 | } |
1661 | }, | 1629 | }, |
1662 | "minimist": { | ||
1663 | "version": "1.2.5", | ||
1664 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", | ||
1665 | "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", | ||
1666 | "dev": true | ||
1667 | }, | ||
1668 | "mkdirp": { | ||
1669 | "version": "0.5.5", | ||
1670 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", | ||
1671 | "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", | ||
1672 | "dev": true, | ||
1673 | "requires": { | ||
1674 | "minimist": "^1.2.5" | ||
1675 | } | ||
1676 | }, | ||
1677 | "mocha": { | 1630 | "mocha": { |
1678 | "version": "8.1.3", | 1631 | "version": "8.2.1", |
1679 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.1.3.tgz", | 1632 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.2.1.tgz", |
1680 | "integrity": "sha512-ZbaYib4hT4PpF4bdSO2DohooKXIn4lDeiYqB+vTmCdr6l2woW0b6H3pf5x4sM5nwQMru9RvjjHYWVGltR50ZBw==", | 1633 | "integrity": "sha512-cuLBVfyFfFqbNR0uUKbDGXKGk+UDFe6aR4os78XIrMQpZl/nv7JYHcvP5MFIAb374b2zFXsdgEGwmzMtP0Xg8w==", |
1681 | "dev": true, | 1634 | "dev": true, |
1682 | "requires": { | 1635 | "requires": { |
1636 | "@ungap/promise-all-settled": "1.1.2", | ||
1683 | "ansi-colors": "4.1.1", | 1637 | "ansi-colors": "4.1.1", |
1684 | "browser-stdout": "1.3.1", | 1638 | "browser-stdout": "1.3.1", |
1685 | "chokidar": "3.4.2", | 1639 | "chokidar": "3.4.3", |
1686 | "debug": "4.1.1", | 1640 | "debug": "4.2.0", |
1687 | "diff": "4.0.2", | 1641 | "diff": "4.0.2", |
1688 | "escape-string-regexp": "4.0.0", | 1642 | "escape-string-regexp": "4.0.0", |
1689 | "find-up": "5.0.0", | 1643 | "find-up": "5.0.0", |
@@ -1694,24 +1648,26 @@ | |||
1694 | "log-symbols": "4.0.0", | 1648 | "log-symbols": "4.0.0", |
1695 | "minimatch": "3.0.4", | 1649 | "minimatch": "3.0.4", |
1696 | "ms": "2.1.2", | 1650 | "ms": "2.1.2", |
1697 | "object.assign": "4.1.0", | 1651 | "nanoid": "3.1.12", |
1698 | "promise.allsettled": "1.0.2", | 1652 | "serialize-javascript": "5.0.1", |
1699 | "serialize-javascript": "4.0.0", | 1653 | "strip-json-comments": "3.1.1", |
1700 | "strip-json-comments": "3.0.1", | 1654 | "supports-color": "7.2.0", |
1701 | "supports-color": "7.1.0", | ||
1702 | "which": "2.0.2", | 1655 | "which": "2.0.2", |
1703 | "wide-align": "1.1.3", | 1656 | "wide-align": "1.1.3", |
1704 | "workerpool": "6.0.0", | 1657 | "workerpool": "6.0.2", |
1705 | "yargs": "13.3.2", | 1658 | "yargs": "13.3.2", |
1706 | "yargs-parser": "13.1.2", | 1659 | "yargs-parser": "13.1.2", |
1707 | "yargs-unparser": "1.6.1" | 1660 | "yargs-unparser": "2.0.0" |
1708 | }, | 1661 | }, |
1709 | "dependencies": { | 1662 | "dependencies": { |
1710 | "ansi-colors": { | 1663 | "debug": { |
1711 | "version": "4.1.1", | 1664 | "version": "4.2.0", |
1712 | "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", | 1665 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", |
1713 | "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", | 1666 | "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", |
1714 | "dev": true | 1667 | "dev": true, |
1668 | "requires": { | ||
1669 | "ms": "2.1.2" | ||
1670 | } | ||
1715 | }, | 1671 | }, |
1716 | "escape-string-regexp": { | 1672 | "escape-string-regexp": { |
1717 | "version": "4.0.0", | 1673 | "version": "4.0.0", |
@@ -1725,16 +1681,10 @@ | |||
1725 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | 1681 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", |
1726 | "dev": true | 1682 | "dev": true |
1727 | }, | 1683 | }, |
1728 | "strip-json-comments": { | ||
1729 | "version": "3.0.1", | ||
1730 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", | ||
1731 | "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", | ||
1732 | "dev": true | ||
1733 | }, | ||
1734 | "supports-color": { | 1684 | "supports-color": { |
1735 | "version": "7.1.0", | 1685 | "version": "7.2.0", |
1736 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", | 1686 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", |
1737 | "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", | 1687 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", |
1738 | "dev": true, | 1688 | "dev": true, |
1739 | "requires": { | 1689 | "requires": { |
1740 | "has-flag": "^4.0.0" | 1690 | "has-flag": "^4.0.0" |
@@ -1754,6 +1704,12 @@ | |||
1754 | "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", | 1704 | "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", |
1755 | "dev": true | 1705 | "dev": true |
1756 | }, | 1706 | }, |
1707 | "nanoid": { | ||
1708 | "version": "3.1.12", | ||
1709 | "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.12.tgz", | ||
1710 | "integrity": "sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A==", | ||
1711 | "dev": true | ||
1712 | }, | ||
1757 | "natural-compare": { | 1713 | "natural-compare": { |
1758 | "version": "1.4.0", | 1714 | "version": "1.4.0", |
1759 | "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", | 1715 | "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", |
@@ -1780,30 +1736,6 @@ | |||
1780 | "boolbase": "~1.0.0" | 1736 | "boolbase": "~1.0.0" |
1781 | } | 1737 | } |
1782 | }, | 1738 | }, |
1783 | "object-inspect": { | ||
1784 | "version": "1.8.0", | ||
1785 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", | ||
1786 | "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", | ||
1787 | "dev": true | ||
1788 | }, | ||
1789 | "object-keys": { | ||
1790 | "version": "1.1.1", | ||
1791 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", | ||
1792 | "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", | ||
1793 | "dev": true | ||
1794 | }, | ||
1795 | "object.assign": { | ||
1796 | "version": "4.1.0", | ||
1797 | "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", | ||
1798 | "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", | ||
1799 | "dev": true, | ||
1800 | "requires": { | ||
1801 | "define-properties": "^1.1.2", | ||
1802 | "function-bind": "^1.1.1", | ||
1803 | "has-symbols": "^1.0.0", | ||
1804 | "object-keys": "^1.0.11" | ||
1805 | } | ||
1806 | }, | ||
1807 | "once": { | 1739 | "once": { |
1808 | "version": "1.4.0", | 1740 | "version": "1.4.0", |
1809 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", | 1741 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", |
@@ -1856,12 +1788,12 @@ | |||
1856 | } | 1788 | } |
1857 | }, | 1789 | }, |
1858 | "p-limit": { | 1790 | "p-limit": { |
1859 | "version": "3.0.2", | 1791 | "version": "3.1.0", |
1860 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.2.tgz", | 1792 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", |
1861 | "integrity": "sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==", | 1793 | "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", |
1862 | "dev": true, | 1794 | "dev": true, |
1863 | "requires": { | 1795 | "requires": { |
1864 | "p-try": "^2.0.0" | 1796 | "yocto-queue": "^0.1.0" |
1865 | } | 1797 | } |
1866 | }, | 1798 | }, |
1867 | "p-locate": { | 1799 | "p-locate": { |
@@ -1938,6 +1870,12 @@ | |||
1938 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", | 1870 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", |
1939 | "dev": true | 1871 | "dev": true |
1940 | }, | 1872 | }, |
1873 | "path-type": { | ||
1874 | "version": "4.0.0", | ||
1875 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", | ||
1876 | "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", | ||
1877 | "dev": true | ||
1878 | }, | ||
1941 | "pend": { | 1879 | "pend": { |
1942 | "version": "1.2.0", | 1880 | "version": "1.2.0", |
1943 | "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", | 1881 | "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", |
@@ -1962,19 +1900,6 @@ | |||
1962 | "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", | 1900 | "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", |
1963 | "dev": true | 1901 | "dev": true |
1964 | }, | 1902 | }, |
1965 | "promise.allsettled": { | ||
1966 | "version": "1.0.2", | ||
1967 | "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz", | ||
1968 | "integrity": "sha512-UpcYW5S1RaNKT6pd+s9jp9K9rlQge1UXKskec0j6Mmuq7UJCvlS2J2/s/yuPN8ehftf9HXMxWlKiPbGGUzpoRg==", | ||
1969 | "dev": true, | ||
1970 | "requires": { | ||
1971 | "array.prototype.map": "^1.0.1", | ||
1972 | "define-properties": "^1.1.3", | ||
1973 | "es-abstract": "^1.17.0-next.1", | ||
1974 | "function-bind": "^1.1.1", | ||
1975 | "iterate-value": "^1.0.0" | ||
1976 | } | ||
1977 | }, | ||
1978 | "pseudomap": { | 1903 | "pseudomap": { |
1979 | "version": "1.0.2", | 1904 | "version": "1.0.2", |
1980 | "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", | 1905 | "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", |
@@ -2017,9 +1942,9 @@ | |||
2017 | } | 1942 | } |
2018 | }, | 1943 | }, |
2019 | "readdirp": { | 1944 | "readdirp": { |
2020 | "version": "3.4.0", | 1945 | "version": "3.5.0", |
2021 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", | 1946 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", |
2022 | "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", | 1947 | "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", |
2023 | "dev": true, | 1948 | "dev": true, |
2024 | "requires": { | 1949 | "requires": { |
2025 | "picomatch": "^2.2.1" | 1950 | "picomatch": "^2.2.1" |
@@ -2044,11 +1969,12 @@ | |||
2044 | "dev": true | 1969 | "dev": true |
2045 | }, | 1970 | }, |
2046 | "resolve": { | 1971 | "resolve": { |
2047 | "version": "1.17.0", | 1972 | "version": "1.19.0", |
2048 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", | 1973 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", |
2049 | "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", | 1974 | "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", |
2050 | "dev": true, | 1975 | "dev": true, |
2051 | "requires": { | 1976 | "requires": { |
1977 | "is-core-module": "^2.1.0", | ||
2052 | "path-parse": "^1.0.6" | 1978 | "path-parse": "^1.0.6" |
2053 | } | 1979 | } |
2054 | }, | 1980 | }, |
@@ -2058,28 +1984,40 @@ | |||
2058 | "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", | 1984 | "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", |
2059 | "dev": true | 1985 | "dev": true |
2060 | }, | 1986 | }, |
1987 | "reusify": { | ||
1988 | "version": "1.0.4", | ||
1989 | "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", | ||
1990 | "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", | ||
1991 | "dev": true | ||
1992 | }, | ||
2061 | "rimraf": { | 1993 | "rimraf": { |
2062 | "version": "2.6.3", | 1994 | "version": "3.0.2", |
2063 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", | 1995 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", |
2064 | "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", | 1996 | "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", |
2065 | "dev": true, | 1997 | "dev": true, |
2066 | "requires": { | 1998 | "requires": { |
2067 | "glob": "^7.1.3" | 1999 | "glob": "^7.1.3" |
2068 | } | 2000 | } |
2069 | }, | 2001 | }, |
2070 | "rollup": { | 2002 | "rollup": { |
2071 | "version": "2.26.9", | 2003 | "version": "2.34.2", |
2072 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.26.9.tgz", | 2004 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.34.2.tgz", |
2073 | "integrity": "sha512-XIiWYLayLqV+oY4S2Lub/shJq4uk/QQLwWToYCL4LjZbYHbFK3czea4UDVRUJu+zNmKmxq5Zb/OG7c5HSvH2TQ==", | 2005 | "integrity": "sha512-mvtQLqu3cNeoctS+kZ09iOPxrc1P1/Bt1z15enuQ5feyKOdM3MJAVFjjsygurDpSWn530xB4AlA83TWIzRstXA==", |
2074 | "dev": true, | 2006 | "dev": true, |
2075 | "requires": { | 2007 | "requires": { |
2076 | "fsevents": "~2.1.2" | 2008 | "fsevents": "~2.1.2" |
2077 | } | 2009 | } |
2078 | }, | 2010 | }, |
2011 | "run-parallel": { | ||
2012 | "version": "1.1.10", | ||
2013 | "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", | ||
2014 | "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", | ||
2015 | "dev": true | ||
2016 | }, | ||
2079 | "safe-buffer": { | 2017 | "safe-buffer": { |
2080 | "version": "5.2.0", | 2018 | "version": "5.2.1", |
2081 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", | 2019 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", |
2082 | "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", | 2020 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", |
2083 | "dev": true | 2021 | "dev": true |
2084 | }, | 2022 | }, |
2085 | "semver": { | 2023 | "semver": { |
@@ -2088,9 +2026,9 @@ | |||
2088 | "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" | 2026 | "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" |
2089 | }, | 2027 | }, |
2090 | "serialize-javascript": { | 2028 | "serialize-javascript": { |
2091 | "version": "4.0.0", | 2029 | "version": "5.0.1", |
2092 | "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", | 2030 | "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", |
2093 | "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", | 2031 | "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", |
2094 | "dev": true, | 2032 | "dev": true, |
2095 | "requires": { | 2033 | "requires": { |
2096 | "randombytes": "^2.1.0" | 2034 | "randombytes": "^2.1.0" |
@@ -2123,6 +2061,12 @@ | |||
2123 | "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", | 2061 | "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", |
2124 | "dev": true | 2062 | "dev": true |
2125 | }, | 2063 | }, |
2064 | "slash": { | ||
2065 | "version": "3.0.0", | ||
2066 | "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", | ||
2067 | "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", | ||
2068 | "dev": true | ||
2069 | }, | ||
2126 | "slice-ansi": { | 2070 | "slice-ansi": { |
2127 | "version": "2.1.0", | 2071 | "version": "2.1.0", |
2128 | "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", | 2072 | "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", |
@@ -2174,26 +2118,6 @@ | |||
2174 | } | 2118 | } |
2175 | } | 2119 | } |
2176 | }, | 2120 | }, |
2177 | "string.prototype.trimend": { | ||
2178 | "version": "1.0.1", | ||
2179 | "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", | ||
2180 | "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", | ||
2181 | "dev": true, | ||
2182 | "requires": { | ||
2183 | "define-properties": "^1.1.3", | ||
2184 | "es-abstract": "^1.17.5" | ||
2185 | } | ||
2186 | }, | ||
2187 | "string.prototype.trimstart": { | ||
2188 | "version": "1.0.1", | ||
2189 | "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", | ||
2190 | "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", | ||
2191 | "dev": true, | ||
2192 | "requires": { | ||
2193 | "define-properties": "^1.1.3", | ||
2194 | "es-abstract": "^1.17.5" | ||
2195 | } | ||
2196 | }, | ||
2197 | "string_decoder": { | 2121 | "string_decoder": { |
2198 | "version": "1.3.0", | 2122 | "version": "1.3.0", |
2199 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", | 2123 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", |
@@ -2264,9 +2188,9 @@ | |||
2264 | } | 2188 | } |
2265 | }, | 2189 | }, |
2266 | "tslib": { | 2190 | "tslib": { |
2267 | "version": "2.0.1", | 2191 | "version": "2.0.3", |
2268 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", | 2192 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", |
2269 | "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==", | 2193 | "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==", |
2270 | "dev": true | 2194 | "dev": true |
2271 | }, | 2195 | }, |
2272 | "tsutils": { | 2196 | "tsutils": { |
@@ -2279,9 +2203,9 @@ | |||
2279 | }, | 2203 | }, |
2280 | "dependencies": { | 2204 | "dependencies": { |
2281 | "tslib": { | 2205 | "tslib": { |
2282 | "version": "1.13.0", | 2206 | "version": "1.14.1", |
2283 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", | 2207 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", |
2284 | "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", | 2208 | "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", |
2285 | "dev": true | 2209 | "dev": true |
2286 | } | 2210 | } |
2287 | } | 2211 | } |
@@ -2318,9 +2242,9 @@ | |||
2318 | } | 2242 | } |
2319 | }, | 2243 | }, |
2320 | "typescript": { | 2244 | "typescript": { |
2321 | "version": "3.9.7", | 2245 | "version": "4.1.2", |
2322 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", | 2246 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.2.tgz", |
2323 | "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", | 2247 | "integrity": "sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==", |
2324 | "dev": true | 2248 | "dev": true |
2325 | }, | 2249 | }, |
2326 | "typescript-formatter": { | 2250 | "typescript-formatter": { |
@@ -2367,21 +2291,21 @@ | |||
2367 | "dev": true | 2291 | "dev": true |
2368 | }, | 2292 | }, |
2369 | "v8-compile-cache": { | 2293 | "v8-compile-cache": { |
2370 | "version": "2.1.1", | 2294 | "version": "2.2.0", |
2371 | "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", | 2295 | "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz", |
2372 | "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", | 2296 | "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==", |
2373 | "dev": true | 2297 | "dev": true |
2374 | }, | 2298 | }, |
2375 | "vsce": { | 2299 | "vsce": { |
2376 | "version": "1.79.5", | 2300 | "version": "1.81.1", |
2377 | "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.79.5.tgz", | 2301 | "resolved": "https://registry.npmjs.org/vsce/-/vsce-1.81.1.tgz", |
2378 | "integrity": "sha512-KZFOthGwxWFwoGqwrkzfTfyCZGuniTofnJ1a/dCzQ2HP93u1UuCKrTQyGT+SuGHu8sNqdBYNe0hb9GC3qCN7fg==", | 2302 | "integrity": "sha512-1yWAYRxTx/PKSFZnuELe7GPyIo70H/XKJqf6wGikofUK3f3TCNGI6F9xkTQFvXKNe0AygUuxN7kITyPIQGMP+w==", |
2379 | "dev": true, | 2303 | "dev": true, |
2380 | "requires": { | 2304 | "requires": { |
2381 | "azure-devops-node-api": "^7.2.0", | 2305 | "azure-devops-node-api": "^7.2.0", |
2382 | "chalk": "^2.4.2", | 2306 | "chalk": "^2.4.2", |
2383 | "cheerio": "^1.0.0-rc.1", | 2307 | "cheerio": "^1.0.0-rc.1", |
2384 | "commander": "^2.8.1", | 2308 | "commander": "^6.1.0", |
2385 | "denodeify": "^1.2.1", | 2309 | "denodeify": "^1.2.1", |
2386 | "glob": "^7.0.6", | 2310 | "glob": "^7.0.6", |
2387 | "leven": "^3.1.0", | 2311 | "leven": "^3.1.0", |
@@ -2400,6 +2324,23 @@ | |||
2400 | "yazl": "^2.2.2" | 2324 | "yazl": "^2.2.2" |
2401 | }, | 2325 | }, |
2402 | "dependencies": { | 2326 | "dependencies": { |
2327 | "chalk": { | ||
2328 | "version": "2.4.2", | ||
2329 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", | ||
2330 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", | ||
2331 | "dev": true, | ||
2332 | "requires": { | ||
2333 | "ansi-styles": "^3.2.1", | ||
2334 | "escape-string-regexp": "^1.0.5", | ||
2335 | "supports-color": "^5.3.0" | ||
2336 | } | ||
2337 | }, | ||
2338 | "commander": { | ||
2339 | "version": "6.2.0", | ||
2340 | "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz", | ||
2341 | "integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==", | ||
2342 | "dev": true | ||
2343 | }, | ||
2403 | "semver": { | 2344 | "semver": { |
2404 | "version": "5.7.1", | 2345 | "version": "5.7.1", |
2405 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", | 2346 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", |
@@ -2437,14 +2378,25 @@ | |||
2437 | "integrity": "sha512-lf8Y1XXMtF1r2oDDAmJe+drizNXkybSRXAQQk5dPy2rYJsY9SPXYNO074L3THu9zNYepzV5fRJZUPo/V/TLBRQ==" | 2378 | "integrity": "sha512-lf8Y1XXMtF1r2oDDAmJe+drizNXkybSRXAQQk5dPy2rYJsY9SPXYNO074L3THu9zNYepzV5fRJZUPo/V/TLBRQ==" |
2438 | }, | 2379 | }, |
2439 | "vscode-test": { | 2380 | "vscode-test": { |
2440 | "version": "1.4.0", | 2381 | "version": "1.4.1", |
2441 | "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.4.0.tgz", | 2382 | "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-1.4.1.tgz", |
2442 | "integrity": "sha512-Jt7HNGvSE0+++Tvtq5wc4hiXLIr2OjDShz/gbAfM/mahQpy4rKBnmOK33D+MR67ATWviQhl+vpmU3p/qwSH/Pg==", | 2383 | "integrity": "sha512-Ls7+JyC06cUCuomlTYk4aNJI00Rri09hgtkNl3zfQ1bj6meXglpSPpuzJ/RPNetlUHFMm4eGs0Xr/H5pFPVwfQ==", |
2443 | "dev": true, | 2384 | "dev": true, |
2444 | "requires": { | 2385 | "requires": { |
2445 | "http-proxy-agent": "^2.1.0", | 2386 | "http-proxy-agent": "^2.1.0", |
2446 | "https-proxy-agent": "^2.2.4", | 2387 | "https-proxy-agent": "^2.2.4", |
2447 | "rimraf": "^2.6.3" | 2388 | "rimraf": "^2.6.3" |
2389 | }, | ||
2390 | "dependencies": { | ||
2391 | "rimraf": { | ||
2392 | "version": "2.7.1", | ||
2393 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", | ||
2394 | "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", | ||
2395 | "dev": true, | ||
2396 | "requires": { | ||
2397 | "glob": "^7.1.3" | ||
2398 | } | ||
2399 | } | ||
2448 | } | 2400 | } |
2449 | }, | 2401 | }, |
2450 | "which": { | 2402 | "which": { |
@@ -2505,9 +2457,9 @@ | |||
2505 | "dev": true | 2457 | "dev": true |
2506 | }, | 2458 | }, |
2507 | "workerpool": { | 2459 | "workerpool": { |
2508 | "version": "6.0.0", | 2460 | "version": "6.0.2", |
2509 | "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.0.tgz", | 2461 | "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.2.tgz", |
2510 | "integrity": "sha512-fU2OcNA/GVAJLLyKUoHkAgIhKb0JoCpSjLC/G2vYKxUjVmQwGbRVeoPJ1a8U4pnVofz4AQV5Y/NEw8oKqxEBtA==", | 2462 | "integrity": "sha512-DSNyvOpFKrNusaaUwk+ej6cBj1bmhLcBfj80elGk+ZIo5JSkq+unB1dLKEOcNfJDZgjGICfhQ0Q5TbP0PvF4+Q==", |
2511 | "dev": true | 2463 | "dev": true |
2512 | }, | 2464 | }, |
2513 | "wrap-ansi": { | 2465 | "wrap-ansi": { |
@@ -2544,19 +2496,10 @@ | |||
2544 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", | 2496 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", |
2545 | "dev": true | 2497 | "dev": true |
2546 | }, | 2498 | }, |
2547 | "write": { | ||
2548 | "version": "1.0.3", | ||
2549 | "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", | ||
2550 | "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", | ||
2551 | "dev": true, | ||
2552 | "requires": { | ||
2553 | "mkdirp": "^0.5.1" | ||
2554 | } | ||
2555 | }, | ||
2556 | "y18n": { | 2499 | "y18n": { |
2557 | "version": "4.0.0", | 2500 | "version": "4.0.1", |
2558 | "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", | 2501 | "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", |
2559 | "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", | 2502 | "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", |
2560 | "dev": true | 2503 | "dev": true |
2561 | }, | 2504 | }, |
2562 | "yallist": { | 2505 | "yallist": { |
@@ -2639,89 +2582,28 @@ | |||
2639 | } | 2582 | } |
2640 | }, | 2583 | }, |
2641 | "yargs-unparser": { | 2584 | "yargs-unparser": { |
2642 | "version": "1.6.1", | 2585 | "version": "2.0.0", |
2643 | "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.1.tgz", | 2586 | "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", |
2644 | "integrity": "sha512-qZV14lK9MWsGCmcr7u5oXGH0dbGqZAIxTDrWXZDo5zUr6b6iUmelNKO6x6R1dQT24AH3LgRxJpr8meWy2unolA==", | 2587 | "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", |
2645 | "dev": true, | 2588 | "dev": true, |
2646 | "requires": { | 2589 | "requires": { |
2647 | "camelcase": "^5.3.1", | 2590 | "camelcase": "^6.0.0", |
2648 | "decamelize": "^1.2.0", | 2591 | "decamelize": "^4.0.0", |
2649 | "flat": "^4.1.0", | 2592 | "flat": "^5.0.2", |
2650 | "is-plain-obj": "^1.1.0", | 2593 | "is-plain-obj": "^2.1.0" |
2651 | "yargs": "^14.2.3" | ||
2652 | }, | 2594 | }, |
2653 | "dependencies": { | 2595 | "dependencies": { |
2654 | "find-up": { | 2596 | "camelcase": { |
2655 | "version": "3.0.0", | 2597 | "version": "6.2.0", |
2656 | "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", | 2598 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", |
2657 | "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", | 2599 | "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", |
2658 | "dev": true, | ||
2659 | "requires": { | ||
2660 | "locate-path": "^3.0.0" | ||
2661 | } | ||
2662 | }, | ||
2663 | "locate-path": { | ||
2664 | "version": "3.0.0", | ||
2665 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", | ||
2666 | "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", | ||
2667 | "dev": true, | ||
2668 | "requires": { | ||
2669 | "p-locate": "^3.0.0", | ||
2670 | "path-exists": "^3.0.0" | ||
2671 | } | ||
2672 | }, | ||
2673 | "p-limit": { | ||
2674 | "version": "2.3.0", | ||
2675 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", | ||
2676 | "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", | ||
2677 | "dev": true, | ||
2678 | "requires": { | ||
2679 | "p-try": "^2.0.0" | ||
2680 | } | ||
2681 | }, | ||
2682 | "p-locate": { | ||
2683 | "version": "3.0.0", | ||
2684 | "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", | ||
2685 | "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", | ||
2686 | "dev": true, | ||
2687 | "requires": { | ||
2688 | "p-limit": "^2.0.0" | ||
2689 | } | ||
2690 | }, | ||
2691 | "path-exists": { | ||
2692 | "version": "3.0.0", | ||
2693 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", | ||
2694 | "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", | ||
2695 | "dev": true | 2600 | "dev": true |
2696 | }, | 2601 | }, |
2697 | "yargs": { | 2602 | "decamelize": { |
2698 | "version": "14.2.3", | 2603 | "version": "4.0.0", |
2699 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz", | 2604 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", |
2700 | "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==", | 2605 | "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", |
2701 | "dev": true, | 2606 | "dev": true |
2702 | "requires": { | ||
2703 | "cliui": "^5.0.0", | ||
2704 | "decamelize": "^1.2.0", | ||
2705 | "find-up": "^3.0.0", | ||
2706 | "get-caller-file": "^2.0.1", | ||
2707 | "require-directory": "^2.1.1", | ||
2708 | "require-main-filename": "^2.0.0", | ||
2709 | "set-blocking": "^2.0.0", | ||
2710 | "string-width": "^3.0.0", | ||
2711 | "which-module": "^2.0.0", | ||
2712 | "y18n": "^4.0.0", | ||
2713 | "yargs-parser": "^15.0.1" | ||
2714 | } | ||
2715 | }, | ||
2716 | "yargs-parser": { | ||
2717 | "version": "15.0.1", | ||
2718 | "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz", | ||
2719 | "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==", | ||
2720 | "dev": true, | ||
2721 | "requires": { | ||
2722 | "camelcase": "^5.0.0", | ||
2723 | "decamelize": "^1.2.0" | ||
2724 | } | ||
2725 | } | 2607 | } |
2726 | } | 2608 | } |
2727 | }, | 2609 | }, |
@@ -2743,6 +2625,12 @@ | |||
2743 | "requires": { | 2625 | "requires": { |
2744 | "buffer-crc32": "~0.2.3" | 2626 | "buffer-crc32": "~0.2.3" |
2745 | } | 2627 | } |
2628 | }, | ||
2629 | "yocto-queue": { | ||
2630 | "version": "0.1.0", | ||
2631 | "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", | ||
2632 | "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", | ||
2633 | "dev": true | ||
2746 | } | 2634 | } |
2747 | } | 2635 | } |
2748 | } | 2636 | } |
diff --git a/editors/code/package.json b/editors/code/package.json index c3f1a0d8d..af228f983 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -39,24 +39,24 @@ | |||
39 | "vscode-languageclient": "7.0.0-next.14" | 39 | "vscode-languageclient": "7.0.0-next.14" |
40 | }, | 40 | }, |
41 | "devDependencies": { | 41 | "devDependencies": { |
42 | "@rollup/plugin-commonjs": "^13.0.2", | 42 | "@rollup/plugin-commonjs": "^17.0.0", |
43 | "@rollup/plugin-node-resolve": "^8.4.0", | 43 | "@rollup/plugin-node-resolve": "^11.0.0", |
44 | "@types/glob": "^7.1.3", | 44 | "@types/glob": "^7.1.3", |
45 | "@types/mocha": "^7.0.2", | 45 | "@types/mocha": "^8.0.4", |
46 | "@types/node": "~12.7.0", | 46 | "@types/node": "~12.12.6", |
47 | "@types/node-fetch": "^2.5.7", | 47 | "@types/node-fetch": "^2.5.7", |
48 | "@types/vscode": "^1.47.1", | 48 | "@types/vscode": "^1.51.0", |
49 | "@typescript-eslint/eslint-plugin": "^3.10.1", | 49 | "@typescript-eslint/eslint-plugin": "^4.9.0", |
50 | "@typescript-eslint/parser": "^3.10.1", | 50 | "@typescript-eslint/parser": "^4.9.0", |
51 | "eslint": "^7.8.0", | 51 | "eslint": "^7.15.0", |
52 | "glob": "^7.1.6", | 52 | "glob": "^7.1.6", |
53 | "mocha": "^8.1.3", | 53 | "mocha": "^8.2.1", |
54 | "rollup": "^2.26.9", | 54 | "rollup": "^2.34.2", |
55 | "tslib": "^2.0.1", | 55 | "tslib": "^2.0.3", |
56 | "typescript": "^3.9.7", | 56 | "typescript": "^4.1.2", |
57 | "typescript-formatter": "^7.2.2", | 57 | "typescript-formatter": "^7.2.2", |
58 | "vsce": "^1.79.5", | 58 | "vsce": "^1.81.1", |
59 | "vscode-test": "^1.4.0" | 59 | "vscode-test": "^1.4.1" |
60 | }, | 60 | }, |
61 | "activationEvents": [ | 61 | "activationEvents": [ |
62 | "onLanguage:rust", | 62 | "onLanguage:rust", |