aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yaml4
-rw-r--r--Cargo.lock20
-rw-r--r--crates/ra_assists/src/doc_tests/generated.rs14
-rw-r--r--crates/ra_assists/src/handlers/merge_imports.rs154
-rw-r--r--crates/ra_assists/src/handlers/move_bounds.rs27
-rw-r--r--crates/ra_assists/src/handlers/split_import.rs29
-rw-r--r--crates/ra_assists/src/lib.rs58
-rw-r--r--crates/ra_syntax/src/ast/edit.rs116
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs14
-rw-r--r--crates/ra_syntax/src/lib.rs4
-rw-r--r--docs/user/assists.md13
-rw-r--r--editors/code/package-lock.json243
-rw-r--r--editors/code/package.json6
13 files changed, 487 insertions, 215 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index e7745c6cd..58c8f083a 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -126,8 +126,8 @@ jobs:
126 - run: npm ci 126 - run: npm ci
127 working-directory: ./editors/code 127 working-directory: ./editors/code
128 128
129 # - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; } 129 - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
130 # working-directory: ./editors/code 130 working-directory: ./editors/code
131 131
132 - run: npm run lint 132 - run: npm run lint
133 working-directory: ./editors/code 133 working-directory: ./editors/code
diff --git a/Cargo.lock b/Cargo.lock
index f76857724..3f4d9204c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -594,9 +594,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
594 594
595[[package]] 595[[package]]
596name = "libc" 596name = "libc"
597version = "0.2.67" 597version = "0.2.68"
598source = "registry+https://github.com/rust-lang/crates.io-index" 598source = "registry+https://github.com/rust-lang/crates.io-index"
599checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" 599checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
600 600
601[[package]] 601[[package]]
602name = "linked-hash-map" 602name = "linked-hash-map"
@@ -845,9 +845,9 @@ checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
845 845
846[[package]] 846[[package]]
847name = "proc-macro-hack" 847name = "proc-macro-hack"
848version = "0.5.11" 848version = "0.5.12"
849source = "registry+https://github.com/rust-lang/crates.io-index" 849source = "registry+https://github.com/rust-lang/crates.io-index"
850checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" 850checksum = "f918f2b601f93baa836c1c2945faef682ba5b6d4828ecb45eeb7cc3c71b811b4"
851dependencies = [ 851dependencies = [
852 "proc-macro2", 852 "proc-macro2",
853 "quote", 853 "quote",
@@ -1399,18 +1399,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
1399 1399
1400[[package]] 1400[[package]]
1401name = "serde" 1401name = "serde"
1402version = "1.0.104" 1402version = "1.0.105"
1403source = "registry+https://github.com/rust-lang/crates.io-index" 1403source = "registry+https://github.com/rust-lang/crates.io-index"
1404checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" 1404checksum = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff"
1405dependencies = [ 1405dependencies = [
1406 "serde_derive", 1406 "serde_derive",
1407] 1407]
1408 1408
1409[[package]] 1409[[package]]
1410name = "serde_derive" 1410name = "serde_derive"
1411version = "1.0.104" 1411version = "1.0.105"
1412source = "registry+https://github.com/rust-lang/crates.io-index" 1412source = "registry+https://github.com/rust-lang/crates.io-index"
1413checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" 1413checksum = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8"
1414dependencies = [ 1414dependencies = [
1415 "proc-macro2", 1415 "proc-macro2",
1416 "quote", 1416 "quote",
@@ -1529,9 +1529,9 @@ checksum = "20431e104bfecc1a40872578dbc390e10290a0e9c35fffe3ce6f73c15a9dbfc2"
1529 1529
1530[[package]] 1530[[package]]
1531name = "thin-dst" 1531name = "thin-dst"
1532version = "1.0.0" 1532version = "1.1.0"
1533source = "registry+https://github.com/rust-lang/crates.io-index" 1533source = "registry+https://github.com/rust-lang/crates.io-index"
1534checksum = "c52fd98a9e4913c466d83381a59245691875d2f3e04611fca57f964bd8aa96e1" 1534checksum = "db3c46be180f1af9673ebb27bc1235396f61ef6965b3fe0dbb2e624deb604f0e"
1535 1535
1536[[package]] 1536[[package]]
1537name = "thread_local" 1537name = "thread_local"
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
index 3f56dd508..aef6793e8 100644
--- a/crates/ra_assists/src/doc_tests/generated.rs
+++ b/crates/ra_assists/src/doc_tests/generated.rs
@@ -418,6 +418,20 @@ fn main() {
418} 418}
419 419
420#[test] 420#[test]
421fn doctest_merge_imports() {
422 check(
423 "merge_imports",
424 r#####"
425use std::<|>fmt::Formatter;
426use std::io;
427"#####,
428 r#####"
429use std::{fmt::Formatter, io};
430"#####,
431 )
432}
433
434#[test]
421fn doctest_merge_match_arms() { 435fn doctest_merge_match_arms() {
422 check( 436 check(
423 "merge_match_arms", 437 "merge_match_arms",
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs
new file mode 100644
index 000000000..96b1ab86a
--- /dev/null
+++ b/crates/ra_assists/src/handlers/merge_imports.rs
@@ -0,0 +1,154 @@
1use std::iter::successors;
2
3use ast::{edit::AstNodeEdit, make};
4use ra_syntax::{ast, AstNode, AstToken, Direction, InsertPosition, SyntaxElement, T};
5
6use crate::{Assist, AssistCtx, AssistId};
7
8// Assist: merge_imports
9//
10// Merges two imports with a common prefix.
11//
12// ```
13// use std::<|>fmt::Formatter;
14// use std::io;
15// ```
16// ->
17// ```
18// use std::{fmt::Formatter, io};
19// ```
20pub(crate) fn merge_imports(ctx: AssistCtx) -> Option<Assist> {
21 let tree: ast::UseTree = ctx.find_node_at_offset()?;
22 let use_item = tree.syntax().parent().and_then(ast::UseItem::cast)?;
23 let (merged, to_delete) = [Direction::Prev, Direction::Next]
24 .iter()
25 .copied()
26 .filter_map(|dir| next_use_item(&use_item, dir))
27 .filter_map(|it| Some((it.clone(), it.use_tree()?)))
28 .find_map(|(use_item, use_tree)| {
29 Some((try_merge_trees(&tree, &use_tree)?, use_item.clone()))
30 })?;
31 let mut offset = ctx.frange.range.start();
32 ctx.add_assist(AssistId("merge_imports"), "Merge imports", |edit| {
33 edit.replace_ast(tree, merged);
34
35 let mut range = to_delete.syntax().text_range();
36 let next_ws = to_delete
37 .syntax()
38 .next_sibling_or_token()
39 .and_then(|it| it.into_token())
40 .and_then(ast::Whitespace::cast);
41 if let Some(ws) = next_ws {
42 range = range.extend_to(&ws.syntax().text_range())
43 }
44 edit.delete(range);
45 if range.end() <= offset {
46 offset -= range.len();
47 }
48 edit.set_cursor(offset);
49 })
50}
51
52fn next_use_item(this_use_item: &ast::UseItem, direction: Direction) -> Option<ast::UseItem> {
53 this_use_item.syntax().siblings(direction).skip(1).find_map(ast::UseItem::cast)
54}
55
56fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option<ast::UseTree> {
57 let lhs_path = old.path()?;
58 let rhs_path = new.path()?;
59
60 let (lhs_prefix, rhs_prefix) = common_prefix(&lhs_path, &rhs_path)?;
61
62 let lhs = old.split_prefix(&lhs_prefix);
63 let rhs = new.split_prefix(&rhs_prefix);
64
65 let mut to_insert: Vec<SyntaxElement> = Vec::new();
66 to_insert.push(make::token(T![,]).into());
67 to_insert.push(make::tokens::single_space().into());
68 to_insert.extend(
69 rhs.use_tree_list()?
70 .syntax()
71 .children_with_tokens()
72 .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']),
73 );
74 let use_tree_list = lhs.use_tree_list()?;
75 let pos = InsertPosition::Before(use_tree_list.r_curly()?.into());
76 let use_tree_list = use_tree_list.insert_children(pos, to_insert);
77 Some(lhs.with_use_tree_list(use_tree_list))
78}
79
80fn common_prefix(lhs: &ast::Path, rhs: &ast::Path) -> Option<(ast::Path, ast::Path)> {
81 let mut res = None;
82 let mut lhs_curr = first_path(&lhs);
83 let mut rhs_curr = first_path(&rhs);
84 loop {
85 match (lhs_curr.segment(), rhs_curr.segment()) {
86 (Some(lhs), Some(rhs)) if lhs.syntax().text() == rhs.syntax().text() => (),
87 _ => break,
88 }
89 res = Some((lhs_curr.clone(), rhs_curr.clone()));
90
91 match (lhs_curr.parent_path(), rhs_curr.parent_path()) {
92 (Some(lhs), Some(rhs)) => {
93 lhs_curr = lhs;
94 rhs_curr = rhs;
95 }
96 _ => break,
97 }
98 }
99
100 res
101}
102
103fn first_path(path: &ast::Path) -> ast::Path {
104 successors(Some(path.clone()), |it| it.qualifier()).last().unwrap()
105}
106
107#[cfg(test)]
108mod tests {
109 use crate::helpers::check_assist;
110
111 use super::*;
112
113 #[test]
114 fn test_merge_first() {
115 check_assist(
116 merge_imports,
117 r"
118use std::fmt<|>::Debug;
119use std::fmt::Display;
120",
121 r"
122use std::fmt<|>::{Debug, Display};
123",
124 )
125 }
126
127 #[test]
128 fn test_merge_second() {
129 check_assist(
130 merge_imports,
131 r"
132use std::fmt::Debug;
133use std::fmt<|>::Display;
134",
135 r"
136use std::fmt<|>::{Display, Debug};
137",
138 )
139 }
140
141 #[test]
142 #[ignore]
143 fn test_merge_nested() {
144 check_assist(
145 merge_imports,
146 r"
147use std::{fmt<|>::Debug, fmt::Display};
148",
149 r"
150use std::{fmt::{Debug, Display}};
151",
152 )
153 }
154}
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs
index 0b501f3e5..93f26f51a 100644
--- a/crates/ra_assists/src/handlers/move_bounds.rs
+++ b/crates/ra_assists/src/handlers/move_bounds.rs
@@ -1,6 +1,6 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, edit, make, AstNode, NameOwner, TypeBoundsOwner}, 2 ast::{self, edit::AstNodeEdit, make, AstNode, NameOwner, TypeBoundsOwner},
3 SyntaxElement, 3 match_ast,
4 SyntaxKind::*, 4 SyntaxKind::*,
5}; 5};
6 6
@@ -34,15 +34,18 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option<Assist> {
34 return None; 34 return None;
35 } 35 }
36 36
37 let anchor: SyntaxElement = match parent.kind() { 37 let anchor = match_ast! {
38 FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), 38 match parent {
39 TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), 39 ast::FnDef(it) => it.body()?.syntax().clone().into(),
40 IMPL_DEF => ast::ImplDef::cast(parent)?.item_list()?.syntax().clone().into(), 40 ast::TraitDef(it) => it.item_list()?.syntax().clone().into(),
41 ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), 41 ast::ImplDef(it) => it.item_list()?.syntax().clone().into(),
42 STRUCT_DEF => parent 42 ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),
43 .children_with_tokens() 43 ast::StructDef(it) => {
44 .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == SEMI)?, 44 it.syntax().children_with_tokens()
45 _ => return None, 45 .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == SEMI)?
46 },
47 _ => return None
48 }
46 }; 49 };
47 50
48 ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to where clause", |edit| { 51 ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to where clause", |edit| {
@@ -54,7 +57,7 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option<Assist> {
54 (type_param, without_bounds) 57 (type_param, without_bounds)
55 }); 58 });
56 59
57 let new_type_param_list = edit::replace_descendants(&type_param_list, new_params); 60 let new_type_param_list = type_param_list.replace_descendants(new_params);
58 edit.replace_ast(type_param_list.clone(), new_type_param_list); 61 edit.replace_ast(type_param_list.clone(), new_type_param_list);
59 62
60 let where_clause = { 63 let where_clause = {
diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs
index 292c39f59..d9244f22d 100644
--- a/crates/ra_assists/src/handlers/split_import.rs
+++ b/crates/ra_assists/src/handlers/split_import.rs
@@ -1,9 +1,6 @@
1use std::iter::{once, successors}; 1use std::iter::successors;
2 2
3use ra_syntax::{ 3use ra_syntax::{ast, AstNode, T};
4 ast::{self, make},
5 AstNode, T,
6};
7 4
8use crate::{Assist, AssistCtx, AssistId}; 5use crate::{Assist, AssistCtx, AssistId};
9 6
@@ -25,7 +22,10 @@ pub(crate) fn split_import(ctx: AssistCtx) -> Option<Assist> {
25 22
26 let use_tree = top_path.syntax().ancestors().find_map(ast::UseTree::cast)?; 23 let use_tree = top_path.syntax().ancestors().find_map(ast::UseTree::cast)?;
27 24
28 let new_tree = split_use_tree_prefix(&use_tree, &path)?; 25 let new_tree = use_tree.split_prefix(&path);
26 if new_tree == use_tree {
27 return None;
28 }
29 let cursor = ctx.frange.range.start(); 29 let cursor = ctx.frange.range.start();
30 30
31 ctx.add_assist(AssistId("split_import"), "Split import", |edit| { 31 ctx.add_assist(AssistId("split_import"), "Split import", |edit| {
@@ -35,23 +35,6 @@ pub(crate) fn split_import(ctx: AssistCtx) -> Option<Assist> {
35 }) 35 })
36} 36}
37 37
38fn split_use_tree_prefix(use_tree: &ast::UseTree, prefix: &ast::Path) -> Option<ast::UseTree> {
39 let suffix = split_path_prefix(&prefix)?;
40 let use_tree = make::use_tree(suffix.clone(), use_tree.use_tree_list(), use_tree.alias());
41 let nested = make::use_tree_list(once(use_tree));
42 let res = make::use_tree(prefix.clone(), Some(nested), None);
43 Some(res)
44}
45
46fn split_path_prefix(prefix: &ast::Path) -> Option<ast::Path> {
47 let parent = prefix.parent_path()?;
48 let mut res = make::path_unqualified(parent.segment()?);
49 for p in successors(parent.parent_path(), |it| it.parent_path()) {
50 res = make::path_qualified(res, p.segment()?);
51 }
52 Some(res)
53}
54
55#[cfg(test)] 38#[cfg(test)]
56mod tests { 39mod tests {
57 use crate::helpers::{check_assist, check_assist_target}; 40 use crate::helpers::{check_assist, check_assist_target};
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 62fadcddd..b8704ea7d 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -93,66 +93,68 @@ pub fn resolved_assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssi
93mod handlers { 93mod handlers {
94 use crate::AssistHandler; 94 use crate::AssistHandler;
95 95
96 mod add_custom_impl;
96 mod add_derive; 97 mod add_derive;
97 mod add_explicit_type; 98 mod add_explicit_type;
98 mod add_impl; 99 mod add_impl;
99 mod add_custom_impl; 100 mod add_missing_impl_members;
100 mod add_new; 101 mod add_new;
101 mod apply_demorgan; 102 mod apply_demorgan;
102 mod auto_import; 103 mod auto_import;
103 mod invert_if;
104 mod flip_comma;
105 mod flip_binexpr;
106 mod flip_trait_bound;
107 mod change_visibility; 104 mod change_visibility;
105 mod early_return;
108 mod fill_match_arms; 106 mod fill_match_arms;
109 mod merge_match_arms; 107 mod flip_binexpr;
110 mod introduce_variable; 108 mod flip_comma;
109 mod flip_trait_bound;
111 mod inline_local_variable; 110 mod inline_local_variable;
111 mod introduce_variable;
112 mod invert_if;
113 mod merge_imports;
114 mod merge_match_arms;
115 mod move_bounds;
116 mod move_guard;
112 mod raw_string; 117 mod raw_string;
118 mod remove_dbg;
113 mod remove_mut; 119 mod remove_mut;
114 mod replace_if_let_with_match; 120 mod replace_if_let_with_match;
121 mod replace_qualified_name_with_use;
115 mod split_import; 122 mod split_import;
116 mod remove_dbg;
117 pub(crate) mod replace_qualified_name_with_use;
118 mod add_missing_impl_members;
119 mod move_guard;
120 mod move_bounds;
121 mod early_return;
122 123
123 pub(crate) fn all() -> &'static [AssistHandler] { 124 pub(crate) fn all() -> &'static [AssistHandler] {
124 &[ 125 &[
126 add_custom_impl::add_custom_impl,
125 add_derive::add_derive, 127 add_derive::add_derive,
126 add_explicit_type::add_explicit_type, 128 add_explicit_type::add_explicit_type,
127 add_impl::add_impl, 129 add_impl::add_impl,
128 add_custom_impl::add_custom_impl, 130 add_missing_impl_members::add_missing_default_members,
131 add_missing_impl_members::add_missing_impl_members,
129 add_new::add_new, 132 add_new::add_new,
130 apply_demorgan::apply_demorgan, 133 apply_demorgan::apply_demorgan,
131 invert_if::invert_if, 134 auto_import::auto_import,
132 change_visibility::change_visibility, 135 change_visibility::change_visibility,
136 early_return::convert_to_guarded_return,
133 fill_match_arms::fill_match_arms, 137 fill_match_arms::fill_match_arms,
134 merge_match_arms::merge_match_arms,
135 flip_comma::flip_comma,
136 flip_binexpr::flip_binexpr, 138 flip_binexpr::flip_binexpr,
139 flip_comma::flip_comma,
137 flip_trait_bound::flip_trait_bound, 140 flip_trait_bound::flip_trait_bound,
138 introduce_variable::introduce_variable,
139 replace_if_let_with_match::replace_if_let_with_match,
140 split_import::split_import,
141 remove_dbg::remove_dbg,
142 replace_qualified_name_with_use::replace_qualified_name_with_use,
143 add_missing_impl_members::add_missing_impl_members,
144 add_missing_impl_members::add_missing_default_members,
145 inline_local_variable::inline_local_variable, 141 inline_local_variable::inline_local_variable,
146 move_guard::move_guard_to_arm_body, 142 introduce_variable::introduce_variable,
147 move_guard::move_arm_cond_to_match_guard, 143 invert_if::invert_if,
144 merge_imports::merge_imports,
145 merge_match_arms::merge_match_arms,
148 move_bounds::move_bounds_to_where_clause, 146 move_bounds::move_bounds_to_where_clause,
147 move_guard::move_arm_cond_to_match_guard,
148 move_guard::move_guard_to_arm_body,
149 raw_string::add_hash, 149 raw_string::add_hash,
150 raw_string::make_raw_string, 150 raw_string::make_raw_string,
151 raw_string::make_usual_string, 151 raw_string::make_usual_string,
152 raw_string::remove_hash, 152 raw_string::remove_hash,
153 remove_dbg::remove_dbg,
153 remove_mut::remove_mut, 154 remove_mut::remove_mut,
154 early_return::convert_to_guarded_return, 155 replace_if_let_with_match::replace_if_let_with_match,
155 auto_import::auto_import, 156 replace_qualified_name_with_use::replace_qualified_name_with_use,
157 split_import::split_import,
156 ] 158 ]
157 } 159 }
158} 160}
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 40a04b9c5..68dae008f 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -23,7 +23,7 @@ impl ast::BinExpr {
23 pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> { 23 pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> {
24 let op_node: SyntaxElement = self.op_details()?.0.into(); 24 let op_node: SyntaxElement = self.op_details()?.0.into();
25 let to_insert: Option<SyntaxElement> = Some(make::token(op).into()); 25 let to_insert: Option<SyntaxElement> = Some(make::token(op).into());
26 Some(replace_children(self, single_node(op_node), to_insert)) 26 Some(self.replace_children(single_node(op_node), to_insert))
27 } 27 }
28} 28}
29 29
@@ -39,10 +39,10 @@ impl ast::FnDef {
39 } else { 39 } else {
40 to_insert.push(make::tokens::single_space().into()); 40 to_insert.push(make::tokens::single_space().into());
41 to_insert.push(body.syntax().clone().into()); 41 to_insert.push(body.syntax().clone().into());
42 return insert_children(self, InsertPosition::Last, to_insert); 42 return self.insert_children(InsertPosition::Last, to_insert);
43 }; 43 };
44 to_insert.push(body.syntax().clone().into()); 44 to_insert.push(body.syntax().clone().into());
45 replace_children(self, single_node(old_body_or_semi), to_insert) 45 self.replace_children(single_node(old_body_or_semi), to_insert)
46 } 46 }
47} 47}
48 48
@@ -75,7 +75,7 @@ impl ast::ItemList {
75 let ws = tokens::WsBuilder::new(&format!("\n{}", indent)); 75 let ws = tokens::WsBuilder::new(&format!("\n{}", indent));
76 let to_insert: ArrayVec<[SyntaxElement; 2]> = 76 let to_insert: ArrayVec<[SyntaxElement; 2]> =
77 [ws.ws().into(), item.syntax().clone().into()].into(); 77 [ws.ws().into(), item.syntax().clone().into()].into();
78 insert_children(self, position, to_insert) 78 self.insert_children(position, to_insert)
79 } 79 }
80 80
81 fn l_curly(&self) -> Option<SyntaxElement> { 81 fn l_curly(&self) -> Option<SyntaxElement> {
@@ -106,8 +106,8 @@ impl ast::ItemList {
106 let ws = tokens::WsBuilder::new(&format!("\n{}", indent)); 106 let ws = tokens::WsBuilder::new(&format!("\n{}", indent));
107 let to_insert = iter::once(ws.ws().into()); 107 let to_insert = iter::once(ws.ws().into());
108 match existing_ws { 108 match existing_ws {
109 None => insert_children(self, InsertPosition::After(l_curly), to_insert), 109 None => self.insert_children(InsertPosition::After(l_curly), to_insert),
110 Some(ws) => replace_children(self, single_node(ws), to_insert), 110 Some(ws) => self.replace_children(single_node(ws), to_insert),
111 } 111 }
112 } 112 }
113} 113}
@@ -184,7 +184,7 @@ impl ast::RecordFieldList {
184 InsertPosition::After(anchor) => after_field!(anchor), 184 InsertPosition::After(anchor) => after_field!(anchor),
185 }; 185 };
186 186
187 insert_children(self, position, to_insert) 187 self.insert_children(position, to_insert)
188 } 188 }
189 189
190 fn l_curly(&self) -> Option<SyntaxElement> { 190 fn l_curly(&self) -> Option<SyntaxElement> {
@@ -203,7 +203,7 @@ impl ast::TypeParam {
203 Some(it) => it.syntax().clone().into(), 203 Some(it) => it.syntax().clone().into(),
204 None => colon.clone().into(), 204 None => colon.clone().into(),
205 }; 205 };
206 replace_children(self, colon.into()..=end, iter::empty()) 206 self.replace_children(colon.into()..=end, iter::empty())
207 } 207 }
208} 208}
209 209
@@ -211,8 +211,7 @@ impl ast::Path {
211 #[must_use] 211 #[must_use]
212 pub fn with_segment(&self, segment: ast::PathSegment) -> ast::Path { 212 pub fn with_segment(&self, segment: ast::PathSegment) -> ast::Path {
213 if let Some(old) = self.segment() { 213 if let Some(old) = self.segment() {
214 return replace_children( 214 return self.replace_children(
215 self,
216 single_node(old.syntax().clone()), 215 single_node(old.syntax().clone()),
217 iter::once(segment.syntax().clone().into()), 216 iter::once(segment.syntax().clone().into()),
218 ); 217 );
@@ -234,8 +233,7 @@ impl ast::PathSegment {
234 233
235 fn _with_type_args(&self, type_args: ast::TypeArgList, turbo: bool) -> ast::PathSegment { 234 fn _with_type_args(&self, type_args: ast::TypeArgList, turbo: bool) -> ast::PathSegment {
236 if let Some(old) = self.type_arg_list() { 235 if let Some(old) = self.type_arg_list() {
237 return replace_children( 236 return self.replace_children(
238 self,
239 single_node(old.syntax().clone()), 237 single_node(old.syntax().clone()),
240 iter::once(type_args.syntax().clone().into()), 238 iter::once(type_args.syntax().clone().into()),
241 ); 239 );
@@ -245,7 +243,7 @@ impl ast::PathSegment {
245 to_insert.push(make::token(T![::]).into()); 243 to_insert.push(make::token(T![::]).into());
246 } 244 }
247 to_insert.push(type_args.syntax().clone().into()); 245 to_insert.push(type_args.syntax().clone().into());
248 insert_children(self, InsertPosition::Last, to_insert) 246 self.insert_children(InsertPosition::Last, to_insert)
249 } 247 }
250} 248}
251 249
@@ -253,7 +251,7 @@ impl ast::UseItem {
253 #[must_use] 251 #[must_use]
254 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem { 252 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem {
255 if let Some(old) = self.use_tree() { 253 if let Some(old) = self.use_tree() {
256 return replace_descendants(self, iter::once((old, use_tree))); 254 return self.replace_descendants(iter::once((old, use_tree)));
257 } 255 }
258 self.clone() 256 self.clone()
259 } 257 }
@@ -263,7 +261,7 @@ impl ast::UseTree {
263 #[must_use] 261 #[must_use]
264 pub fn with_path(&self, path: ast::Path) -> ast::UseTree { 262 pub fn with_path(&self, path: ast::Path) -> ast::UseTree {
265 if let Some(old) = self.path() { 263 if let Some(old) = self.path() {
266 return replace_descendants(self, iter::once((old, path))); 264 return self.replace_descendants(iter::once((old, path)));
267 } 265 }
268 self.clone() 266 self.clone()
269 } 267 }
@@ -271,10 +269,30 @@ impl ast::UseTree {
271 #[must_use] 269 #[must_use]
272 pub fn with_use_tree_list(&self, use_tree_list: ast::UseTreeList) -> ast::UseTree { 270 pub fn with_use_tree_list(&self, use_tree_list: ast::UseTreeList) -> ast::UseTree {
273 if let Some(old) = self.use_tree_list() { 271 if let Some(old) = self.use_tree_list() {
274 return replace_descendants(self, iter::once((old, use_tree_list))); 272 return self.replace_descendants(iter::once((old, use_tree_list)));
275 } 273 }
276 self.clone() 274 self.clone()
277 } 275 }
276
277 #[must_use]
278 pub fn split_prefix(&self, prefix: &ast::Path) -> ast::UseTree {
279 let suffix = match split_path_prefix(&prefix) {
280 Some(it) => it,
281 None => return self.clone(),
282 };
283 let use_tree = make::use_tree(suffix.clone(), self.use_tree_list(), self.alias());
284 let nested = make::use_tree_list(iter::once(use_tree));
285 return make::use_tree(prefix.clone(), Some(nested), None);
286
287 fn split_path_prefix(prefix: &ast::Path) -> Option<ast::Path> {
288 let parent = prefix.parent_path()?;
289 let mut res = make::path_unqualified(parent.segment()?);
290 for p in iter::successors(parent.parent_path(), |it| it.parent_path()) {
291 res = make::path_qualified(res, p.segment()?);
292 }
293 Some(res)
294 }
295 }
278} 296}
279 297
280#[must_use] 298#[must_use]
@@ -295,19 +313,6 @@ fn strip_attrs_and_docs_inner(mut node: SyntaxNode) -> SyntaxNode {
295 node 313 node
296} 314}
297 315
298#[must_use]
299pub fn replace_descendants<N: AstNode, D: AstNode>(
300 parent: &N,
301 replacement_map: impl IntoIterator<Item = (D, D)>,
302) -> N {
303 let map = replacement_map
304 .into_iter()
305 .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into()))
306 .collect::<FxHashMap<SyntaxElement, _>>();
307 let new_syntax = algo::replace_descendants(parent.syntax(), |n| map.get(n).cloned());
308 N::cast(new_syntax).unwrap()
309}
310
311#[derive(Debug, Clone, Copy)] 316#[derive(Debug, Clone, Copy)]
312pub struct IndentLevel(pub u8); 317pub struct IndentLevel(pub u8);
313 318
@@ -411,31 +416,48 @@ fn prev_tokens(token: SyntaxToken) -> impl Iterator<Item = SyntaxToken> {
411 iter::successors(Some(token), |token| token.prev_token()) 416 iter::successors(Some(token), |token| token.prev_token())
412} 417}
413 418
414#[must_use] 419pub trait AstNodeEdit: AstNode + Sized {
415fn insert_children<N: AstNode>( 420 #[must_use]
416 parent: &N, 421 fn insert_children(
417 position: InsertPosition<SyntaxElement>, 422 &self,
418 to_insert: impl IntoIterator<Item = SyntaxElement>, 423 position: InsertPosition<SyntaxElement>,
419) -> N { 424 to_insert: impl IntoIterator<Item = SyntaxElement>,
420 let new_syntax = algo::insert_children(parent.syntax(), position, to_insert); 425 ) -> Self {
421 N::cast(new_syntax).unwrap() 426 let new_syntax = algo::insert_children(self.syntax(), position, to_insert);
427 Self::cast(new_syntax).unwrap()
428 }
429
430 #[must_use]
431 fn replace_children(
432 &self,
433 to_replace: RangeInclusive<SyntaxElement>,
434 to_insert: impl IntoIterator<Item = SyntaxElement>,
435 ) -> Self {
436 let new_syntax = algo::replace_children(self.syntax(), to_replace, to_insert);
437 Self::cast(new_syntax).unwrap()
438 }
439
440 #[must_use]
441 fn replace_descendants<D: AstNode>(
442 &self,
443 replacement_map: impl IntoIterator<Item = (D, D)>,
444 ) -> Self {
445 let map = replacement_map
446 .into_iter()
447 .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into()))
448 .collect::<FxHashMap<SyntaxElement, _>>();
449 let new_syntax = algo::replace_descendants(self.syntax(), |n| map.get(n).cloned());
450 Self::cast(new_syntax).unwrap()
451 }
422} 452}
423 453
454impl<N: AstNode> AstNodeEdit for N {}
455
424fn single_node(element: impl Into<SyntaxElement>) -> RangeInclusive<SyntaxElement> { 456fn single_node(element: impl Into<SyntaxElement>) -> RangeInclusive<SyntaxElement> {
425 let element = element.into(); 457 let element = element.into();
426 element.clone()..=element 458 element.clone()..=element
427} 459}
428 460
429#[must_use]
430fn replace_children<N: AstNode>(
431 parent: &N,
432 to_replace: RangeInclusive<SyntaxElement>,
433 to_insert: impl IntoIterator<Item = SyntaxElement>,
434) -> N {
435 let new_syntax = algo::replace_children(parent.syntax(), to_replace, to_insert);
436 N::cast(new_syntax).unwrap()
437}
438
439#[test] 461#[test]
440fn test_increase_indent() { 462fn test_increase_indent() {
441 let arm_list = { 463 let arm_list = {
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index d5986e8b4..c3ae8f90e 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -167,6 +167,20 @@ impl ast::UseTreeList {
167 .and_then(ast::UseTree::cast) 167 .and_then(ast::UseTree::cast)
168 .expect("UseTreeLists are always nested in UseTrees") 168 .expect("UseTreeLists are always nested in UseTrees")
169 } 169 }
170 pub fn l_curly(&self) -> Option<SyntaxToken> {
171 self.token(T!['{'])
172 }
173
174 pub fn r_curly(&self) -> Option<SyntaxToken> {
175 self.token(T!['}'])
176 }
177
178 fn token(&self, kind: SyntaxKind) -> Option<SyntaxToken> {
179 self.syntax()
180 .children_with_tokens()
181 .filter_map(|it| it.into_token())
182 .find(|it| it.kind() == kind)
183 }
170} 184}
171 185
172impl ast::ImplDef { 186impl ast::ImplDef {
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index e3f74da6d..cef926ed3 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -179,10 +179,10 @@ macro_rules! match_ast {
179 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) }; 179 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
180 180
181 (match ($node:expr) { 181 (match ($node:expr) {
182 $( ast::$ast:ident($it:ident) => $res:block, )* 182 $( ast::$ast:ident($it:ident) => $res:expr, )*
183 _ => $catch_all:expr $(,)? 183 _ => $catch_all:expr $(,)?
184 }) => {{ 184 }) => {{
185 $( if let Some($it) = ast::$ast::cast($node.clone()) $res else )* 185 $( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )*
186 { $catch_all } 186 { $catch_all }
187 }}; 187 }};
188} 188}
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 9861332af..e2850b4dd 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -402,6 +402,19 @@ fn main() {
402} 402}
403``` 403```
404 404
405## `merge_imports`
406
407Merges two imports with a common prefix.
408
409```rust
410// BEFORE
411use std::┃fmt::Formatter;
412use std::io;
413
414// AFTER
415use std::{fmt::Formatter, io};
416```
417
405## `merge_match_arms` 418## `merge_match_arms`
406 419
407Merges identical match arms. 420Merges identical match arms.
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index c1fe620ef..787f1b17a 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -48,17 +48,6 @@
48 "builtin-modules": "^3.1.0", 48 "builtin-modules": "^3.1.0",
49 "is-module": "^1.0.0", 49 "is-module": "^1.0.0",
50 "resolve": "^1.14.2" 50 "resolve": "^1.14.2"
51 },
52 "dependencies": {
53 "resolve": {
54 "version": "1.15.0",
55 "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz",
56 "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==",
57 "dev": true,
58 "requires": {
59 "path-parse": "^1.0.6"
60 }
61 }
62 } 51 }
63 }, 52 },
64 "@rollup/pluginutils": { 53 "@rollup/pluginutils": {
@@ -70,6 +59,12 @@
70 "estree-walker": "^1.0.1" 59 "estree-walker": "^1.0.1"
71 } 60 }
72 }, 61 },
62 "@types/color-name": {
63 "version": "1.1.1",
64 "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
65 "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
66 "dev": true
67 },
73 "@types/eslint-visitor-keys": { 68 "@types/eslint-visitor-keys": {
74 "version": "1.0.0", 69 "version": "1.0.0",
75 "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", 70 "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
@@ -120,12 +115,12 @@
120 "dev": true 115 "dev": true
121 }, 116 },
122 "@typescript-eslint/eslint-plugin": { 117 "@typescript-eslint/eslint-plugin": {
123 "version": "2.23.0", 118 "version": "2.24.0",
124 "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.23.0.tgz", 119 "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.24.0.tgz",
125 "integrity": "sha512-8iA4FvRsz8qTjR0L/nK9RcRUN3QtIHQiOm69FzV7WS3SE+7P7DyGGwh3k4UNR2JBbk+Ej2Io+jLAaqKibNhmtw==", 120 "integrity": "sha512-wJRBeaMeT7RLQ27UQkDFOu25MqFOBus8PtOa9KaT5ZuxC1kAsd7JEHqWt4YXuY9eancX0GK9C68i5OROnlIzBA==",
126 "dev": true, 121 "dev": true,
127 "requires": { 122 "requires": {
128 "@typescript-eslint/experimental-utils": "2.23.0", 123 "@typescript-eslint/experimental-utils": "2.24.0",
129 "eslint-utils": "^1.4.3", 124 "eslint-utils": "^1.4.3",
130 "functional-red-black-tree": "^1.0.1", 125 "functional-red-black-tree": "^1.0.1",
131 "regexpp": "^3.0.0", 126 "regexpp": "^3.0.0",
@@ -133,32 +128,32 @@
133 } 128 }
134 }, 129 },
135 "@typescript-eslint/experimental-utils": { 130 "@typescript-eslint/experimental-utils": {
136 "version": "2.23.0", 131 "version": "2.24.0",
137 "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz", 132 "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz",
138 "integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==", 133 "integrity": "sha512-DXrwuXTdVh3ycNCMYmWhUzn/gfqu9N0VzNnahjiDJvcyhfBy4gb59ncVZVxdp5XzBC77dCncu0daQgOkbvPwBw==",
139 "dev": true, 134 "dev": true,
140 "requires": { 135 "requires": {
141 "@types/json-schema": "^7.0.3", 136 "@types/json-schema": "^7.0.3",
142 "@typescript-eslint/typescript-estree": "2.23.0", 137 "@typescript-eslint/typescript-estree": "2.24.0",
143 "eslint-scope": "^5.0.0" 138 "eslint-scope": "^5.0.0"
144 } 139 }
145 }, 140 },
146 "@typescript-eslint/parser": { 141 "@typescript-eslint/parser": {
147 "version": "2.23.0", 142 "version": "2.24.0",
148 "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.23.0.tgz", 143 "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.24.0.tgz",
149 "integrity": "sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg==", 144 "integrity": "sha512-H2Y7uacwSSg8IbVxdYExSI3T7uM1DzmOn2COGtCahCC3g8YtM1xYAPi2MAHyfPs61VKxP/J/UiSctcRgw4G8aw==",
150 "dev": true, 145 "dev": true,
151 "requires": { 146 "requires": {
152 "@types/eslint-visitor-keys": "^1.0.0", 147 "@types/eslint-visitor-keys": "^1.0.0",
153 "@typescript-eslint/experimental-utils": "2.23.0", 148 "@typescript-eslint/experimental-utils": "2.24.0",
154 "@typescript-eslint/typescript-estree": "2.23.0", 149 "@typescript-eslint/typescript-estree": "2.24.0",
155 "eslint-visitor-keys": "^1.1.0" 150 "eslint-visitor-keys": "^1.1.0"
156 } 151 }
157 }, 152 },
158 "@typescript-eslint/typescript-estree": { 153 "@typescript-eslint/typescript-estree": {
159 "version": "2.23.0", 154 "version": "2.24.0",
160 "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz", 155 "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz",
161 "integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==", 156 "integrity": "sha512-RJ0yMe5owMSix55qX7Mi9V6z2FDuuDpN6eR5fzRJrp+8in9UF41IGNQHbg5aMK4/PjVaEQksLvz0IA8n+Mr/FA==",
162 "dev": true, 157 "dev": true,
163 "requires": { 158 "requires": {
164 "debug": "^4.1.1", 159 "debug": "^4.1.1",
@@ -177,15 +172,15 @@
177 "dev": true 172 "dev": true
178 }, 173 },
179 "acorn-jsx": { 174 "acorn-jsx": {
180 "version": "5.1.0", 175 "version": "5.2.0",
181 "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz", 176 "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz",
182 "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==", 177 "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==",
183 "dev": true 178 "dev": true
184 }, 179 },
185 "ajv": { 180 "ajv": {
186 "version": "6.11.0", 181 "version": "6.12.0",
187 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", 182 "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz",
188 "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", 183 "integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==",
189 "dev": true, 184 "dev": true,
190 "requires": { 185 "requires": {
191 "fast-deep-equal": "^3.1.1", 186 "fast-deep-equal": "^3.1.1",
@@ -195,12 +190,20 @@
195 } 190 }
196 }, 191 },
197 "ansi-escapes": { 192 "ansi-escapes": {
198 "version": "4.3.0", 193 "version": "4.3.1",
199 "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", 194 "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz",
200 "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", 195 "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==",
201 "dev": true, 196 "dev": true,
202 "requires": { 197 "requires": {
203 "type-fest": "^0.8.1" 198 "type-fest": "^0.11.0"
199 },
200 "dependencies": {
201 "type-fest": {
202 "version": "0.11.0",
203 "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz",
204 "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==",
205 "dev": true
206 }
204 } 207 }
205 }, 208 },
206 "ansi-regex": { 209 "ansi-regex": {
@@ -612,13 +615,13 @@
612 "dev": true 615 "dev": true
613 }, 616 },
614 "espree": { 617 "espree": {
615 "version": "6.1.2", 618 "version": "6.2.1",
616 "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", 619 "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz",
617 "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", 620 "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==",
618 "dev": true, 621 "dev": true,
619 "requires": { 622 "requires": {
620 "acorn": "^7.1.0", 623 "acorn": "^7.1.1",
621 "acorn-jsx": "^5.1.0", 624 "acorn-jsx": "^5.2.0",
622 "eslint-visitor-keys": "^1.1.0" 625 "eslint-visitor-keys": "^1.1.0"
623 } 626 }
624 }, 627 },
@@ -673,17 +676,6 @@
673 "chardet": "^0.7.0", 676 "chardet": "^0.7.0",
674 "iconv-lite": "^0.4.24", 677 "iconv-lite": "^0.4.24",
675 "tmp": "^0.0.33" 678 "tmp": "^0.0.33"
676 },
677 "dependencies": {
678 "tmp": {
679 "version": "0.0.33",
680 "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
681 "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
682 "dev": true,
683 "requires": {
684 "os-tmpdir": "~1.0.2"
685 }
686 }
687 } 679 }
688 }, 680 },
689 "fast-deep-equal": { 681 "fast-deep-equal": {
@@ -765,6 +757,13 @@
765 "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 757 "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
766 "dev": true 758 "dev": true
767 }, 759 },
760 "fsevents": {
761 "version": "2.1.2",
762 "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz",
763 "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==",
764 "dev": true,
765 "optional": true
766 },
768 "functional-red-black-tree": { 767 "functional-red-black-tree": {
769 "version": "1.0.1", 768 "version": "1.0.1",
770 "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", 769 "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
@@ -795,9 +794,9 @@
795 } 794 }
796 }, 795 },
797 "globals": { 796 "globals": {
798 "version": "12.3.0", 797 "version": "12.4.0",
799 "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz", 798 "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
800 "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==", 799 "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
801 "dev": true, 800 "dev": true,
802 "requires": { 801 "requires": {
803 "type-fest": "^0.8.1" 802 "type-fest": "^0.8.1"
@@ -871,24 +870,85 @@
871 "dev": true 870 "dev": true
872 }, 871 },
873 "inquirer": { 872 "inquirer": {
874 "version": "7.0.4", 873 "version": "7.1.0",
875 "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.4.tgz", 874 "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.1.0.tgz",
876 "integrity": "sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==", 875 "integrity": "sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg==",
877 "dev": true, 876 "dev": true,
878 "requires": { 877 "requires": {
879 "ansi-escapes": "^4.2.1", 878 "ansi-escapes": "^4.2.1",
880 "chalk": "^2.4.2", 879 "chalk": "^3.0.0",
881 "cli-cursor": "^3.1.0", 880 "cli-cursor": "^3.1.0",
882 "cli-width": "^2.0.0", 881 "cli-width": "^2.0.0",
883 "external-editor": "^3.0.3", 882 "external-editor": "^3.0.3",
884 "figures": "^3.0.0", 883 "figures": "^3.0.0",
885 "lodash": "^4.17.15", 884 "lodash": "^4.17.15",
886 "mute-stream": "0.0.8", 885 "mute-stream": "0.0.8",
887 "run-async": "^2.2.0", 886 "run-async": "^2.4.0",
888 "rxjs": "^6.5.3", 887 "rxjs": "^6.5.3",
889 "string-width": "^4.1.0", 888 "string-width": "^4.1.0",
890 "strip-ansi": "^5.1.0", 889 "strip-ansi": "^6.0.0",
891 "through": "^2.3.6" 890 "through": "^2.3.6"
891 },
892 "dependencies": {
893 "ansi-styles": {
894 "version": "4.2.1",
895 "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
896 "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
897 "dev": true,
898 "requires": {
899 "@types/color-name": "^1.1.1",
900 "color-convert": "^2.0.1"
901 }
902 },
903 "chalk": {
904 "version": "3.0.0",
905 "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
906 "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
907 "dev": true,
908 "requires": {
909 "ansi-styles": "^4.1.0",
910 "supports-color": "^7.1.0"
911 }
912 },
913 "color-convert": {
914 "version": "2.0.1",
915 "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
916 "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
917 "dev": true,
918 "requires": {
919 "color-name": "~1.1.4"
920 }
921 },
922 "color-name": {
923 "version": "1.1.4",
924 "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
925 "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
926 "dev": true
927 },
928 "has-flag": {
929 "version": "4.0.0",
930 "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
931 "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
932 "dev": true
933 },
934 "strip-ansi": {
935 "version": "6.0.0",
936 "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
937 "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
938 "dev": true,
939 "requires": {
940 "ansi-regex": "^5.0.0"
941 }
942 },
943 "supports-color": {
944 "version": "7.1.0",
945 "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
946 "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
947 "dev": true,
948 "requires": {
949 "has-flag": "^4.0.0"
950 }
951 }
892 } 952 }
893 }, 953 },
894 "is-extglob": { 954 "is-extglob": {
@@ -1008,9 +1068,9 @@
1008 } 1068 }
1009 }, 1069 },
1010 "magic-string": { 1070 "magic-string": {
1011 "version": "0.25.6", 1071 "version": "0.25.7",
1012 "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.6.tgz", 1072 "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
1013 "integrity": "sha512-3a5LOMSGoCTH5rbqobC2HuDNRtE2glHZ8J7pK+QZYppyWA36yuNpsX994rIY2nCuyP7CZYy7lQq/X2jygiZ89g==", 1073 "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==",
1014 "dev": true, 1074 "dev": true,
1015 "requires": { 1075 "requires": {
1016 "sourcemap-codec": "^1.4.4" 1076 "sourcemap-codec": "^1.4.4"
@@ -1072,18 +1132,18 @@
1072 } 1132 }
1073 }, 1133 },
1074 "minimist": { 1134 "minimist": {
1075 "version": "0.0.8", 1135 "version": "1.2.5",
1076 "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 1136 "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
1077 "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 1137 "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
1078 "dev": true 1138 "dev": true
1079 }, 1139 },
1080 "mkdirp": { 1140 "mkdirp": {
1081 "version": "0.5.1", 1141 "version": "0.5.3",
1082 "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 1142 "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz",
1083 "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 1143 "integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==",
1084 "dev": true, 1144 "dev": true,
1085 "requires": { 1145 "requires": {
1086 "minimist": "0.0.8" 1146 "minimist": "^1.2.5"
1087 } 1147 }
1088 }, 1148 },
1089 "ms": { 1149 "ms": {
@@ -1294,9 +1354,9 @@
1294 "dev": true 1354 "dev": true
1295 }, 1355 },
1296 "resolve": { 1356 "resolve": {
1297 "version": "1.14.1", 1357 "version": "1.15.1",
1298 "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.1.tgz", 1358 "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz",
1299 "integrity": "sha512-fn5Wobh4cxbLzuHaE+nphztHy43/b++4M6SsGFC2gB8uYwf0C8LcarfCz1un7UTW8OFQg9iNjZ4xpcFVGebDPg==", 1359 "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==",
1300 "dev": true, 1360 "dev": true,
1301 "requires": { 1361 "requires": {
1302 "path-parse": "^1.0.6" 1362 "path-parse": "^1.0.6"
@@ -1328,20 +1388,18 @@
1328 } 1388 }
1329 }, 1389 },
1330 "rollup": { 1390 "rollup": {
1331 "version": "1.32.1", 1391 "version": "2.1.0",
1332 "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", 1392 "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.1.0.tgz",
1333 "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", 1393 "integrity": "sha512-gfE1455AEazVVTJoeQtcOq/U6GSxwoj4XPSWVsuWmgIxj7sBQNLDOSA82PbdMe+cP8ql8fR1jogPFe8Wg8g4SQ==",
1334 "dev": true, 1394 "dev": true,
1335 "requires": { 1395 "requires": {
1336 "@types/estree": "*", 1396 "fsevents": "~2.1.2"
1337 "@types/node": "*",
1338 "acorn": "^7.1.0"
1339 } 1397 }
1340 }, 1398 },
1341 "run-async": { 1399 "run-async": {
1342 "version": "2.3.0", 1400 "version": "2.4.0",
1343 "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", 1401 "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz",
1344 "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", 1402 "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==",
1345 "dev": true, 1403 "dev": true,
1346 "requires": { 1404 "requires": {
1347 "is-promise": "^2.1.0" 1405 "is-promise": "^2.1.0"
@@ -1544,12 +1602,12 @@
1544 "dev": true 1602 "dev": true
1545 }, 1603 },
1546 "tmp": { 1604 "tmp": {
1547 "version": "0.0.29", 1605 "version": "0.0.33",
1548 "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.29.tgz", 1606 "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
1549 "integrity": "sha1-8lEl/w3Z2jzLDC3Tce4SiLuRKMA=", 1607 "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
1550 "dev": true, 1608 "dev": true,
1551 "requires": { 1609 "requires": {
1552 "os-tmpdir": "~1.0.1" 1610 "os-tmpdir": "~1.0.2"
1553 } 1611 }
1554 }, 1612 },
1555 "tslib": { 1613 "tslib": {
@@ -1686,6 +1744,15 @@
1686 "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 1744 "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
1687 "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 1745 "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
1688 "dev": true 1746 "dev": true
1747 },
1748 "tmp": {
1749 "version": "0.0.29",
1750 "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.29.tgz",
1751 "integrity": "sha1-8lEl/w3Z2jzLDC3Tce4SiLuRKMA=",
1752 "dev": true,
1753 "requires": {
1754 "os-tmpdir": "~1.0.1"
1755 }
1689 } 1756 }
1690 } 1757 }
1691 }, 1758 },
diff --git a/editors/code/package.json b/editors/code/package.json
index 6528ff071..150c36845 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -42,10 +42,10 @@
42 "@types/node": "^12.12.30", 42 "@types/node": "^12.12.30",
43 "@types/node-fetch": "^2.5.5", 43 "@types/node-fetch": "^2.5.5",
44 "@types/vscode": "^1.43.0", 44 "@types/vscode": "^1.43.0",
45 "@typescript-eslint/eslint-plugin": "^2.23.0", 45 "@typescript-eslint/eslint-plugin": "^2.24.0",
46 "@typescript-eslint/parser": "^2.23.0", 46 "@typescript-eslint/parser": "^2.24.0",
47 "eslint": "^6.8.0", 47 "eslint": "^6.8.0",
48 "rollup": "^1.32.1", 48 "rollup": "^2.1.0",
49 "tslib": "^1.11.1", 49 "tslib": "^1.11.1",
50 "typescript": "^3.8.3", 50 "typescript": "^3.8.3",
51 "typescript-formatter": "^7.2.2", 51 "typescript-formatter": "^7.2.2",