aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-12 16:04:52 +0100
committerGitHub <[email protected]>2020-08-12 16:04:52 +0100
commita573e088ac64eeeb19e4fc74be2ff019be510477 (patch)
tree392c214055eab6a713814d46435bc0d91cf84e6c
parent6dba0e1c4de3b225556f7fce70518c8ebff170a6 (diff)
parent6dafc13f5f776980cd2560fb79d3d4790811c96d (diff)
Merge #5726
5726: Rename ra_text_edit -> text_edit r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--Cargo.lock48
-rw-r--r--crates/flycheck/Cargo.toml2
-rw-r--r--crates/flycheck/src/lib.rs2
-rw-r--r--crates/ra_assists/Cargo.toml2
-rw-r--r--crates/ra_assists/src/assist_context.rs4
-rw-r--r--crates/ra_assists/src/utils/insert_use.rs4
-rw-r--r--crates/ra_ide/Cargo.toml2
-rw-r--r--crates/ra_ide/src/completion/complete_postfix.rs2
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_item.rs2
-rw-r--r--crates/ra_ide/src/diagnostics.rs6
-rw-r--r--crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs4
-rw-r--r--crates/ra_ide/src/join_lines.rs6
-rw-r--r--crates/ra_ide/src/lib.rs2
-rw-r--r--crates/ra_ide/src/references/rename.rs6
-rw-r--r--crates/ra_ide/src/typing.rs2
-rw-r--r--crates/ra_ide/src/typing/on_enter.rs2
-rw-r--r--crates/ra_ide_db/Cargo.toml2
-rw-r--r--crates/ra_ide_db/src/source_change.rs2
-rw-r--r--crates/ra_proc_macro_srv/Cargo.toml2
-rw-r--r--crates/ra_proc_macro_srv/src/tests/utils.rs2
-rw-r--r--crates/ra_project_model/Cargo.toml2
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs4
-rw-r--r--crates/ra_project_model/src/lib.rs2
-rw-r--r--crates/ra_project_model/src/sysroot.rs4
-rw-r--r--crates/ra_ssr/Cargo.toml2
-rw-r--r--crates/ra_ssr/src/replacing.rs4
-rw-r--r--crates/ra_syntax/Cargo.toml2
-rw-r--r--crates/ra_syntax/fuzz/Cargo.toml2
-rw-r--r--crates/ra_syntax/src/algo.rs2
-rw-r--r--crates/ra_syntax/src/fuzz.rs2
-rw-r--r--crates/ra_syntax/src/lib.rs2
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs2
-rw-r--r--crates/rust-analyzer/Cargo.toml4
-rw-r--r--crates/rust-analyzer/src/handlers.rs2
-rw-r--r--crates/text_edit/Cargo.toml (renamed from crates/ra_text_edit/Cargo.toml)9
-rw-r--r--crates/text_edit/src/lib.rs (renamed from crates/ra_text_edit/src/lib.rs)27
-rw-r--r--crates/toolchain/Cargo.toml (renamed from crates/ra_toolchain/Cargo.toml)8
-rw-r--r--crates/toolchain/src/lib.rs (renamed from crates/ra_toolchain/src/lib.rs)4
-rw-r--r--editors/code/src/toolchain.ts4
41 files changed, 102 insertions, 94 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 598b739c7..4a6a65934 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -358,8 +358,8 @@ dependencies = [
358 "crossbeam-channel", 358 "crossbeam-channel",
359 "jod-thread", 359 "jod-thread",
360 "log", 360 "log",
361 "ra_toolchain",
362 "serde_json", 361 "serde_json",
362 "toolchain",
363] 363]
364 364
365[[package]] 365[[package]]
@@ -927,10 +927,10 @@ dependencies = [
927 "ra_hir", 927 "ra_hir",
928 "ra_ide_db", 928 "ra_ide_db",
929 "ra_syntax", 929 "ra_syntax",
930 "ra_text_edit",
931 "rustc-hash", 930 "rustc-hash",
932 "stdx", 931 "stdx",
933 "test_utils", 932 "test_utils",
933 "text_edit",
934] 934]
935 935
936[[package]] 936[[package]]
@@ -1075,10 +1075,10 @@ dependencies = [
1075 "ra_ide_db", 1075 "ra_ide_db",
1076 "ra_ssr", 1076 "ra_ssr",
1077 "ra_syntax", 1077 "ra_syntax",
1078 "ra_text_edit",
1079 "rustc-hash", 1078 "rustc-hash",
1080 "stdx", 1079 "stdx",
1081 "test_utils", 1080 "test_utils",
1081 "text_edit",
1082] 1082]
1083 1083
1084[[package]] 1084[[package]]
@@ -1093,11 +1093,11 @@ dependencies = [
1093 "ra_db", 1093 "ra_db",
1094 "ra_hir", 1094 "ra_hir",
1095 "ra_syntax", 1095 "ra_syntax",
1096 "ra_text_edit",
1097 "rayon", 1096 "rayon",
1098 "rustc-hash", 1097 "rustc-hash",
1099 "stdx", 1098 "stdx",
1100 "test_utils", 1099 "test_utils",
1100 "text_edit",
1101] 1101]
1102 1102
1103[[package]] 1103[[package]]
@@ -1143,9 +1143,9 @@ dependencies = [
1143 "memmap", 1143 "memmap",
1144 "ra_mbe", 1144 "ra_mbe",
1145 "ra_proc_macro", 1145 "ra_proc_macro",
1146 "ra_toolchain",
1147 "serde_derive", 1146 "serde_derive",
1148 "test_utils", 1147 "test_utils",
1148 "toolchain",
1149 "tt", 1149 "tt",
1150] 1150]
1151 1151
@@ -1161,11 +1161,11 @@ dependencies = [
1161 "ra_cfg", 1161 "ra_cfg",
1162 "ra_db", 1162 "ra_db",
1163 "ra_proc_macro", 1163 "ra_proc_macro",
1164 "ra_toolchain",
1165 "rustc-hash", 1164 "rustc-hash",
1166 "serde", 1165 "serde",
1167 "serde_json", 1166 "serde_json",
1168 "stdx", 1167 "stdx",
1168 "toolchain",
1169] 1169]
1170 1170
1171[[package]] 1171[[package]]
@@ -1177,9 +1177,9 @@ dependencies = [
1177 "ra_hir", 1177 "ra_hir",
1178 "ra_ide_db", 1178 "ra_ide_db",
1179 "ra_syntax", 1179 "ra_syntax",
1180 "ra_text_edit",
1181 "rustc-hash", 1180 "rustc-hash",
1182 "test_utils", 1181 "test_utils",
1182 "text_edit",
1183] 1183]
1184 1184
1185[[package]] 1185[[package]]
@@ -1191,7 +1191,6 @@ dependencies = [
1191 "itertools", 1191 "itertools",
1192 "once_cell", 1192 "once_cell",
1193 "ra_parser", 1193 "ra_parser",
1194 "ra_text_edit",
1195 "rayon", 1194 "rayon",
1196 "rowan", 1195 "rowan",
1197 "rustc-ap-rustc_lexer", 1196 "rustc-ap-rustc_lexer",
@@ -1200,24 +1199,11 @@ dependencies = [
1200 "smol_str", 1199 "smol_str",
1201 "stdx", 1200 "stdx",
1202 "test_utils", 1201 "test_utils",
1202 "text_edit",
1203 "walkdir", 1203 "walkdir",
1204] 1204]
1205 1205
1206[[package]] 1206[[package]]
1207name = "ra_text_edit"
1208version = "0.1.0"
1209dependencies = [
1210 "text-size",
1211]
1212
1213[[package]]
1214name = "ra_toolchain"
1215version = "0.1.0"
1216dependencies = [
1217 "home",
1218]
1219
1220[[package]]
1221name = "rayon" 1207name = "rayon"
1222version = "1.3.1" 1208version = "1.3.1"
1223source = "registry+https://github.com/rust-lang/crates.io-index" 1209source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1319,15 +1305,15 @@ dependencies = [
1319 "ra_project_model", 1305 "ra_project_model",
1320 "ra_ssr", 1306 "ra_ssr",
1321 "ra_syntax", 1307 "ra_syntax",
1322 "ra_text_edit",
1323 "ra_toolchain",
1324 "rayon", 1308 "rayon",
1325 "rustc-hash", 1309 "rustc-hash",
1326 "serde", 1310 "serde",
1327 "serde_json", 1311 "serde_json",
1328 "stdx", 1312 "stdx",
1329 "test_utils", 1313 "test_utils",
1314 "text_edit",
1330 "threadpool", 1315 "threadpool",
1316 "toolchain",
1331 "tt", 1317 "tt",
1332 "vfs", 1318 "vfs",
1333 "vfs-notify", 1319 "vfs-notify",
@@ -1573,6 +1559,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1573checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" 1559checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a"
1574 1560
1575[[package]] 1561[[package]]
1562name = "text_edit"
1563version = "0.0.0"
1564dependencies = [
1565 "text-size",
1566]
1567
1568[[package]]
1576name = "thin-dst" 1569name = "thin-dst"
1577version = "1.1.0" 1570version = "1.1.0"
1578source = "registry+https://github.com/rust-lang/crates.io-index" 1571source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1613,6 +1606,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1613checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" 1606checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed"
1614 1607
1615[[package]] 1608[[package]]
1609name = "toolchain"
1610version = "0.0.0"
1611dependencies = [
1612 "home",
1613]
1614
1615[[package]]
1616name = "tracing" 1616name = "tracing"
1617version = "0.1.18" 1617version = "0.1.18"
1618source = "registry+https://github.com/rust-lang/crates.io-index" 1618source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml
index ff8a1e568..acc72bc59 100644
--- a/crates/flycheck/Cargo.toml
+++ b/crates/flycheck/Cargo.toml
@@ -14,4 +14,4 @@ log = "0.4.8"
14cargo_metadata = "0.11.1" 14cargo_metadata = "0.11.1"
15serde_json = "1.0.48" 15serde_json = "1.0.48"
16jod-thread = "0.1.1" 16jod-thread = "0.1.1"
17ra_toolchain = { path = "../ra_toolchain" } 17toolchain = { path = "../toolchain" }
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index 31e14246d..16078d104 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -193,7 +193,7 @@ impl FlycheckActor {
193 extra_args, 193 extra_args,
194 features, 194 features,
195 } => { 195 } => {
196 let mut cmd = Command::new(ra_toolchain::cargo()); 196 let mut cmd = Command::new(toolchain::cargo());
197 cmd.arg(command); 197 cmd.arg(command);
198 cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) 198 cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
199 .arg(self.workspace_root.join("Cargo.toml")); 199 .arg(self.workspace_root.join("Cargo.toml"));
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml
index 6f5ace941..e4a5ee6c1 100644
--- a/crates/ra_assists/Cargo.toml
+++ b/crates/ra_assists/Cargo.toml
@@ -16,7 +16,7 @@ either = "1.5.3"
16stdx = { path = "../stdx" } 16stdx = { path = "../stdx" }
17 17
18ra_syntax = { path = "../ra_syntax" } 18ra_syntax = { path = "../ra_syntax" }
19ra_text_edit = { path = "../ra_text_edit" } 19text_edit = { path = "../text_edit" }
20ra_fmt = { path = "../ra_fmt" } 20ra_fmt = { path = "../ra_fmt" }
21profile = { path = "../profile" } 21profile = { path = "../profile" }
22ra_db = { path = "../ra_db" } 22ra_db = { path = "../ra_db" }
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs
index afd3fd4b9..fcaa1aedc 100644
--- a/crates/ra_assists/src/assist_context.rs
+++ b/crates/ra_assists/src/assist_context.rs
@@ -15,7 +15,7 @@ use ra_syntax::{
15 AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, 15 AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize,
16 TokenAtOffset, 16 TokenAtOffset,
17}; 17};
18use ra_text_edit::TextEditBuilder; 18use text_edit::{TextEdit, TextEditBuilder};
19 19
20use crate::{ 20use crate::{
21 assist_config::{AssistConfig, SnippetCap}, 21 assist_config::{AssistConfig, SnippetCap},
@@ -214,7 +214,7 @@ pub(crate) struct AssistBuilder {
214impl AssistBuilder { 214impl AssistBuilder {
215 pub(crate) fn new(file_id: FileId) -> AssistBuilder { 215 pub(crate) fn new(file_id: FileId) -> AssistBuilder {
216 AssistBuilder { 216 AssistBuilder {
217 edit: TextEditBuilder::default(), 217 edit: TextEdit::builder(),
218 file_id, 218 file_id,
219 is_snippet: false, 219 is_snippet: false,
220 change: SourceChange::default(), 220 change: SourceChange::default(),
diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs
index 32780fceb..13dbe1919 100644
--- a/crates/ra_assists/src/utils/insert_use.rs
+++ b/crates/ra_assists/src/utils/insert_use.rs
@@ -2,6 +2,7 @@
2// FIXME: rewrite according to the plan, outlined in 2// FIXME: rewrite according to the plan, outlined in
3// https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553 3// https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553
4 4
5use either::Either;
5use hir::{self, ModPath}; 6use hir::{self, ModPath};
6use ra_syntax::{ 7use ra_syntax::{
7 ast::{self, NameOwner, VisibilityOwner}, 8 ast::{self, NameOwner, VisibilityOwner},
@@ -9,10 +10,9 @@ use ra_syntax::{
9 SyntaxKind::{PATH, PATH_SEGMENT}, 10 SyntaxKind::{PATH, PATH_SEGMENT},
10 SyntaxNode, T, 11 SyntaxNode, T,
11}; 12};
12use ra_text_edit::TextEditBuilder; 13use text_edit::TextEditBuilder;
13 14
14use crate::assist_context::AssistContext; 15use crate::assist_context::AssistContext;
15use either::Either;
16 16
17/// Determines the containing syntax node in which to insert a `use` statement affecting `position`. 17/// Determines the containing syntax node in which to insert a `use` statement affecting `position`.
18pub(crate) fn find_insert_use_container( 18pub(crate) fn find_insert_use_container(
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index bbc9ba4e7..84c25f0b8 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -22,7 +22,7 @@ oorandom = "11.1.2"
22stdx = { path = "../stdx" } 22stdx = { path = "../stdx" }
23 23
24ra_syntax = { path = "../ra_syntax" } 24ra_syntax = { path = "../ra_syntax" }
25ra_text_edit = { path = "../ra_text_edit" } 25text_edit = { path = "../text_edit" }
26ra_db = { path = "../ra_db" } 26ra_db = { path = "../ra_db" }
27ra_ide_db = { path = "../ra_ide_db" } 27ra_ide_db = { path = "../ra_ide_db" }
28ra_cfg = { path = "../ra_cfg" } 28ra_cfg = { path = "../ra_cfg" }
diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs
index 8735b9010..42087da8d 100644
--- a/crates/ra_ide/src/completion/complete_postfix.rs
+++ b/crates/ra_ide/src/completion/complete_postfix.rs
@@ -4,7 +4,7 @@ use ra_syntax::{
4 ast::{self, AstNode}, 4 ast::{self, AstNode},
5 TextRange, TextSize, 5 TextRange, TextSize,
6}; 6};
7use ra_text_edit::TextEdit; 7use text_edit::TextEdit;
8 8
9use crate::{ 9use crate::{
10 completion::{ 10 completion::{
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index d9a0ef167..b397baf10 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -37,7 +37,7 @@ use ra_syntax::{
37 ast::{self, edit, Impl}, 37 ast::{self, edit, Impl},
38 AstNode, SyntaxKind, SyntaxNode, TextRange, T, 38 AstNode, SyntaxKind, SyntaxNode, TextRange, T,
39}; 39};
40use ra_text_edit::TextEdit; 40use text_edit::TextEdit;
41 41
42use crate::{ 42use crate::{
43 completion::{ 43 completion::{
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 4aa761148..0cb57fb1b 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -9,7 +9,7 @@ use ra_syntax::{
9 SyntaxKind::*, 9 SyntaxKind::*,
10 SyntaxNode, SyntaxToken, TextRange, TextSize, 10 SyntaxNode, SyntaxToken, TextRange, TextSize,
11}; 11};
12use ra_text_edit::Indel; 12use text_edit::Indel;
13 13
14use super::patterns::{ 14use super::patterns::{
15 has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, 15 has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent,
diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs
index 7bdda316c..1c0684f4e 100644
--- a/crates/ra_ide/src/completion/completion_item.rs
+++ b/crates/ra_ide/src/completion/completion_item.rs
@@ -4,7 +4,7 @@ use std::fmt;
4 4
5use hir::Documentation; 5use hir::Documentation;
6use ra_syntax::TextRange; 6use ra_syntax::TextRange;
7use ra_text_edit::TextEdit; 7use text_edit::TextEdit;
8 8
9use crate::completion::completion_config::SnippetCap; 9use crate::completion::completion_config::SnippetCap;
10 10
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 07bf133bd..54810d5bb 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -14,7 +14,7 @@ use ra_syntax::{
14 ast::{self, AstNode}, 14 ast::{self, AstNode},
15 SyntaxNode, TextRange, T, 15 SyntaxNode, TextRange, T,
16}; 16};
17use ra_text_edit::{TextEdit, TextEditBuilder}; 17use text_edit::TextEdit;
18 18
19use crate::{Diagnostic, FileId, Fix, SourceFileEdit}; 19use crate::{Diagnostic, FileId, Fix, SourceFileEdit};
20 20
@@ -103,7 +103,7 @@ fn check_unnecessary_braces_in_use_statement(
103 text_edit_for_remove_unnecessary_braces_with_self_in_use_statement(&single_use_tree) 103 text_edit_for_remove_unnecessary_braces_with_self_in_use_statement(&single_use_tree)
104 .unwrap_or_else(|| { 104 .unwrap_or_else(|| {
105 let to_replace = single_use_tree.syntax().text().to_string(); 105 let to_replace = single_use_tree.syntax().text().to_string();
106 let mut edit_builder = TextEditBuilder::default(); 106 let mut edit_builder = TextEdit::builder();
107 edit_builder.delete(use_range); 107 edit_builder.delete(use_range);
108 edit_builder.insert(use_range.start(), to_replace); 108 edit_builder.insert(use_range.start(), to_replace);
109 edit_builder.finish() 109 edit_builder.finish()
@@ -149,7 +149,7 @@ fn check_struct_shorthand_initialization(
149 let field_expr = expr.syntax().text().to_string(); 149 let field_expr = expr.syntax().text().to_string();
150 let field_name_is_tup_index = name_ref.as_tuple_field().is_some(); 150 let field_name_is_tup_index = name_ref.as_tuple_field().is_some();
151 if field_name == field_expr && !field_name_is_tup_index { 151 if field_name == field_expr && !field_name_is_tup_index {
152 let mut edit_builder = TextEditBuilder::default(); 152 let mut edit_builder = TextEdit::builder();
153 edit_builder.delete(record_field.syntax().text_range()); 153 edit_builder.delete(record_field.syntax().text_range());
154 edit_builder.insert(record_field.syntax().text_range().start(), field_name); 154 edit_builder.insert(record_field.syntax().text_range().start(), field_name);
155 let edit = edit_builder.finish(); 155 let edit = edit_builder.finish();
diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs
index f7c73773f..8fb25de6c 100644
--- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs
+++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs
@@ -13,7 +13,7 @@ use ra_ide_db::{
13 RootDatabase, 13 RootDatabase,
14}; 14};
15use ra_syntax::{algo, ast, AstNode}; 15use ra_syntax::{algo, ast, AstNode};
16use ra_text_edit::{TextEdit, TextEditBuilder}; 16use text_edit::TextEdit;
17 17
18/// A [Diagnostic] that potentially has a fix available. 18/// A [Diagnostic] that potentially has a fix available.
19/// 19///
@@ -70,7 +70,7 @@ impl DiagnosticWithFix for MissingFields {
70 } 70 }
71 71
72 let edit = { 72 let edit = {
73 let mut builder = TextEditBuilder::default(); 73 let mut builder = TextEdit::builder();
74 algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) 74 algo::diff(&old_field_list.syntax(), &new_field_list.syntax())
75 .into_text_edit(&mut builder); 75 .into_text_edit(&mut builder);
76 builder.finish() 76 builder.finish()
diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs
index 6907c09e8..caf63933a 100644
--- a/crates/ra_ide/src/join_lines.rs
+++ b/crates/ra_ide/src/join_lines.rs
@@ -7,7 +7,7 @@ use ra_syntax::{
7 SyntaxKind::{self, WHITESPACE}, 7 SyntaxKind::{self, WHITESPACE},
8 SyntaxNode, SyntaxToken, TextRange, TextSize, T, 8 SyntaxNode, SyntaxToken, TextRange, TextSize, T,
9}; 9};
10use ra_text_edit::{TextEdit, TextEditBuilder}; 10use text_edit::{TextEdit, TextEditBuilder};
11 11
12// Feature: Join Lines 12// Feature: Join Lines
13// 13//
@@ -23,7 +23,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit {
23 let syntax = file.syntax(); 23 let syntax = file.syntax();
24 let text = syntax.text().slice(range.start()..); 24 let text = syntax.text().slice(range.start()..);
25 let pos = match text.find_char('\n') { 25 let pos = match text.find_char('\n') {
26 None => return TextEditBuilder::default().finish(), 26 None => return TextEdit::builder().finish(),
27 Some(pos) => pos, 27 Some(pos) => pos,
28 }; 28 };
29 TextRange::at(range.start() + pos, TextSize::of('\n')) 29 TextRange::at(range.start() + pos, TextSize::of('\n'))
@@ -35,7 +35,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit {
35 NodeOrToken::Node(node) => node, 35 NodeOrToken::Node(node) => node,
36 NodeOrToken::Token(token) => token.parent(), 36 NodeOrToken::Token(token) => token.parent(),
37 }; 37 };
38 let mut edit = TextEditBuilder::default(); 38 let mut edit = TextEdit::builder();
39 for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { 39 for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) {
40 let range = match range.intersect(token.text_range()) { 40 let range = match range.intersect(token.text_range()) {
41 Some(range) => range, 41 Some(range) => range,
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index bfcf5d750..09cb5faf6 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -96,7 +96,7 @@ pub use ra_ide_db::{
96 RootDatabase, 96 RootDatabase,
97}; 97};
98pub use ra_ssr::SsrError; 98pub use ra_ssr::SsrError;
99pub use ra_text_edit::{Indel, TextEdit}; 99pub use text_edit::{Indel, TextEdit};
100 100
101pub type Cancelable<T> = Result<T, Canceled>; 101pub type Cancelable<T> = Result<T, Canceled>;
102 102
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index c8d80fcf7..9c688fb06 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -11,9 +11,9 @@ use ra_syntax::{
11 ast::{self, NameOwner}, 11 ast::{self, NameOwner},
12 lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, 12 lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken,
13}; 13};
14use ra_text_edit::TextEdit;
15use std::convert::TryInto; 14use std::convert::TryInto;
16use test_utils::mark; 15use test_utils::mark;
16use text_edit::TextEdit;
17 17
18use crate::{ 18use crate::{
19 references::find_all_refs, FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind, 19 references::find_all_refs, FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind,
@@ -271,9 +271,9 @@ fn rename_reference(
271#[cfg(test)] 271#[cfg(test)]
272mod tests { 272mod tests {
273 use expect::{expect, Expect}; 273 use expect::{expect, Expect};
274 use ra_text_edit::TextEditBuilder;
275 use stdx::trim_indent; 274 use stdx::trim_indent;
276 use test_utils::{assert_eq_text, mark}; 275 use test_utils::{assert_eq_text, mark};
276 use text_edit::TextEdit;
277 277
278 use crate::{mock_analysis::analysis_and_position, FileId}; 278 use crate::{mock_analysis::analysis_and_position, FileId};
279 279
@@ -281,7 +281,7 @@ mod tests {
281 let ra_fixture_after = &trim_indent(ra_fixture_after); 281 let ra_fixture_after = &trim_indent(ra_fixture_after);
282 let (analysis, position) = analysis_and_position(ra_fixture_before); 282 let (analysis, position) = analysis_and_position(ra_fixture_before);
283 let source_change = analysis.rename(position, new_name).unwrap(); 283 let source_change = analysis.rename(position, new_name).unwrap();
284 let mut text_edit_builder = TextEditBuilder::default(); 284 let mut text_edit_builder = TextEdit::builder();
285 let mut file_id: Option<FileId> = None; 285 let mut file_id: Option<FileId> = None;
286 if let Some(change) = source_change { 286 if let Some(change) = source_change {
287 for edit in change.info.source_file_edits { 287 for edit in change.info.source_file_edits {
diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs
index d3ce744b4..952429cde 100644
--- a/crates/ra_ide/src/typing.rs
+++ b/crates/ra_ide/src/typing.rs
@@ -26,7 +26,7 @@ use ra_syntax::{
26 TextRange, TextSize, 26 TextRange, TextSize,
27}; 27};
28 28
29use ra_text_edit::TextEdit; 29use text_edit::TextEdit;
30 30
31use crate::SourceChange; 31use crate::SourceChange;
32 32
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs
index 143b1ae41..c0c5ce3bc 100644
--- a/crates/ra_ide/src/typing/on_enter.rs
+++ b/crates/ra_ide/src/typing/on_enter.rs
@@ -9,8 +9,8 @@ use ra_syntax::{
9 SyntaxKind::*, 9 SyntaxKind::*,
10 SyntaxToken, TextRange, TextSize, TokenAtOffset, 10 SyntaxToken, TextRange, TextSize, TokenAtOffset,
11}; 11};
12use ra_text_edit::TextEdit;
13use test_utils::mark; 12use test_utils::mark;
13use text_edit::TextEdit;
14 14
15// Feature: On Enter 15// Feature: On Enter
16// 16//
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml
index 92b8ef82a..5446a5961 100644
--- a/crates/ra_ide_db/Cargo.toml
+++ b/crates/ra_ide_db/Cargo.toml
@@ -22,7 +22,7 @@ either = "1.5.3"
22stdx = { path = "../stdx" } 22stdx = { path = "../stdx" }
23 23
24ra_syntax = { path = "../ra_syntax" } 24ra_syntax = { path = "../ra_syntax" }
25ra_text_edit = { path = "../ra_text_edit" } 25text_edit = { path = "../text_edit" }
26ra_db = { path = "../ra_db" } 26ra_db = { path = "../ra_db" }
27profile = { path = "../profile" } 27profile = { path = "../profile" }
28test_utils = { path = "../test_utils" } 28test_utils = { path = "../test_utils" }
diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs
index abb83f421..ae21132dd 100644
--- a/crates/ra_ide_db/src/source_change.rs
+++ b/crates/ra_ide_db/src/source_change.rs
@@ -4,7 +4,7 @@
4//! It can be viewed as a dual for `AnalysisChange`. 4//! It can be viewed as a dual for `AnalysisChange`.
5 5
6use ra_db::FileId; 6use ra_db::FileId;
7use ra_text_edit::TextEdit; 7use text_edit::TextEdit;
8 8
9#[derive(Default, Debug, Clone)] 9#[derive(Default, Debug, Clone)]
10pub struct SourceChange { 10pub struct SourceChange {
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml
index a690cc044..1c25e7229 100644
--- a/crates/ra_proc_macro_srv/Cargo.toml
+++ b/crates/ra_proc_macro_srv/Cargo.toml
@@ -23,4 +23,4 @@ cargo_metadata = "0.11.1"
23difference = "2.0.0" 23difference = "2.0.0"
24# used as proc macro test target 24# used as proc macro test target
25serde_derive = "1.0.106" 25serde_derive = "1.0.106"
26ra_toolchain = { path = "../ra_toolchain" } 26toolchain = { path = "../toolchain" }
diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/ra_proc_macro_srv/src/tests/utils.rs
index dcb00671f..1b6a0b6fb 100644
--- a/crates/ra_proc_macro_srv/src/tests/utils.rs
+++ b/crates/ra_proc_macro_srv/src/tests/utils.rs
@@ -12,7 +12,7 @@ mod fixtures {
12 12
13 // Use current project metadata to get the proc-macro dylib path 13 // Use current project metadata to get the proc-macro dylib path
14 pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { 14 pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf {
15 let command = Command::new(ra_toolchain::cargo()) 15 let command = Command::new(toolchain::cargo())
16 .args(&["check", "--message-format", "json"]) 16 .args(&["check", "--message-format", "json"])
17 .output() 17 .output()
18 .unwrap() 18 .unwrap()
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml
index 27b1f5d33..171fe8626 100644
--- a/crates/ra_project_model/Cargo.toml
+++ b/crates/ra_project_model/Cargo.toml
@@ -17,7 +17,7 @@ cargo_metadata = "0.11.1"
17arena = { path = "../arena" } 17arena = { path = "../arena" }
18ra_cfg = { path = "../ra_cfg" } 18ra_cfg = { path = "../ra_cfg" }
19ra_db = { path = "../ra_db" } 19ra_db = { path = "../ra_db" }
20ra_toolchain = { path = "../ra_toolchain" } 20toolchain = { path = "../toolchain" }
21ra_proc_macro = { path = "../ra_proc_macro" } 21ra_proc_macro = { path = "../ra_proc_macro" }
22paths = { path = "../paths" } 22paths = { path = "../paths" }
23stdx = { path = "../stdx" } 23stdx = { path = "../stdx" }
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index a526d743d..abf8dca96 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -140,7 +140,7 @@ impl CargoWorkspace {
140 cargo_features: &CargoConfig, 140 cargo_features: &CargoConfig,
141 ) -> Result<CargoWorkspace> { 141 ) -> Result<CargoWorkspace> {
142 let mut meta = MetadataCommand::new(); 142 let mut meta = MetadataCommand::new();
143 meta.cargo_path(ra_toolchain::cargo()); 143 meta.cargo_path(toolchain::cargo());
144 meta.manifest_path(cargo_toml.to_path_buf()); 144 meta.manifest_path(cargo_toml.to_path_buf());
145 if cargo_features.all_features { 145 if cargo_features.all_features {
146 meta.features(CargoOpt::AllFeatures); 146 meta.features(CargoOpt::AllFeatures);
@@ -288,7 +288,7 @@ pub fn load_extern_resources(
288 cargo_toml: &Path, 288 cargo_toml: &Path,
289 cargo_features: &CargoConfig, 289 cargo_features: &CargoConfig,
290) -> Result<ExternResources> { 290) -> Result<ExternResources> {
291 let mut cmd = Command::new(ra_toolchain::cargo()); 291 let mut cmd = Command::new(toolchain::cargo());
292 cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); 292 cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml);
293 if cargo_features.all_features { 293 if cargo_features.all_features {
294 cmd.arg("--all-features"); 294 cmd.arg("--all-features");
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 300e75135..46f44910c 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -513,7 +513,7 @@ fn get_rustc_cfg_options(target: Option<&str>) -> Vec<CfgFlag> {
513 } 513 }
514 514
515 let rustc_cfgs = { 515 let rustc_cfgs = {
516 let mut cmd = Command::new(ra_toolchain::rustc()); 516 let mut cmd = Command::new(toolchain::rustc());
517 cmd.args(&["--print", "cfg", "-O"]); 517 cmd.args(&["--print", "cfg", "-O"]);
518 if let Some(target) = target { 518 if let Some(target) = target {
519 cmd.args(&["--target", target]); 519 cmd.args(&["--target", target]);
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index 6ef001769..8239797b6 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -101,13 +101,13 @@ fn get_or_install_rust_src(cargo_toml: &AbsPath) -> Result<AbsPathBuf> {
101 return Ok(path); 101 return Ok(path);
102 } 102 }
103 let current_dir = cargo_toml.parent().unwrap(); 103 let current_dir = cargo_toml.parent().unwrap();
104 let mut rustc = Command::new(ra_toolchain::rustc()); 104 let mut rustc = Command::new(toolchain::rustc());
105 rustc.current_dir(current_dir).args(&["--print", "sysroot"]); 105 rustc.current_dir(current_dir).args(&["--print", "sysroot"]);
106 let stdout = utf8_stdout(rustc)?; 106 let stdout = utf8_stdout(rustc)?;
107 let sysroot_path = AbsPath::assert(Path::new(stdout.trim())); 107 let sysroot_path = AbsPath::assert(Path::new(stdout.trim()));
108 let mut src = get_rust_src(sysroot_path); 108 let mut src = get_rust_src(sysroot_path);
109 if src.is_none() { 109 if src.is_none() {
110 let mut rustup = Command::new(ra_toolchain::rustup()); 110 let mut rustup = Command::new(toolchain::rustup());
111 rustup.current_dir(current_dir).args(&["component", "add", "rust-src"]); 111 rustup.current_dir(current_dir).args(&["component", "add", "rust-src"]);
112 utf8_stdout(rustup)?; 112 utf8_stdout(rustup)?;
113 src = get_rust_src(sysroot_path); 113 src = get_rust_src(sysroot_path);
diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml
index 84e4b171e..d0f2ae733 100644
--- a/crates/ra_ssr/Cargo.toml
+++ b/crates/ra_ssr/Cargo.toml
@@ -11,7 +11,7 @@ repository = "https://github.com/rust-analyzer/rust-analyzer"
11doctest = false 11doctest = false
12 12
13[dependencies] 13[dependencies]
14ra_text_edit = { path = "../ra_text_edit" } 14text_edit = { path = "../text_edit" }
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
16ra_db = { path = "../ra_db" } 16ra_db = { path = "../ra_db" }
17ra_ide_db = { path = "../ra_ide_db" } 17ra_ide_db = { path = "../ra_ide_db" }
diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ra_ssr/src/replacing.rs
index 0943244ff..74f9e7db6 100644
--- a/crates/ra_ssr/src/replacing.rs
+++ b/crates/ra_ssr/src/replacing.rs
@@ -4,8 +4,8 @@ use crate::matching::Var;
4use crate::{resolving::ResolvedRule, Match, SsrMatches}; 4use crate::{resolving::ResolvedRule, Match, SsrMatches};
5use ra_syntax::ast::{self, AstToken}; 5use ra_syntax::ast::{self, AstToken};
6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; 6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
7use ra_text_edit::TextEdit;
8use rustc_hash::{FxHashMap, FxHashSet}; 7use rustc_hash::{FxHashMap, FxHashSet};
8use text_edit::TextEdit;
9 9
10/// Returns a text edit that will replace each match in `matches` with its corresponding replacement 10/// Returns a text edit that will replace each match in `matches` with its corresponding replacement
11/// template. Placeholders in the template will have been substituted with whatever they matched to 11/// template. Placeholders in the template will have been substituted with whatever they matched to
@@ -24,7 +24,7 @@ fn matches_to_edit_at_offset(
24 relative_start: TextSize, 24 relative_start: TextSize,
25 rules: &[ResolvedRule], 25 rules: &[ResolvedRule],
26) -> TextEdit { 26) -> TextEdit {
27 let mut edit_builder = ra_text_edit::TextEditBuilder::default(); 27 let mut edit_builder = TextEdit::builder();
28 for m in &matches.matches { 28 for m in &matches.matches {
29 edit_builder.replace( 29 edit_builder.replace(
30 m.range.range.checked_sub(relative_start).unwrap(), 30 m.range.range.checked_sub(relative_start).unwrap(),
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index fc4d7aa04..f2789e6a3 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -20,7 +20,7 @@ once_cell = "1.3.1"
20 20
21stdx = { path = "../stdx" } 21stdx = { path = "../stdx" }
22 22
23ra_text_edit = { path = "../ra_text_edit" } 23text_edit = { path = "../text_edit" }
24ra_parser = { path = "../ra_parser" } 24ra_parser = { path = "../ra_parser" }
25 25
26# This crate transitively depends on `smol_str` via `rowan`. 26# This crate transitively depends on `smol_str` via `rowan`.
diff --git a/crates/ra_syntax/fuzz/Cargo.toml b/crates/ra_syntax/fuzz/Cargo.toml
index 613ad2857..4cec3c4cd 100644
--- a/crates/ra_syntax/fuzz/Cargo.toml
+++ b/crates/ra_syntax/fuzz/Cargo.toml
@@ -11,7 +11,7 @@ cargo-fuzz = true
11 11
12[dependencies] 12[dependencies]
13ra_syntax = { path = ".." } 13ra_syntax = { path = ".." }
14ra_text_edit = { path = "../../ra_text_edit" } 14text_edit = { path = "../../text_edit" }
15libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } 15libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }
16 16
17# Prevent this from interfering with workspaces 17# Prevent this from interfering with workspaces
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index 26b3c813a..6254b38ba 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -6,8 +6,8 @@ use std::{
6}; 6};
7 7
8use itertools::Itertools; 8use itertools::Itertools;
9use ra_text_edit::TextEditBuilder;
10use rustc_hash::FxHashMap; 9use rustc_hash::FxHashMap;
10use text_edit::TextEditBuilder;
11 11
12use crate::{ 12use crate::{
13 AstNode, Direction, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxNodePtr, 13 AstNode, Direction, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxNodePtr,
diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs
index 39f9b12ab..fbb97aa27 100644
--- a/crates/ra_syntax/src/fuzz.rs
+++ b/crates/ra_syntax/src/fuzz.rs
@@ -5,7 +5,7 @@ use std::{
5 str::{self, FromStr}, 5 str::{self, FromStr},
6}; 6};
7 7
8use ra_text_edit::Indel; 8use text_edit::Indel;
9 9
10use crate::{validation, AstNode, SourceFile, TextRange}; 10use crate::{validation, AstNode, SourceFile, TextRange};
11 11
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 8a4d45386..465607f55 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -39,8 +39,8 @@ pub mod fuzz;
39 39
40use std::{marker::PhantomData, sync::Arc}; 40use std::{marker::PhantomData, sync::Arc};
41 41
42use ra_text_edit::Indel;
43use stdx::format_to; 42use stdx::format_to;
43use text_edit::Indel;
44 44
45pub use crate::{ 45pub use crate::{
46 algo::InsertPosition, 46 algo::InsertPosition,
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index ed5a42ea3..6644ffca4 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -7,7 +7,7 @@
7//! and try to parse only this block. 7//! and try to parse only this block.
8 8
9use ra_parser::Reparser; 9use ra_parser::Reparser;
10use ra_text_edit::Indel; 10use text_edit::Indel;
11 11
12use crate::{ 12use crate::{
13 algo, 13 algo,
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 9bc5cc631..ef244da59 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -39,11 +39,11 @@ ra_ide = { path = "../ra_ide" }
39profile = { path = "../profile" } 39profile = { path = "../profile" }
40ra_project_model = { path = "../ra_project_model" } 40ra_project_model = { path = "../ra_project_model" }
41ra_syntax = { path = "../ra_syntax" } 41ra_syntax = { path = "../ra_syntax" }
42ra_text_edit = { path = "../ra_text_edit" } 42text_edit = { path = "../text_edit" }
43vfs = { path = "../vfs" } 43vfs = { path = "../vfs" }
44vfs-notify = { path = "../vfs-notify" } 44vfs-notify = { path = "../vfs-notify" }
45ra_cfg = { path = "../ra_cfg" } 45ra_cfg = { path = "../ra_cfg" }
46ra_toolchain = { path = "../ra_toolchain" } 46toolchain = { path = "../toolchain" }
47 47
48# This should only be used in CLI 48# This should only be used in CLI
49ra_db = { path = "../ra_db" } 49ra_db = { path = "../ra_db" }
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index d9b75eed4..07f4af3d3 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -692,7 +692,7 @@ pub(crate) fn handle_formatting(
692 692
693 let mut rustfmt = match &snap.config.rustfmt { 693 let mut rustfmt = match &snap.config.rustfmt {
694 RustfmtConfig::Rustfmt { extra_args } => { 694 RustfmtConfig::Rustfmt { extra_args } => {
695 let mut cmd = process::Command::new(ra_toolchain::rustfmt()); 695 let mut cmd = process::Command::new(toolchain::rustfmt());
696 cmd.args(extra_args); 696 cmd.args(extra_args);
697 if let Some(&crate_id) = crate_ids.first() { 697 if let Some(&crate_id) = crate_ids.first() {
698 // Assume all crates are in the same edition 698 // Assume all crates are in the same edition
diff --git a/crates/ra_text_edit/Cargo.toml b/crates/text_edit/Cargo.toml
index dbb223350..a69b1ef2b 100644
--- a/crates/ra_text_edit/Cargo.toml
+++ b/crates/text_edit/Cargo.toml
@@ -1,10 +1,9 @@
1[package] 1[package]
2edition = "2018" 2name = "text_edit"
3name = "ra_text_edit" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6publish = false
7license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
8 7
9[lib] 8[lib]
10doctest = false 9doctest = false
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/text_edit/src/lib.rs
index d68791cf1..ab8cd7fd1 100644
--- a/crates/ra_text_edit/src/lib.rs
+++ b/crates/text_edit/src/lib.rs
@@ -3,8 +3,6 @@
3//! `rust-analyzer` never mutates text itself and only sends diffs to clients, 3//! `rust-analyzer` never mutates text itself and only sends diffs to clients,
4//! so `TextEdit` is the ultimate representation of the work done by 4//! so `TextEdit` is the ultimate representation of the work done by
5//! rust-analyzer. 5//! rust-analyzer.
6use std::{slice, vec};
7
8pub use text_size::{TextRange, TextSize}; 6pub use text_size::{TextRange, TextSize};
9 7
10/// `InsertDelete` -- a single "atomic" change to text 8/// `InsertDelete` -- a single "atomic" change to text
@@ -46,20 +44,24 @@ impl Indel {
46} 44}
47 45
48impl TextEdit { 46impl TextEdit {
47 pub fn builder() -> TextEditBuilder {
48 TextEditBuilder::default()
49 }
50
49 pub fn insert(offset: TextSize, text: String) -> TextEdit { 51 pub fn insert(offset: TextSize, text: String) -> TextEdit {
50 let mut builder = TextEditBuilder::default(); 52 let mut builder = TextEdit::builder();
51 builder.insert(offset, text); 53 builder.insert(offset, text);
52 builder.finish() 54 builder.finish()
53 } 55 }
54 56
55 pub fn delete(range: TextRange) -> TextEdit { 57 pub fn delete(range: TextRange) -> TextEdit {
56 let mut builder = TextEditBuilder::default(); 58 let mut builder = TextEdit::builder();
57 builder.delete(range); 59 builder.delete(range);
58 builder.finish() 60 builder.finish()
59 } 61 }
60 62
61 pub fn replace(range: TextRange, replace_with: String) -> TextEdit { 63 pub fn replace(range: TextRange, replace_with: String) -> TextEdit {
62 let mut builder = TextEditBuilder::default(); 64 let mut builder = TextEdit::builder();
63 builder.replace(range, replace_with); 65 builder.replace(range, replace_with);
64 builder.finish() 66 builder.finish()
65 } 67 }
@@ -72,8 +74,8 @@ impl TextEdit {
72 self.indels.is_empty() 74 self.indels.is_empty()
73 } 75 }
74 76
75 pub fn iter(&self) -> slice::Iter<'_, Indel> { 77 pub fn iter(&self) -> std::slice::Iter<'_, Indel> {
76 self.indels.iter() 78 self.into_iter()
77 } 79 }
78 80
79 pub fn apply(&self, text: &mut String) { 81 pub fn apply(&self, text: &mut String) {
@@ -139,13 +141,22 @@ impl TextEdit {
139 141
140impl IntoIterator for TextEdit { 142impl IntoIterator for TextEdit {
141 type Item = Indel; 143 type Item = Indel;
142 type IntoIter = vec::IntoIter<Self::Item>; 144 type IntoIter = std::vec::IntoIter<Indel>;
143 145
144 fn into_iter(self) -> Self::IntoIter { 146 fn into_iter(self) -> Self::IntoIter {
145 self.indels.into_iter() 147 self.indels.into_iter()
146 } 148 }
147} 149}
148 150
151impl<'a> IntoIterator for &'a TextEdit {
152 type Item = &'a Indel;
153 type IntoIter = std::slice::Iter<'a, Indel>;
154
155 fn into_iter(self) -> Self::IntoIter {
156 self.indels.iter()
157 }
158}
159
149impl TextEditBuilder { 160impl TextEditBuilder {
150 pub fn replace(&mut self, range: TextRange, replace_with: String) { 161 pub fn replace(&mut self, range: TextRange, replace_with: String) {
151 self.indels.push(Indel::replace(range, replace_with)) 162 self.indels.push(Indel::replace(range, replace_with))
diff --git a/crates/ra_toolchain/Cargo.toml b/crates/toolchain/Cargo.toml
index 84b748c0a..4856668f8 100644
--- a/crates/ra_toolchain/Cargo.toml
+++ b/crates/toolchain/Cargo.toml
@@ -1,9 +1,9 @@
1[package] 1[package]
2edition = "2018" 2name = "toolchain"
3name = "ra_toolchain" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
7 7
8[lib] 8[lib]
9doctest = false 9doctest = false
diff --git a/crates/ra_toolchain/src/lib.rs b/crates/toolchain/src/lib.rs
index 9916e52c4..3b6886f5b 100644
--- a/crates/ra_toolchain/src/lib.rs
+++ b/crates/toolchain/src/lib.rs
@@ -1,6 +1,4 @@
1//! This crate contains a single public function 1//! Discovery of `cargo` & `rustc` executables.
2//! [`get_path_for_executable`](fn.get_path_for_executable.html).
3//! See docs there for more information.
4use std::{env, iter, path::PathBuf}; 2use std::{env, iter, path::PathBuf};
5 3
6pub fn cargo() -> PathBuf { 4pub fn cargo() -> PathBuf {
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index 80a7915e9..a5dc3cf0c 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -121,12 +121,12 @@ export class Cargo {
121 } 121 }
122} 122}
123 123
124/** Mirrors `ra_toolchain::cargo()` implementation */ 124/** Mirrors `toolchain::cargo()` implementation */
125export function cargoPath(): string { 125export function cargoPath(): string {
126 return getPathForExecutable("cargo"); 126 return getPathForExecutable("cargo");
127} 127}
128 128
129/** Mirrors `ra_toolchain::get_path_for_executable()` implementation */ 129/** Mirrors `toolchain::get_path_for_executable()` implementation */
130export const getPathForExecutable = memoize( 130export const getPathForExecutable = memoize(
131 // We apply caching to decrease file-system interactions 131 // We apply caching to decrease file-system interactions
132 (executableName: "cargo" | "rustc" | "rustup"): string => { 132 (executableName: "cargo" | "rustc" | "rustup"): string => {