aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock94
-rw-r--r--crates/ra_batch/Cargo.toml4
-rw-r--r--crates/ra_cli/Cargo.toml5
-rw-r--r--docs/dev/README.md19
-rw-r--r--editors/code/.vscode/launch.json1
-rw-r--r--editors/code/package.json1
-rw-r--r--editors/code/src/commands/cargo_watch.ts66
-rw-r--r--editors/code/src/test/fixtures/rust-diagnostics/clippy/trivially_copy_pass_by_ref.json110
-rw-r--r--editors/code/src/test/fixtures/rust-diagnostics/error/E0053.json42
-rw-r--r--editors/code/src/test/fixtures/rust-diagnostics/error/E0061.json114
-rw-r--r--editors/code/src/test/fixtures/rust-diagnostics/warning/unused_variables.json72
-rw-r--r--editors/code/src/test/index.ts22
-rw-r--r--editors/code/src/test/rust_diagnostics.test.ts161
-rw-r--r--editors/code/src/test/vscode_diagnostics.test.ts164
-rw-r--r--editors/code/src/utils/vscode_diagnostics.ts73
15 files changed, 835 insertions, 113 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4f3538a51..33e6a4f3d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -55,7 +55,7 @@ dependencies = [
55 55
56[[package]] 56[[package]]
57name = "backtrace" 57name = "backtrace"
58version = "0.3.30" 58version = "0.3.31"
59source = "registry+https://github.com/rust-lang/crates.io-index" 59source = "registry+https://github.com/rust-lang/crates.io-index"
60dependencies = [ 60dependencies = [
61 "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 61 "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -108,7 +108,7 @@ dependencies = [
108 "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 108 "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
109 "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 109 "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
110 "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 110 "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
111 "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 111 "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
112] 112]
113 113
114[[package]] 114[[package]]
@@ -136,8 +136,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
136dependencies = [ 136dependencies = [
137 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 137 "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
138 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 138 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
139 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 139 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
140 "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 140 "serde_derive 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
141 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 141 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
142] 142]
143 143
@@ -208,12 +208,13 @@ dependencies = [
208 208
209[[package]] 209[[package]]
210name = "chrono" 210name = "chrono"
211version = "0.4.6" 211version = "0.4.7"
212source = "registry+https://github.com/rust-lang/crates.io-index" 212source = "registry+https://github.com/rust-lang/crates.io-index"
213dependencies = [ 213dependencies = [
214 "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
214 "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 215 "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
215 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 216 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
216 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 217 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
217 "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", 218 "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
218] 219]
219 220
@@ -350,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
350dependencies = [ 351dependencies = [
351 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 352 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
352 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 353 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
353 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 354 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
354] 355]
355 356
356[[package]] 357[[package]]
@@ -368,7 +369,7 @@ name = "digest"
368version = "0.8.0" 369version = "0.8.0"
369source = "registry+https://github.com/rust-lang/crates.io-index" 370source = "registry+https://github.com/rust-lang/crates.io-index"
370dependencies = [ 371dependencies = [
371 "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 372 "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
372] 373]
373 374
374[[package]] 375[[package]]
@@ -420,7 +421,7 @@ name = "error-chain"
420version = "0.12.1" 421version = "0.12.1"
421source = "registry+https://github.com/rust-lang/crates.io-index" 422source = "registry+https://github.com/rust-lang/crates.io-index"
422dependencies = [ 423dependencies = [
423 "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", 424 "backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)",
424 "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 425 "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
425] 426]
426 427
@@ -429,7 +430,7 @@ name = "failure"
429version = "0.1.5" 430version = "0.1.5"
430source = "registry+https://github.com/rust-lang/crates.io-index" 431source = "registry+https://github.com/rust-lang/crates.io-index"
431dependencies = [ 432dependencies = [
432 "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", 433 "backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)",
433 "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 434 "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
434] 435]
435 436
@@ -440,7 +441,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
440dependencies = [ 441dependencies = [
441 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 442 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
442 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 443 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
443 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 444 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
444 "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", 445 "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
445] 446]
446 447
@@ -469,7 +470,7 @@ name = "flexi_logger"
469version = "0.13.2" 470version = "0.13.2"
470source = "registry+https://github.com/rust-lang/crates.io-index" 471source = "registry+https://github.com/rust-lang/crates.io-index"
471dependencies = [ 472dependencies = [
472 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 473 "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
473 "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 474 "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
474 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 475 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
475 "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", 476 "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -533,13 +534,13 @@ dependencies = [
533 "flexi_logger 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", 534 "flexi_logger 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
534 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 535 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
535 "lsp-types 0.57.2 (registry+https://github.com/rust-lang/crates.io-index)", 536 "lsp-types 0.57.2 (registry+https://github.com/rust-lang/crates.io-index)",
536 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 537 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
537 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 538 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
538] 539]
539 540
540[[package]] 541[[package]]
541name = "generic-array" 542name = "generic-array"
542version = "0.12.0" 543version = "0.12.3"
543source = "registry+https://github.com/rust-lang/crates.io-index" 544source = "registry+https://github.com/rust-lang/crates.io-index"
544dependencies = [ 545dependencies = [
545 "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 546 "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -618,7 +619,7 @@ name = "insta"
618version = "0.8.1" 619version = "0.8.1"
619source = "registry+https://github.com/rust-lang/crates.io-index" 620source = "registry+https://github.com/rust-lang/crates.io-index"
620dependencies = [ 621dependencies = [
621 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 622 "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
622 "ci_info 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 623 "ci_info 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
623 "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", 624 "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
624 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 625 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -627,7 +628,7 @@ dependencies = [
627 "pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 628 "pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
628 "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 629 "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
629 "ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 630 "ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
630 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 631 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
631 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 632 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
632 "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", 633 "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)",
633 "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", 634 "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -759,8 +760,8 @@ dependencies = [
759 "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 760 "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
760 "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", 761 "num-derive 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
761 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 762 "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
762 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 763 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
763 "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 764 "serde_derive 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
764 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 765 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
765 "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 766 "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
766 "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 767 "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -865,7 +866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
865dependencies = [ 866dependencies = [
866 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 867 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
867 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 868 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
868 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 869 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
869] 870]
870 871
871[[package]] 872[[package]]
@@ -981,7 +982,7 @@ dependencies = [
981 "pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 982 "pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
982 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 983 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
983 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 984 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
984 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 985 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
985] 986]
986 987
987[[package]] 988[[package]]
@@ -1069,7 +1070,6 @@ dependencies = [
1069 "ra_db 0.1.0", 1070 "ra_db 0.1.0",
1070 "ra_hir 0.1.0", 1071 "ra_hir 0.1.0",
1071 "ra_ide_api 0.1.0", 1072 "ra_ide_api 0.1.0",
1072 "ra_prof 0.1.0",
1073 "ra_project_model 0.1.0", 1073 "ra_project_model 0.1.0",
1074 "ra_syntax 0.1.0", 1074 "ra_syntax 0.1.0",
1075 "ra_vfs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", 1075 "ra_vfs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1188,7 +1188,7 @@ dependencies = [
1188 "ra_vfs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", 1188 "ra_vfs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
1189 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 1189 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1190 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1190 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1191 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1191 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1192 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 1192 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
1193 "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 1193 "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
1194 "test_utils 0.1.0", 1194 "test_utils 0.1.0",
@@ -1221,7 +1221,7 @@ dependencies = [
1221name = "ra_prof" 1221name = "ra_prof"
1222version = "0.1.0" 1222version = "0.1.0"
1223dependencies = [ 1223dependencies = [
1224 "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", 1224 "backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)",
1225 "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 1225 "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
1226 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 1226 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1227 "once_cell 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 1227 "once_cell 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1237,7 +1237,7 @@ dependencies = [
1237 "ra_db 0.1.0", 1237 "ra_db 0.1.0",
1238 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 1238 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1239 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1239 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1240 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1240 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1241 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 1241 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
1242 "test_utils 0.1.0", 1242 "test_utils 0.1.0",
1243 "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 1243 "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1479,7 +1479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1479dependencies = [ 1479dependencies = [
1480 "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", 1480 "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
1481 "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1481 "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1482 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1482 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1483] 1483]
1484 1484
1485[[package]] 1485[[package]]
@@ -1543,7 +1543,7 @@ dependencies = [
1543 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1543 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1544 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 1544 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
1545 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 1545 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
1546 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 1546 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
1547] 1547]
1548 1548
1549[[package]] 1549[[package]]
@@ -1570,7 +1570,7 @@ version = "0.9.0"
1570source = "registry+https://github.com/rust-lang/crates.io-index" 1570source = "registry+https://github.com/rust-lang/crates.io-index"
1571dependencies = [ 1571dependencies = [
1572 "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 1572 "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
1573 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1573 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1574] 1574]
1575 1575
1576[[package]] 1576[[package]]
@@ -1580,20 +1580,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1580 1580
1581[[package]] 1581[[package]]
1582name = "serde" 1582name = "serde"
1583version = "1.0.92" 1583version = "1.0.93"
1584source = "registry+https://github.com/rust-lang/crates.io-index" 1584source = "registry+https://github.com/rust-lang/crates.io-index"
1585dependencies = [ 1585dependencies = [
1586 "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1586 "serde_derive 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1587] 1587]
1588 1588
1589[[package]] 1589[[package]]
1590name = "serde_derive" 1590name = "serde_derive"
1591version = "1.0.92" 1591version = "1.0.93"
1592source = "registry+https://github.com/rust-lang/crates.io-index" 1592source = "registry+https://github.com/rust-lang/crates.io-index"
1593dependencies = [ 1593dependencies = [
1594 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 1594 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
1595 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 1595 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
1596 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 1596 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
1597] 1597]
1598 1598
1599[[package]] 1599[[package]]
@@ -1603,7 +1603,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1603dependencies = [ 1603dependencies = [
1604 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 1604 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
1605 "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 1605 "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
1606 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1606 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1607] 1607]
1608 1608
1609[[package]] 1609[[package]]
@@ -1613,7 +1613,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1613dependencies = [ 1613dependencies = [
1614 "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 1614 "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
1615 "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 1615 "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
1616 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1616 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1617 "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 1617 "yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
1618] 1618]
1619 1619
@@ -1651,7 +1651,7 @@ name = "smol_str"
1651version = "0.1.11" 1651version = "0.1.11"
1652source = "registry+https://github.com/rust-lang/crates.io-index" 1652source = "registry+https://github.com/rust-lang/crates.io-index"
1653dependencies = [ 1653dependencies = [
1654 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1654 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1655] 1655]
1656 1656
1657[[package]] 1657[[package]]
@@ -1677,7 +1677,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1677 1677
1678[[package]] 1678[[package]]
1679name = "syn" 1679name = "syn"
1680version = "0.15.36" 1680version = "0.15.38"
1681source = "registry+https://github.com/rust-lang/crates.io-index" 1681source = "registry+https://github.com/rust-lang/crates.io-index"
1682dependencies = [ 1682dependencies = [
1683 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 1683 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1692,7 +1692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1692dependencies = [ 1692dependencies = [
1693 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", 1693 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
1694 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", 1694 "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
1695 "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", 1695 "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)",
1696 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1696 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1697] 1697]
1698 1698
@@ -1714,7 +1714,7 @@ name = "tera"
1714version = "0.11.20" 1714version = "0.11.20"
1715source = "registry+https://github.com/rust-lang/crates.io-index" 1715source = "registry+https://github.com/rust-lang/crates.io-index"
1716dependencies = [ 1716dependencies = [
1717 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 1717 "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
1718 "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", 1718 "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
1719 "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", 1719 "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
1720 "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1720 "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1722,7 +1722,7 @@ dependencies = [
1722 "pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 1722 "pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1723 "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1723 "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1724 "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", 1724 "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
1725 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1725 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1726 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", 1726 "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
1727 "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 1727 "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
1728 "unic-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 1728 "unic-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1773,7 +1773,7 @@ name = "text_unit"
1773version = "0.1.9" 1773version = "0.1.9"
1774source = "registry+https://github.com/rust-lang/crates.io-index" 1774source = "registry+https://github.com/rust-lang/crates.io-index"
1775dependencies = [ 1775dependencies = [
1776 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1776 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1777] 1777]
1778 1778
1779[[package]] 1779[[package]]
@@ -1931,7 +1931,7 @@ name = "url_serde"
1931version = "0.2.0" 1931version = "0.2.0"
1932source = "registry+https://github.com/rust-lang/crates.io-index" 1932source = "registry+https://github.com/rust-lang/crates.io-index"
1933dependencies = [ 1933dependencies = [
1934 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1934 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1935 "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 1935 "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
1936] 1936]
1937 1937
@@ -1946,7 +1946,7 @@ version = "0.7.4"
1946source = "registry+https://github.com/rust-lang/crates.io-index" 1946source = "registry+https://github.com/rust-lang/crates.io-index"
1947dependencies = [ 1947dependencies = [
1948 "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", 1948 "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
1949 "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", 1949 "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)",
1950] 1950]
1951 1951
1952[[package]] 1952[[package]]
@@ -2035,7 +2035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2035"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" 2035"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
2036"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" 2036"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf"
2037"checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f" 2037"checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f"
2038"checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" 2038"checksum backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "e0f77aa27f55a4beb477ff6bc4d9bf72f90eb422b19c1d8e5a644b8aeb674d66"
2039"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" 2039"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
2040"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" 2040"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
2041"checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" 2041"checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
@@ -2053,7 +2053,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2053"checksum chalk-macros 0.1.1 (git+https://github.com/flodiebold/chalk.git?branch=fuel)" = "<none>" 2053"checksum chalk-macros 0.1.1 (git+https://github.com/flodiebold/chalk.git?branch=fuel)" = "<none>"
2054"checksum chalk-rust-ir 0.1.0 (git+https://github.com/flodiebold/chalk.git?branch=fuel)" = "<none>" 2054"checksum chalk-rust-ir 0.1.0 (git+https://github.com/flodiebold/chalk.git?branch=fuel)" = "<none>"
2055"checksum chalk-solve 0.1.0 (git+https://github.com/flodiebold/chalk.git?branch=fuel)" = "<none>" 2055"checksum chalk-solve 0.1.0 (git+https://github.com/flodiebold/chalk.git?branch=fuel)" = "<none>"
2056"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" 2056"checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe"
2057"checksum ci_info 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5e881307a989a3a5e20d52a32cc05950e3c2178cccfcc9428271a6cde09f902" 2057"checksum ci_info 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5e881307a989a3a5e20d52a32cc05950e3c2178cccfcc9428271a6cde09f902"
2058"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" 2058"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
2059"checksum clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9" 2059"checksum clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9"
@@ -2092,7 +2092,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2092"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 2092"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
2093"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 2093"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
2094"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 2094"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
2095"checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" 2095"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
2096"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" 2096"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
2097"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" 2097"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
2098"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" 2098"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
@@ -2185,8 +2185,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2185"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" 2185"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
2186"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 2186"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
2187"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 2187"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
2188"checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" 2188"checksum serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)" = "960e29cf7004b3b6e65fc5002981400eb3ccc017a08a2406940823e58e7179a9"
2189"checksum serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" 2189"checksum serde_derive 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)" = "c4cce6663696bd38272e90bf34a0267e1226156c33f52d3f3915a2dd5d802085"
2190"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" 2190"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
2191"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" 2191"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582"
2192"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" 2192"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68"
@@ -2197,7 +2197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2197"checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b" 2197"checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b"
2198"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 2198"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
2199"checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" 2199"checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
2200"checksum syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)" = "8b4f551a91e2e3848aeef8751d0d4eec9489b6474c720fd4c55958d8d31a430c" 2200"checksum syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)" = "37ea458a750f59ab679b47fef9b6722c586c5742f4cfe18a120bbc807e5e01fd"
2201"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" 2201"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
2202"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" 2202"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef"
2203"checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" 2203"checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3"
diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml
index f521937c5..7d8837fc3 100644
--- a/crates/ra_batch/Cargo.toml
+++ b/crates/ra_batch/Cargo.toml
@@ -15,9 +15,5 @@ ra_ide_api = { path = "../ra_ide_api" }
15ra_hir = { path = "../ra_hir" } 15ra_hir = { path = "../ra_hir" }
16ra_project_model = { path = "../ra_project_model" } 16ra_project_model = { path = "../ra_project_model" }
17 17
18[dependencies.ra_prof]
19path = "../ra_prof"
20# features = [ "cpuprofiler" ]
21
22[dev-dependencies] 18[dev-dependencies]
23test_utils = { path = "../test_utils" } 19test_utils = { path = "../test_utils" }
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
index 301145b5d..b10873cd8 100644
--- a/crates/ra_cli/Cargo.toml
+++ b/crates/ra_cli/Cargo.toml
@@ -16,4 +16,7 @@ ra_ide_api = { path = "../ra_ide_api" }
16ra_batch = { path = "../ra_batch" } 16ra_batch = { path = "../ra_batch" }
17ra_hir = { path = "../ra_hir" } 17ra_hir = { path = "../ra_hir" }
18ra_db = { path = "../ra_db" } 18ra_db = { path = "../ra_db" }
19ra_prof = { path = "../ra_prof" } 19
20[dependencies.ra_prof]
21path = "../ra_prof"
22# features = [ "cpuprofiler" ]
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 3dc37e86e..0a148ed32 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -97,6 +97,25 @@ To work on the VS Code extension, launch code inside `editors/code` and use `F5`
97to launch/debug. To automatically apply formatter and linter suggestions, use 97to launch/debug. To automatically apply formatter and linter suggestions, use
98`npm run fix`. 98`npm run fix`.
99 99
100Tests are located inside `src/test` and are named `*.test.ts`. They use the
101[Mocha](https://mochajs.org) test framework and the builtin Node
102[assert](https://nodejs.org/api/assert.html) module. Unlike normal Node tests
103they must be hosted inside a VS Code instance. This can be done in one of two
104ways:
105
1061. When `F5` debugging in VS Code select the `Extension Tests` configuration
107 from the drop-down at the top of the Debug View. This will launch a temporary
108 instance of VS Code. The test results will appear in the "Debug Console" tab
109 of the primary VS Code instance.
110
1112. Run `npm test` from the command line. Although this is initiated from the
112 command line it is not headless; it will also launch a temporary instance of
113 VS Code.
114
115Due to the requirements of running the tests inside VS Code they are **not run
116on CI**. When making changes to the extension please ensure the tests are not
117broken locally before opening a Pull Request.
118
100# Logging 119# Logging
101 120
102Logging is done by both rust-analyzer and VS Code, so it might be tricky to 121Logging is done by both rust-analyzer and VS Code, so it might be tricky to
diff --git a/editors/code/.vscode/launch.json b/editors/code/.vscode/launch.json
index b9d14dddd..c3578f476 100644
--- a/editors/code/.vscode/launch.json
+++ b/editors/code/.vscode/launch.json
@@ -20,6 +20,7 @@
20 "request": "launch", 20 "request": "launch",
21 "runtimeExecutable": "${execPath}", 21 "runtimeExecutable": "${execPath}",
22 "args": [ 22 "args": [
23 "${workspaceFolder}/src/test/",
23 "--extensionDevelopmentPath=${workspaceFolder}", 24 "--extensionDevelopmentPath=${workspaceFolder}",
24 "--extensionTestsPath=${workspaceFolder}/out/test" 25 "--extensionTestsPath=${workspaceFolder}/out/test"
25 ], 26 ],
diff --git a/editors/code/package.json b/editors/code/package.json
index ac2ba82e3..6e2dd0494 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -23,6 +23,7 @@
23 "postinstall": "node ./node_modules/vscode/bin/install", 23 "postinstall": "node ./node_modules/vscode/bin/install",
24 "fix": "prettier **/*.{json,ts} --write && tslint --project . --fix", 24 "fix": "prettier **/*.{json,ts} --write && tslint --project . --fix",
25 "lint": "tslint --project .", 25 "lint": "tslint --project .",
26 "test": "node node_modules/vscode/bin/test",
26 "prettier": "prettier **/*.{json,ts}", 27 "prettier": "prettier **/*.{json,ts}",
27 "travis": "npm run compile && npm run lint && npm run prettier -- --list-different" 28 "travis": "npm run compile && npm run lint && npm run prettier -- --list-different"
28 }, 29 },
diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts
index 126a8b1b3..1ec5f8d5f 100644
--- a/editors/code/src/commands/cargo_watch.ts
+++ b/editors/code/src/commands/cargo_watch.ts
@@ -2,12 +2,17 @@ import * as child_process from 'child_process';
2import * as fs from 'fs'; 2import * as fs from 'fs';
3import * as path from 'path'; 3import * as path from 'path';
4import * as vscode from 'vscode'; 4import * as vscode from 'vscode';
5
5import { Server } from '../server'; 6import { Server } from '../server';
6import { terminate } from '../utils/processes'; 7import { terminate } from '../utils/processes';
7import { 8import {
8 mapRustDiagnosticToVsCode, 9 mapRustDiagnosticToVsCode,
9 RustDiagnostic 10 RustDiagnostic
10} from '../utils/rust_diagnostics'; 11} from '../utils/rust_diagnostics';
12import {
13 areCodeActionsEqual,
14 areDiagnosticsEqual
15} from '../utils/vscode_diagnostics';
11import { LineBuffer } from './line_buffer'; 16import { LineBuffer } from './line_buffer';
12import { StatusDisplay } from './watch_status'; 17import { StatusDisplay } from './watch_status';
13 18
@@ -184,67 +189,6 @@ export class CargoWatchProvider
184 this.statusDisplay.hide(); 189 this.statusDisplay.hide();
185 } 190 }
186 191
187 function areDiagnosticsEqual(
188 left: vscode.Diagnostic,
189 right: vscode.Diagnostic
190 ): boolean {
191 return (
192 left.source === right.source &&
193 left.severity === right.severity &&
194 left.range.isEqual(right.range) &&
195 left.message === right.message
196 );
197 }
198
199 function areCodeActionsEqual(
200 left: vscode.CodeAction,
201 right: vscode.CodeAction
202 ): boolean {
203 if (
204 left.kind !== right.kind ||
205 left.title !== right.title ||
206 !left.edit ||
207 !right.edit
208 ) {
209 return false;
210 }
211
212 const leftEditEntries = left.edit.entries();
213 const rightEditEntries = right.edit.entries();
214
215 if (leftEditEntries.length !== rightEditEntries.length) {
216 return false;
217 }
218
219 for (let i = 0; i < leftEditEntries.length; i++) {
220 const [leftUri, leftEdits] = leftEditEntries[i];
221 const [rightUri, rightEdits] = rightEditEntries[i];
222
223 if (leftUri.toString() !== rightUri.toString()) {
224 return false;
225 }
226
227 if (leftEdits.length !== rightEdits.length) {
228 return false;
229 }
230
231 for (let j = 0; j < leftEdits.length; j++) {
232 const leftEdit = leftEdits[j];
233 const rightEdit = rightEdits[j];
234
235 if (!leftEdit.range.isEqual(rightEdit.range)) {
236 return false;
237 }
238
239 if (leftEdit.newText !== rightEdit.newText) {
240 return false;
241 }
242 }
243 }
244
245 return true;
246 }
247
248 interface CargoArtifact { 192 interface CargoArtifact {
249 reason: string; 193 reason: string;
250 package_id: string; 194 package_id: string;
diff --git a/editors/code/src/test/fixtures/rust-diagnostics/clippy/trivially_copy_pass_by_ref.json b/editors/code/src/test/fixtures/rust-diagnostics/clippy/trivially_copy_pass_by_ref.json
new file mode 100644
index 000000000..d874e99bc
--- /dev/null
+++ b/editors/code/src/test/fixtures/rust-diagnostics/clippy/trivially_copy_pass_by_ref.json
@@ -0,0 +1,110 @@
1{
2 "message": "this argument is passed by reference, but would be more efficient if passed by value",
3 "code": {
4 "code": "clippy::trivially_copy_pass_by_ref",
5 "explanation": null
6 },
7 "level": "warning",
8 "spans": [
9 {
10 "file_name": "compiler/mir/tagset.rs",
11 "byte_start": 941,
12 "byte_end": 946,
13 "line_start": 42,
14 "line_end": 42,
15 "column_start": 24,
16 "column_end": 29,
17 "is_primary": true,
18 "text": [
19 {
20 "text": " pub fn is_disjoint(&self, other: Self) -> bool {",
21 "highlight_start": 24,
22 "highlight_end": 29
23 }
24 ],
25 "label": null,
26 "suggested_replacement": null,
27 "suggestion_applicability": null,
28 "expansion": null
29 }
30 ],
31 "children": [
32 {
33 "message": "lint level defined here",
34 "code": null,
35 "level": "note",
36 "spans": [
37 {
38 "file_name": "compiler/lib.rs",
39 "byte_start": 8,
40 "byte_end": 19,
41 "line_start": 1,
42 "line_end": 1,
43 "column_start": 9,
44 "column_end": 20,
45 "is_primary": true,
46 "text": [
47 {
48 "text": "#![warn(clippy::all)]",
49 "highlight_start": 9,
50 "highlight_end": 20
51 }
52 ],
53 "label": null,
54 "suggested_replacement": null,
55 "suggestion_applicability": null,
56 "expansion": null
57 }
58 ],
59 "children": [],
60 "rendered": null
61 },
62 {
63 "message": "#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]",
64 "code": null,
65 "level": "note",
66 "spans": [],
67 "children": [],
68 "rendered": null
69 },
70 {
71 "message": "for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref",
72 "code": null,
73 "level": "help",
74 "spans": [],
75 "children": [],
76 "rendered": null
77 },
78 {
79 "message": "consider passing by value instead",
80 "code": null,
81 "level": "help",
82 "spans": [
83 {
84 "file_name": "compiler/mir/tagset.rs",
85 "byte_start": 941,
86 "byte_end": 946,
87 "line_start": 42,
88 "line_end": 42,
89 "column_start": 24,
90 "column_end": 29,
91 "is_primary": true,
92 "text": [
93 {
94 "text": " pub fn is_disjoint(&self, other: Self) -> bool {",
95 "highlight_start": 24,
96 "highlight_end": 29
97 }
98 ],
99 "label": null,
100 "suggested_replacement": "self",
101 "suggestion_applicability": "Unspecified",
102 "expansion": null
103 }
104 ],
105 "children": [],
106 "rendered": null
107 }
108 ],
109 "rendered": "warning: this argument is passed by reference, but would be more efficient if passed by value\n --> compiler/mir/tagset.rs:42:24\n |\n42 | pub fn is_disjoint(&self, other: Self) -> bool {\n | ^^^^^ help: consider passing by value instead: `self`\n |\nnote: lint level defined here\n --> compiler/lib.rs:1:9\n |\n1 | #![warn(clippy::all)]\n | ^^^^^^^^^^^\n = note: #[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref\n\n"
110}
diff --git a/editors/code/src/test/fixtures/rust-diagnostics/error/E0053.json b/editors/code/src/test/fixtures/rust-diagnostics/error/E0053.json
new file mode 100644
index 000000000..ea5c976d1
--- /dev/null
+++ b/editors/code/src/test/fixtures/rust-diagnostics/error/E0053.json
@@ -0,0 +1,42 @@
1{
2 "message": "method `next` has an incompatible type for trait",
3 "code": {
4 "code": "E0053",
5 "explanation": "\nThe parameters of any trait method must match between a trait implementation\nand the trait definition.\n\nHere are a couple examples of this error:\n\n```compile_fail,E0053\ntrait Foo {\n fn foo(x: u16);\n fn bar(&self);\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n // error, expected u16, found i16\n fn foo(x: i16) { }\n\n // error, types differ in mutability\n fn bar(&mut self) { }\n}\n```\n"
6 },
7 "level": "error",
8 "spans": [
9 {
10 "file_name": "compiler/ty/list_iter.rs",
11 "byte_start": 1307,
12 "byte_end": 1350,
13 "line_start": 52,
14 "line_end": 52,
15 "column_start": 5,
16 "column_end": 48,
17 "is_primary": true,
18 "text": [
19 {
20 "text": " fn next(&self) -> Option<&'list ty::Ref<M>> {",
21 "highlight_start": 5,
22 "highlight_end": 48
23 }
24 ],
25 "label": "types differ in mutability",
26 "suggested_replacement": null,
27 "suggestion_applicability": null,
28 "expansion": null
29 }
30 ],
31 "children": [
32 {
33 "message": "expected type `fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref<M>>`\n found type `fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>`",
34 "code": null,
35 "level": "note",
36 "spans": [],
37 "children": [],
38 "rendered": null
39 }
40 ],
41 "rendered": "error[E0053]: method `next` has an incompatible type for trait\n --> compiler/ty/list_iter.rs:52:5\n |\n52 | fn next(&self) -> Option<&'list ty::Ref<M>> {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability\n |\n = note: expected type `fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref<M>>`\n found type `fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>`\n\n"
42}
diff --git a/editors/code/src/test/fixtures/rust-diagnostics/error/E0061.json b/editors/code/src/test/fixtures/rust-diagnostics/error/E0061.json
new file mode 100644
index 000000000..3154d1098
--- /dev/null
+++ b/editors/code/src/test/fixtures/rust-diagnostics/error/E0061.json
@@ -0,0 +1,114 @@
1{
2 "message": "this function takes 2 parameters but 3 parameters were supplied",
3 "code": {
4 "code": "E0061",
5 "explanation": "\nThe number of arguments passed to a function must match the number of arguments\nspecified in the function signature.\n\nFor example, a function like:\n\n```\nfn f(a: u16, b: &str) {}\n```\n\nMust always be called with exactly two arguments, e.g., `f(2, \"test\")`.\n\nNote that Rust does not have a notion of optional function arguments or\nvariadic functions (except for its C-FFI).\n"
6 },
7 "level": "error",
8 "spans": [
9 {
10 "file_name": "compiler/ty/select.rs",
11 "byte_start": 8787,
12 "byte_end": 9241,
13 "line_start": 219,
14 "line_end": 231,
15 "column_start": 5,
16 "column_end": 6,
17 "is_primary": false,
18 "text": [
19 {
20 "text": " pub fn add_evidence(",
21 "highlight_start": 5,
22 "highlight_end": 25
23 },
24 {
25 "text": " &mut self,",
26 "highlight_start": 1,
27 "highlight_end": 19
28 },
29 {
30 "text": " target_poly: &ty::Ref<ty::Poly>,",
31 "highlight_start": 1,
32 "highlight_end": 41
33 },
34 {
35 "text": " evidence_poly: &ty::Ref<ty::Poly>,",
36 "highlight_start": 1,
37 "highlight_end": 43
38 },
39 {
40 "text": " ) {",
41 "highlight_start": 1,
42 "highlight_end": 8
43 },
44 {
45 "text": " match target_poly {",
46 "highlight_start": 1,
47 "highlight_end": 28
48 },
49 {
50 "text": " ty::Ref::Var(tvar, _) => self.add_var_evidence(tvar, evidence_poly),",
51 "highlight_start": 1,
52 "highlight_end": 81
53 },
54 {
55 "text": " ty::Ref::Fixed(target_ty) => {",
56 "highlight_start": 1,
57 "highlight_end": 43
58 },
59 {
60 "text": " let evidence_ty = evidence_poly.resolve_to_ty();",
61 "highlight_start": 1,
62 "highlight_end": 65
63 },
64 {
65 "text": " self.add_evidence_ty(target_ty, evidence_poly, evidence_ty)",
66 "highlight_start": 1,
67 "highlight_end": 76
68 },
69 {
70 "text": " }",
71 "highlight_start": 1,
72 "highlight_end": 14
73 },
74 {
75 "text": " }",
76 "highlight_start": 1,
77 "highlight_end": 10
78 },
79 {
80 "text": " }",
81 "highlight_start": 1,
82 "highlight_end": 6
83 }
84 ],
85 "label": "defined here",
86 "suggested_replacement": null,
87 "suggestion_applicability": null,
88 "expansion": null
89 },
90 {
91 "file_name": "compiler/ty/select.rs",
92 "byte_start": 4045,
93 "byte_end": 4057,
94 "line_start": 104,
95 "line_end": 104,
96 "column_start": 18,
97 "column_end": 30,
98 "is_primary": true,
99 "text": [
100 {
101 "text": " self.add_evidence(target_fixed, evidence_fixed, false);",
102 "highlight_start": 18,
103 "highlight_end": 30
104 }
105 ],
106 "label": "expected 2 parameters",
107 "suggested_replacement": null,
108 "suggestion_applicability": null,
109 "expansion": null
110 }
111 ],
112 "children": [],
113 "rendered": "error[E0061]: this function takes 2 parameters but 3 parameters were supplied\n --> compiler/ty/select.rs:104:18\n |\n104 | self.add_evidence(target_fixed, evidence_fixed, false);\n | ^^^^^^^^^^^^ expected 2 parameters\n...\n219 | / pub fn add_evidence(\n220 | | &mut self,\n221 | | target_poly: &ty::Ref<ty::Poly>,\n222 | | evidence_poly: &ty::Ref<ty::Poly>,\n... |\n230 | | }\n231 | | }\n | |_____- defined here\n\n"
114}
diff --git a/editors/code/src/test/fixtures/rust-diagnostics/warning/unused_variables.json b/editors/code/src/test/fixtures/rust-diagnostics/warning/unused_variables.json
new file mode 100644
index 000000000..d1e2be722
--- /dev/null
+++ b/editors/code/src/test/fixtures/rust-diagnostics/warning/unused_variables.json
@@ -0,0 +1,72 @@
1{
2 "message": "unused variable: `foo`",
3 "code": {
4 "code": "unused_variables",
5 "explanation": null
6 },
7 "level": "warning",
8 "spans": [
9 {
10 "file_name": "driver/subcommand/repl.rs",
11 "byte_start": 9228,
12 "byte_end": 9231,
13 "line_start": 291,
14 "line_end": 291,
15 "column_start": 9,
16 "column_end": 12,
17 "is_primary": true,
18 "text": [
19 {
20 "text": " let foo = 42;",
21 "highlight_start": 9,
22 "highlight_end": 12
23 }
24 ],
25 "label": null,
26 "suggested_replacement": null,
27 "suggestion_applicability": null,
28 "expansion": null
29 }
30 ],
31 "children": [
32 {
33 "message": "#[warn(unused_variables)] on by default",
34 "code": null,
35 "level": "note",
36 "spans": [],
37 "children": [],
38 "rendered": null
39 },
40 {
41 "message": "consider prefixing with an underscore",
42 "code": null,
43 "level": "help",
44 "spans": [
45 {
46 "file_name": "driver/subcommand/repl.rs",
47 "byte_start": 9228,
48 "byte_end": 9231,
49 "line_start": 291,
50 "line_end": 291,
51 "column_start": 9,
52 "column_end": 12,
53 "is_primary": true,
54 "text": [
55 {
56 "text": " let foo = 42;",
57 "highlight_start": 9,
58 "highlight_end": 12
59 }
60 ],
61 "label": null,
62 "suggested_replacement": "_foo",
63 "suggestion_applicability": "MachineApplicable",
64 "expansion": null
65 }
66 ],
67 "children": [],
68 "rendered": null
69 }
70 ],
71 "rendered": "warning: unused variable: `foo`\n --> driver/subcommand/repl.rs:291:9\n |\n291 | let foo = 42;\n | ^^^ help: consider prefixing with an underscore: `_foo`\n |\n = note: #[warn(unused_variables)] on by default\n\n"
72}
diff --git a/editors/code/src/test/index.ts b/editors/code/src/test/index.ts
new file mode 100644
index 000000000..6e565c254
--- /dev/null
+++ b/editors/code/src/test/index.ts
@@ -0,0 +1,22 @@
1//
2// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3//
4// This file is providing the test runner to use when running extension tests.
5// By default the test runner in use is Mocha based.
6//
7// You can provide your own test runner if you want to override it by exporting
8// a function run(testRoot: string, clb: (error:Error) => void) that the extension
9// host can call to run the tests. The test runner is expected to use console.log
10// to report the results back to the caller. When the tests are finished, return
11// a possible error to the callback or null if none.
12
13import * as testRunner from 'vscode/lib/testrunner';
14
15// You can directly control Mocha options by uncommenting the following lines
16// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17testRunner.configure({
18 ui: 'bdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
19 useColors: true // colored output from test results
20});
21
22module.exports = testRunner;
diff --git a/editors/code/src/test/rust_diagnostics.test.ts b/editors/code/src/test/rust_diagnostics.test.ts
new file mode 100644
index 000000000..5eb064b97
--- /dev/null
+++ b/editors/code/src/test/rust_diagnostics.test.ts
@@ -0,0 +1,161 @@
1import * as assert from 'assert';
2import * as fs from 'fs';
3import * as vscode from 'vscode';
4
5import {
6 MappedRustDiagnostic,
7 mapRustDiagnosticToVsCode,
8 RustDiagnostic
9} from '../utils/rust_diagnostics';
10
11function loadDiagnosticFixture(name: string): RustDiagnostic {
12 const jsonText = fs
13 .readFileSync(
14 // We're actually in our JavaScript output directory, climb out
15 `${__dirname}/../../src/test/fixtures/rust-diagnostics/${name}.json`
16 )
17 .toString();
18
19 return JSON.parse(jsonText);
20}
21
22function mapFixtureToVsCode(name: string): MappedRustDiagnostic {
23 const rd = loadDiagnosticFixture(name);
24 const mapResult = mapRustDiagnosticToVsCode(rd);
25
26 if (!mapResult) {
27 return assert.fail('Mapping unexpectedly failed');
28 }
29 return mapResult;
30}
31
32describe('mapRustDiagnosticToVsCode', () => {
33 it('should map an incompatible type for trait error', () => {
34 const { diagnostic, codeActions } = mapFixtureToVsCode('error/E0053');
35
36 assert.strictEqual(
37 diagnostic.severity,
38 vscode.DiagnosticSeverity.Error
39 );
40 assert.strictEqual(
41 diagnostic.message,
42 [
43 `method \`next\` has an incompatible type for trait`,
44 `expected type \`fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref<M>>\``,
45 ` found type \`fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>\``
46 ].join('\n')
47 );
48 assert.strictEqual(diagnostic.code, 'E0053');
49 assert.strictEqual(diagnostic.tags, undefined);
50
51 // No related information
52 assert.deepStrictEqual(diagnostic.relatedInformation, []);
53
54 // There are no code actions available
55 assert.strictEqual(codeActions.length, 0);
56 });
57
58 it('should map an unused variable warning', () => {
59 const { diagnostic, codeActions } = mapFixtureToVsCode(
60 'warning/unused_variables'
61 );
62
63 assert.strictEqual(
64 diagnostic.severity,
65 vscode.DiagnosticSeverity.Warning
66 );
67 assert.strictEqual(
68 diagnostic.message,
69 [
70 'unused variable: `foo`',
71 '#[warn(unused_variables)] on by default'
72 ].join('\n')
73 );
74 assert.strictEqual(diagnostic.code, 'unused_variables');
75 assert.deepStrictEqual(diagnostic.tags, [
76 vscode.DiagnosticTag.Unnecessary
77 ]);
78
79 // No related information
80 assert.deepStrictEqual(diagnostic.relatedInformation, []);
81
82 // One code action available to prefix the variable
83 assert.strictEqual(codeActions.length, 1);
84 const [codeAction] = codeActions;
85 assert.strictEqual(
86 codeAction.title,
87 'consider prefixing with an underscore: `_foo`'
88 );
89 assert(codeAction.isPreferred);
90 });
91
92 it('should map a wrong number of parameters error', () => {
93 const { diagnostic, codeActions } = mapFixtureToVsCode('error/E0061');
94
95 assert.strictEqual(
96 diagnostic.severity,
97 vscode.DiagnosticSeverity.Error
98 );
99 assert.strictEqual(
100 diagnostic.message,
101 'this function takes 2 parameters but 3 parameters were supplied'
102 );
103 assert.strictEqual(diagnostic.code, 'E0061');
104 assert.strictEqual(diagnostic.tags, undefined);
105
106 // One related information for the original definition
107 const relatedInformation = diagnostic.relatedInformation;
108 if (!relatedInformation) {
109 return assert.fail('Related information unexpectedly undefined');
110 }
111 assert.strictEqual(relatedInformation.length, 1);
112 const [related] = relatedInformation;
113 assert.strictEqual(related.message, 'defined here');
114
115 // There are no actions available
116 assert.strictEqual(codeActions.length, 0);
117 });
118
119 it('should map a Clippy copy pass by ref warning', () => {
120 const { diagnostic, codeActions } = mapFixtureToVsCode(
121 'clippy/trivially_copy_pass_by_ref'
122 );
123
124 assert.strictEqual(
125 diagnostic.severity,
126 vscode.DiagnosticSeverity.Warning
127 );
128 assert.strictEqual(
129 diagnostic.message,
130 [
131 'this argument is passed by reference, but would be more efficient if passed by value',
132 '#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]',
133 'for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref'
134 ].join('\n')
135 );
136 assert.strictEqual(
137 diagnostic.code,
138 'clippy::trivially_copy_pass_by_ref'
139 );
140 assert.strictEqual(diagnostic.tags, undefined);
141
142 // One related information for the lint definition
143 const relatedInformation = diagnostic.relatedInformation;
144 if (!relatedInformation) {
145 return assert.fail('Related information unexpectedly undefined');
146 }
147 assert.strictEqual(relatedInformation.length, 1);
148 const [related] = relatedInformation;
149 assert.strictEqual(related.message, 'lint level defined here');
150
151 // One code action available to pass by value
152 assert.strictEqual(codeActions.length, 1);
153 const [codeAction] = codeActions;
154 assert.strictEqual(
155 codeAction.title,
156 'consider passing by value instead: `self`'
157 );
158 // Clippy does not mark this as machine applicable
159 assert.strictEqual(codeAction.isPreferred, false);
160 });
161});
diff --git a/editors/code/src/test/vscode_diagnostics.test.ts b/editors/code/src/test/vscode_diagnostics.test.ts
new file mode 100644
index 000000000..ca4345626
--- /dev/null
+++ b/editors/code/src/test/vscode_diagnostics.test.ts
@@ -0,0 +1,164 @@
1import * as assert from 'assert';
2import * as vscode from 'vscode';
3
4import {
5 areCodeActionsEqual,
6 areDiagnosticsEqual
7} from '../utils/vscode_diagnostics';
8
9const uri = vscode.Uri.file('/file/1');
10
11const range1 = new vscode.Range(
12 new vscode.Position(1, 2),
13 new vscode.Position(3, 4)
14);
15
16const range2 = new vscode.Range(
17 new vscode.Position(5, 6),
18 new vscode.Position(7, 8)
19);
20
21describe('areDiagnosticsEqual', () => {
22 it('should treat identical diagnostics as equal', () => {
23 const diagnostic1 = new vscode.Diagnostic(
24 range1,
25 'Hello, world!',
26 vscode.DiagnosticSeverity.Error
27 );
28
29 const diagnostic2 = new vscode.Diagnostic(
30 range1,
31 'Hello, world!',
32 vscode.DiagnosticSeverity.Error
33 );
34
35 assert(areDiagnosticsEqual(diagnostic1, diagnostic2));
36 });
37
38 it('should treat diagnostics with different ranges as inequal', () => {
39 const diagnostic1 = new vscode.Diagnostic(
40 range1,
41 'Hello, world!',
42 vscode.DiagnosticSeverity.Error
43 );
44
45 const diagnostic2 = new vscode.Diagnostic(
46 range2,
47 'Hello, world!',
48 vscode.DiagnosticSeverity.Error
49 );
50
51 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
52 });
53
54 it('should treat diagnostics with different messages as inequal', () => {
55 const diagnostic1 = new vscode.Diagnostic(
56 range1,
57 'Hello, world!',
58 vscode.DiagnosticSeverity.Error
59 );
60
61 const diagnostic2 = new vscode.Diagnostic(
62 range1,
63 'Goodbye!, world!',
64 vscode.DiagnosticSeverity.Error
65 );
66
67 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
68 });
69
70 it('should treat diagnostics with different severities as inequal', () => {
71 const diagnostic1 = new vscode.Diagnostic(
72 range1,
73 'Hello, world!',
74 vscode.DiagnosticSeverity.Warning
75 );
76
77 const diagnostic2 = new vscode.Diagnostic(
78 range1,
79 'Hello, world!',
80 vscode.DiagnosticSeverity.Error
81 );
82
83 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
84 });
85});
86
87describe('areCodeActionsEqual', () => {
88 it('should treat identical actions as equal', () => {
89 const codeAction1 = new vscode.CodeAction(
90 'Fix me!',
91 vscode.CodeActionKind.QuickFix
92 );
93
94 const codeAction2 = new vscode.CodeAction(
95 'Fix me!',
96 vscode.CodeActionKind.QuickFix
97 );
98
99 const edit = new vscode.WorkspaceEdit();
100 edit.replace(uri, range1, 'Replace with this');
101 codeAction1.edit = edit;
102 codeAction2.edit = edit;
103
104 assert(areCodeActionsEqual(codeAction1, codeAction2));
105 });
106
107 it('should treat actions with different types as inequal', () => {
108 const codeAction1 = new vscode.CodeAction(
109 'Fix me!',
110 vscode.CodeActionKind.Refactor
111 );
112
113 const codeAction2 = new vscode.CodeAction(
114 'Fix me!',
115 vscode.CodeActionKind.QuickFix
116 );
117
118 const edit = new vscode.WorkspaceEdit();
119 edit.replace(uri, range1, 'Replace with this');
120 codeAction1.edit = edit;
121 codeAction2.edit = edit;
122
123 assert(!areCodeActionsEqual(codeAction1, codeAction2));
124 });
125
126 it('should treat actions with different titles as inequal', () => {
127 const codeAction1 = new vscode.CodeAction(
128 'Fix me!',
129 vscode.CodeActionKind.Refactor
130 );
131
132 const codeAction2 = new vscode.CodeAction(
133 'Do something different!',
134 vscode.CodeActionKind.Refactor
135 );
136
137 const edit = new vscode.WorkspaceEdit();
138 edit.replace(uri, range1, 'Replace with this');
139 codeAction1.edit = edit;
140 codeAction2.edit = edit;
141
142 assert(!areCodeActionsEqual(codeAction1, codeAction2));
143 });
144
145 it('should treat actions with different edits as inequal', () => {
146 const codeAction1 = new vscode.CodeAction(
147 'Fix me!',
148 vscode.CodeActionKind.Refactor
149 );
150 const edit1 = new vscode.WorkspaceEdit();
151 edit1.replace(uri, range1, 'Replace with this');
152 codeAction1.edit = edit1;
153
154 const codeAction2 = new vscode.CodeAction(
155 'Fix me!',
156 vscode.CodeActionKind.Refactor
157 );
158 const edit2 = new vscode.WorkspaceEdit();
159 edit2.replace(uri, range1, 'Replace with this other thing');
160 codeAction2.edit = edit2;
161
162 assert(!areCodeActionsEqual(codeAction1, codeAction2));
163 });
164});
diff --git a/editors/code/src/utils/vscode_diagnostics.ts b/editors/code/src/utils/vscode_diagnostics.ts
new file mode 100644
index 000000000..9d763c8d6
--- /dev/null
+++ b/editors/code/src/utils/vscode_diagnostics.ts
@@ -0,0 +1,73 @@
1import * as vscode from 'vscode';
2
3/** Compares two `vscode.Diagnostic`s for equality */
4export function areDiagnosticsEqual(
5 left: vscode.Diagnostic,
6 right: vscode.Diagnostic
7): boolean {
8 return (
9 left.source === right.source &&
10 left.severity === right.severity &&
11 left.range.isEqual(right.range) &&
12 left.message === right.message
13 );
14}
15
16/** Compares two `vscode.TextEdit`s for equality */
17function areTextEditsEqual(
18 left: vscode.TextEdit,
19 right: vscode.TextEdit
20): boolean {
21 if (!left.range.isEqual(right.range)) {
22 return false;
23 }
24
25 if (left.newText !== right.newText) {
26 return false;
27 }
28
29 return true;
30}
31
32/** Compares two `vscode.CodeAction`s for equality */
33export function areCodeActionsEqual(
34 left: vscode.CodeAction,
35 right: vscode.CodeAction
36): boolean {
37 if (
38 left.kind !== right.kind ||
39 left.title !== right.title ||
40 !left.edit ||
41 !right.edit
42 ) {
43 return false;
44 }
45
46 const leftEditEntries = left.edit.entries();
47 const rightEditEntries = right.edit.entries();
48
49 if (leftEditEntries.length !== rightEditEntries.length) {
50 return false;
51 }
52
53 for (let i = 0; i < leftEditEntries.length; i++) {
54 const [leftUri, leftEdits] = leftEditEntries[i];
55 const [rightUri, rightEdits] = rightEditEntries[i];
56
57 if (leftUri.toString() !== rightUri.toString()) {
58 return false;
59 }
60
61 if (leftEdits.length !== rightEdits.length) {
62 return false;
63 }
64
65 for (let j = 0; j < leftEdits.length; j++) {
66 if (!areTextEditsEqual(leftEdits[j], rightEdits[j])) {
67 return false;
68 }
69 }
70 }
71
72 return true;
73}