diff options
-rw-r--r-- | Cargo.lock | 160 | ||||
-rw-r--r-- | crates/assists/src/handlers/auto_import.rs | 3 | ||||
-rw-r--r-- | crates/assists/src/handlers/extract_struct_from_enum_variant.rs | 3 | ||||
-rw-r--r-- | crates/assists/src/handlers/replace_qualified_name_with_use.rs | 2 | ||||
-rw-r--r-- | crates/assists/src/utils.rs | 3 | ||||
-rw-r--r-- | crates/assists/src/utils/insert_use.rs | 14 | ||||
-rw-r--r-- | crates/completion/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/completion/src/completions.rs | 1 | ||||
-rw-r--r-- | crates/completion/src/completions/complete_magic.rs | 114 | ||||
-rw-r--r-- | crates/completion/src/item.rs | 1 | ||||
-rw-r--r-- | crates/completion/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/hir/src/code_model.rs | 10 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ide_db/src/imports_locator.rs | 14 |
14 files changed, 199 insertions, 130 deletions
diff --git a/Cargo.lock b/Cargo.lock index 715a80978..eb4e43ad9 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -2,9 +2,9 @@ | |||
2 | # It is not intended for manual editing. | 2 | # It is not intended for manual editing. |
3 | [[package]] | 3 | [[package]] |
4 | name = "addr2line" | 4 | name = "addr2line" |
5 | version = "0.14.0" | 5 | version = "0.13.0" |
6 | source = "registry+https://github.com/rust-lang/crates.io-index" | 6 | source = "registry+https://github.com/rust-lang/crates.io-index" |
7 | checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" | 7 | checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" |
8 | dependencies = [ | 8 | dependencies = [ |
9 | "gimli", | 9 | "gimli", |
10 | ] | 10 | ] |
@@ -26,9 +26,9 @@ dependencies = [ | |||
26 | 26 | ||
27 | [[package]] | 27 | [[package]] |
28 | name = "anyhow" | 28 | name = "anyhow" |
29 | version = "1.0.34" | 29 | version = "1.0.33" |
30 | source = "registry+https://github.com/rust-lang/crates.io-index" | 30 | source = "registry+https://github.com/rust-lang/crates.io-index" |
31 | checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" | 31 | checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" |
32 | 32 | ||
33 | [[package]] | 33 | [[package]] |
34 | name = "anymap" | 34 | name = "anymap" |
@@ -42,9 +42,9 @@ version = "0.0.0" | |||
42 | 42 | ||
43 | [[package]] | 43 | [[package]] |
44 | name = "arrayvec" | 44 | name = "arrayvec" |
45 | version = "0.5.2" | 45 | version = "0.5.1" |
46 | source = "registry+https://github.com/rust-lang/crates.io-index" | 46 | source = "registry+https://github.com/rust-lang/crates.io-index" |
47 | checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" | 47 | checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" |
48 | 48 | ||
49 | [[package]] | 49 | [[package]] |
50 | name = "assists" | 50 | name = "assists" |
@@ -81,9 +81,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" | |||
81 | 81 | ||
82 | [[package]] | 82 | [[package]] |
83 | name = "backtrace" | 83 | name = "backtrace" |
84 | version = "0.3.54" | 84 | version = "0.3.53" |
85 | source = "registry+https://github.com/rust-lang/crates.io-index" | 85 | source = "registry+https://github.com/rust-lang/crates.io-index" |
86 | checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" | 86 | checksum = "707b586e0e2f247cbde68cdd2c3ce69ea7b7be43e1c5b426e37c9319c4b9838e" |
87 | dependencies = [ | 87 | dependencies = [ |
88 | "addr2line", | 88 | "addr2line", |
89 | "cfg-if 1.0.0", | 89 | "cfg-if 1.0.0", |
@@ -132,7 +132,7 @@ version = "0.12.0" | |||
132 | source = "registry+https://github.com/rust-lang/crates.io-index" | 132 | source = "registry+https://github.com/rust-lang/crates.io-index" |
133 | checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345" | 133 | checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345" |
134 | dependencies = [ | 134 | dependencies = [ |
135 | "semver 0.11.0", | 135 | "semver", |
136 | "serde", | 136 | "serde", |
137 | "serde_json", | 137 | "serde_json", |
138 | ] | 138 | ] |
@@ -255,6 +255,7 @@ version = "0.0.0" | |||
255 | dependencies = [ | 255 | dependencies = [ |
256 | "assists", | 256 | "assists", |
257 | "base_db", | 257 | "base_db", |
258 | "either", | ||
258 | "expect-test", | 259 | "expect-test", |
259 | "hir", | 260 | "hir", |
260 | "ide_db", | 261 | "ide_db", |
@@ -270,17 +271,17 @@ dependencies = [ | |||
270 | 271 | ||
271 | [[package]] | 272 | [[package]] |
272 | name = "const_fn" | 273 | name = "const_fn" |
273 | version = "0.4.3" | 274 | version = "0.4.2" |
274 | source = "registry+https://github.com/rust-lang/crates.io-index" | 275 | source = "registry+https://github.com/rust-lang/crates.io-index" |
275 | checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" | 276 | checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2" |
276 | 277 | ||
277 | [[package]] | 278 | [[package]] |
278 | name = "crc32fast" | 279 | name = "crc32fast" |
279 | version = "1.2.1" | 280 | version = "1.2.0" |
280 | source = "registry+https://github.com/rust-lang/crates.io-index" | 281 | source = "registry+https://github.com/rust-lang/crates.io-index" |
281 | checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" | 282 | checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" |
282 | dependencies = [ | 283 | dependencies = [ |
283 | "cfg-if 1.0.0", | 284 | "cfg-if 0.1.10", |
284 | ] | 285 | ] |
285 | 286 | ||
286 | [[package]] | 287 | [[package]] |
@@ -417,11 +418,11 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" | |||
417 | 418 | ||
418 | [[package]] | 419 | [[package]] |
419 | name = "flate2" | 420 | name = "flate2" |
420 | version = "1.0.19" | 421 | version = "1.0.18" |
421 | source = "registry+https://github.com/rust-lang/crates.io-index" | 422 | source = "registry+https://github.com/rust-lang/crates.io-index" |
422 | checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" | 423 | checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee" |
423 | dependencies = [ | 424 | dependencies = [ |
424 | "cfg-if 1.0.0", | 425 | "cfg-if 0.1.10", |
425 | "crc32fast", | 426 | "crc32fast", |
426 | "libc", | 427 | "libc", |
427 | "miniz_oxide", | 428 | "miniz_oxide", |
@@ -470,9 +471,9 @@ dependencies = [ | |||
470 | 471 | ||
471 | [[package]] | 472 | [[package]] |
472 | name = "fst" | 473 | name = "fst" |
473 | version = "0.4.5" | 474 | version = "0.4.4" |
474 | source = "registry+https://github.com/rust-lang/crates.io-index" | 475 | source = "registry+https://github.com/rust-lang/crates.io-index" |
475 | checksum = "d79238883cf0307100b90aba4a755d8051a3182305dfe7f649a1e9dc0517006f" | 476 | checksum = "a7293de202dbfe786c0b3fe6110a027836c5438ed06db7b715c9955ff4bfea51" |
476 | 477 | ||
477 | [[package]] | 478 | [[package]] |
478 | name = "fuchsia-zircon" | 479 | name = "fuchsia-zircon" |
@@ -491,23 +492,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
491 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" | 492 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" |
492 | 493 | ||
493 | [[package]] | 494 | [[package]] |
494 | name = "generator" | ||
495 | version = "0.6.23" | ||
496 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
497 | checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc" | ||
498 | dependencies = [ | ||
499 | "cc", | ||
500 | "libc", | ||
501 | "log", | ||
502 | "rustc_version", | ||
503 | "winapi 0.3.9", | ||
504 | ] | ||
505 | |||
506 | [[package]] | ||
507 | name = "gimli" | 495 | name = "gimli" |
508 | version = "0.23.0" | 496 | version = "0.22.0" |
509 | source = "registry+https://github.com/rust-lang/crates.io-index" | 497 | source = "registry+https://github.com/rust-lang/crates.io-index" |
510 | checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" | 498 | checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" |
511 | 499 | ||
512 | [[package]] | 500 | [[package]] |
513 | name = "goblin" | 501 | name = "goblin" |
@@ -735,11 +723,11 @@ dependencies = [ | |||
735 | 723 | ||
736 | [[package]] | 724 | [[package]] |
737 | name = "instant" | 725 | name = "instant" |
738 | version = "0.1.8" | 726 | version = "0.1.7" |
739 | source = "registry+https://github.com/rust-lang/crates.io-index" | 727 | source = "registry+https://github.com/rust-lang/crates.io-index" |
740 | checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" | 728 | checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66" |
741 | dependencies = [ | 729 | dependencies = [ |
742 | "cfg-if 1.0.0", | 730 | "cfg-if 0.1.10", |
743 | ] | 731 | ] |
744 | 732 | ||
745 | [[package]] | 733 | [[package]] |
@@ -796,17 +784,17 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" | |||
796 | 784 | ||
797 | [[package]] | 785 | [[package]] |
798 | name = "libc" | 786 | name = "libc" |
799 | version = "0.2.80" | 787 | version = "0.2.79" |
800 | source = "registry+https://github.com/rust-lang/crates.io-index" | 788 | source = "registry+https://github.com/rust-lang/crates.io-index" |
801 | checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" | 789 | checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" |
802 | 790 | ||
803 | [[package]] | 791 | [[package]] |
804 | name = "libloading" | 792 | name = "libloading" |
805 | version = "0.6.5" | 793 | version = "0.6.4" |
806 | source = "registry+https://github.com/rust-lang/crates.io-index" | 794 | source = "registry+https://github.com/rust-lang/crates.io-index" |
807 | checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" | 795 | checksum = "3557c9384f7f757f6d139cd3a4c62ef4e850696c16bf27924a5538c8a09717a1" |
808 | dependencies = [ | 796 | dependencies = [ |
809 | "cfg-if 1.0.0", | 797 | "cfg-if 0.1.10", |
810 | "winapi 0.3.9", | 798 | "winapi 0.3.9", |
811 | ] | 799 | ] |
812 | 800 | ||
@@ -838,19 +826,6 @@ dependencies = [ | |||
838 | ] | 826 | ] |
839 | 827 | ||
840 | [[package]] | 828 | [[package]] |
841 | name = "loom" | ||
842 | version = "0.3.6" | ||
843 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
844 | checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed" | ||
845 | dependencies = [ | ||
846 | "cfg-if 0.1.10", | ||
847 | "generator", | ||
848 | "scoped-tls", | ||
849 | "serde", | ||
850 | "serde_json", | ||
851 | ] | ||
852 | |||
853 | [[package]] | ||
854 | name = "lsp-server" | 829 | name = "lsp-server" |
855 | version = "0.4.1" | 830 | version = "0.4.1" |
856 | source = "registry+https://github.com/rust-lang/crates.io-index" | 831 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -912,9 +887,9 @@ dependencies = [ | |||
912 | 887 | ||
913 | [[package]] | 888 | [[package]] |
914 | name = "memchr" | 889 | name = "memchr" |
915 | version = "2.3.4" | 890 | version = "2.3.3" |
916 | source = "registry+https://github.com/rust-lang/crates.io-index" | 891 | source = "registry+https://github.com/rust-lang/crates.io-index" |
917 | checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" | 892 | checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" |
918 | 893 | ||
919 | [[package]] | 894 | [[package]] |
920 | name = "memmap" | 895 | name = "memmap" |
@@ -1010,9 +985,9 @@ dependencies = [ | |||
1010 | 985 | ||
1011 | [[package]] | 986 | [[package]] |
1012 | name = "notify" | 987 | name = "notify" |
1013 | version = "5.0.0-pre.4" | 988 | version = "5.0.0-pre.3" |
1014 | source = "registry+https://github.com/rust-lang/crates.io-index" | 989 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1015 | checksum = "a8b946889dfdad884379cd56367d93b6d0ce8889cc027d26a69a3a31c0a03bb5" | 990 | checksum = "77d03607cf88b4b160ba0e9ed425fff3cee3b55ac813f0c685b3a3772da37d0e" |
1016 | dependencies = [ | 991 | dependencies = [ |
1017 | "anymap", | 992 | "anymap", |
1018 | "bitflags", | 993 | "bitflags", |
@@ -1030,9 +1005,9 @@ dependencies = [ | |||
1030 | 1005 | ||
1031 | [[package]] | 1006 | [[package]] |
1032 | name = "num-integer" | 1007 | name = "num-integer" |
1033 | version = "0.1.44" | 1008 | version = "0.1.43" |
1034 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1009 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1035 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" | 1010 | checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" |
1036 | dependencies = [ | 1011 | dependencies = [ |
1037 | "autocfg", | 1012 | "autocfg", |
1038 | "num-traits", | 1013 | "num-traits", |
@@ -1040,9 +1015,9 @@ dependencies = [ | |||
1040 | 1015 | ||
1041 | [[package]] | 1016 | [[package]] |
1042 | name = "num-traits" | 1017 | name = "num-traits" |
1043 | version = "0.2.14" | 1018 | version = "0.2.12" |
1044 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1019 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1045 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" | 1020 | checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" |
1046 | dependencies = [ | 1021 | dependencies = [ |
1047 | "autocfg", | 1022 | "autocfg", |
1048 | ] | 1023 | ] |
@@ -1059,9 +1034,9 @@ dependencies = [ | |||
1059 | 1034 | ||
1060 | [[package]] | 1035 | [[package]] |
1061 | name = "object" | 1036 | name = "object" |
1062 | version = "0.22.0" | 1037 | version = "0.21.1" |
1063 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1038 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1064 | checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" | 1039 | checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" |
1065 | 1040 | ||
1066 | [[package]] | 1041 | [[package]] |
1067 | name = "once_cell" | 1042 | name = "once_cell" |
@@ -1310,9 +1285,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" | |||
1310 | 1285 | ||
1311 | [[package]] | 1286 | [[package]] |
1312 | name = "regex" | 1287 | name = "regex" |
1313 | version = "1.4.2" | 1288 | version = "1.4.1" |
1314 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1289 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1315 | checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" | 1290 | checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" |
1316 | dependencies = [ | 1291 | dependencies = [ |
1317 | "regex-syntax", | 1292 | "regex-syntax", |
1318 | ] | 1293 | ] |
@@ -1329,9 +1304,9 @@ dependencies = [ | |||
1329 | 1304 | ||
1330 | [[package]] | 1305 | [[package]] |
1331 | name = "regex-syntax" | 1306 | name = "regex-syntax" |
1332 | version = "0.6.21" | 1307 | version = "0.6.20" |
1333 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1308 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1334 | checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" | 1309 | checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" |
1335 | 1310 | ||
1336 | [[package]] | 1311 | [[package]] |
1337 | name = "rowan" | 1312 | name = "rowan" |
@@ -1404,9 +1379,9 @@ dependencies = [ | |||
1404 | 1379 | ||
1405 | [[package]] | 1380 | [[package]] |
1406 | name = "rustc-demangle" | 1381 | name = "rustc-demangle" |
1407 | version = "0.1.18" | 1382 | version = "0.1.17" |
1408 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1383 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1409 | checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" | 1384 | checksum = "b2610b7f643d18c87dff3b489950269617e6601a51f1f05aa5daefee36f64f0b" |
1410 | 1385 | ||
1411 | [[package]] | 1386 | [[package]] |
1412 | name = "rustc-hash" | 1387 | name = "rustc-hash" |
@@ -1415,15 +1390,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1415 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" | 1390 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" |
1416 | 1391 | ||
1417 | [[package]] | 1392 | [[package]] |
1418 | name = "rustc_version" | ||
1419 | version = "0.2.3" | ||
1420 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1421 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | ||
1422 | dependencies = [ | ||
1423 | "semver 0.9.0", | ||
1424 | ] | ||
1425 | |||
1426 | [[package]] | ||
1427 | name = "ryu" | 1393 | name = "ryu" |
1428 | version = "1.0.5" | 1394 | version = "1.0.5" |
1429 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1395 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1490,9 +1456,9 @@ dependencies = [ | |||
1490 | 1456 | ||
1491 | [[package]] | 1457 | [[package]] |
1492 | name = "scroll_derive" | 1458 | name = "scroll_derive" |
1493 | version = "0.10.4" | 1459 | version = "0.10.3" |
1494 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1460 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1495 | checksum = "b12bd20b94c7cdfda8c7ba9b92ad0d9a56e3fa018c25fca83b51aa664c9b4c0d" | 1461 | checksum = "6dfde5d1531034db129e95c76ac857e2baecea3443579d493d02224950b0fb6d" |
1496 | dependencies = [ | 1462 | dependencies = [ |
1497 | "proc-macro2", | 1463 | "proc-macro2", |
1498 | "quote", | 1464 | "quote", |
@@ -1501,31 +1467,16 @@ dependencies = [ | |||
1501 | 1467 | ||
1502 | [[package]] | 1468 | [[package]] |
1503 | name = "semver" | 1469 | name = "semver" |
1504 | version = "0.9.0" | ||
1505 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1506 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | ||
1507 | dependencies = [ | ||
1508 | "semver-parser 0.7.0", | ||
1509 | ] | ||
1510 | |||
1511 | [[package]] | ||
1512 | name = "semver" | ||
1513 | version = "0.11.0" | 1470 | version = "0.11.0" |
1514 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1471 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1515 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" | 1472 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" |
1516 | dependencies = [ | 1473 | dependencies = [ |
1517 | "semver-parser 0.10.1", | 1474 | "semver-parser", |
1518 | "serde", | 1475 | "serde", |
1519 | ] | 1476 | ] |
1520 | 1477 | ||
1521 | [[package]] | 1478 | [[package]] |
1522 | name = "semver-parser" | 1479 | name = "semver-parser" |
1523 | version = "0.7.0" | ||
1524 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1525 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" | ||
1526 | |||
1527 | [[package]] | ||
1528 | name = "semver-parser" | ||
1529 | version = "0.10.1" | 1480 | version = "0.10.1" |
1530 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1481 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1531 | checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428" | 1482 | checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428" |
@@ -1577,12 +1528,11 @@ dependencies = [ | |||
1577 | 1528 | ||
1578 | [[package]] | 1529 | [[package]] |
1579 | name = "sharded-slab" | 1530 | name = "sharded-slab" |
1580 | version = "0.1.0" | 1531 | version = "0.0.9" |
1581 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1532 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1582 | checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" | 1533 | checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" |
1583 | dependencies = [ | 1534 | dependencies = [ |
1584 | "lazy_static", | 1535 | "lazy_static", |
1585 | "loom", | ||
1586 | ] | 1536 | ] |
1587 | 1537 | ||
1588 | [[package]] | 1538 | [[package]] |
@@ -1626,9 +1576,9 @@ version = "0.0.0" | |||
1626 | 1576 | ||
1627 | [[package]] | 1577 | [[package]] |
1628 | name = "syn" | 1578 | name = "syn" |
1629 | version = "1.0.48" | 1579 | version = "1.0.45" |
1630 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1580 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1631 | checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" | 1581 | checksum = "ea9c5432ff16d6152371f808fb5a871cd67368171b09bb21b43df8e4a47a3556" |
1632 | dependencies = [ | 1582 | dependencies = [ |
1633 | "proc-macro2", | 1583 | "proc-macro2", |
1634 | "quote", | 1584 | "quote", |
@@ -1805,9 +1755,9 @@ dependencies = [ | |||
1805 | 1755 | ||
1806 | [[package]] | 1756 | [[package]] |
1807 | name = "tracing-subscriber" | 1757 | name = "tracing-subscriber" |
1808 | version = "0.2.15" | 1758 | version = "0.2.13" |
1809 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1759 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1810 | checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401" | 1760 | checksum = "4ef0a5e15477aa303afbfac3a44cba9b6430fdaad52423b1e6c0dbbe28c3eedd" |
1811 | dependencies = [ | 1761 | dependencies = [ |
1812 | "ansi_term", | 1762 | "ansi_term", |
1813 | "chrono", | 1763 | "chrono", |
diff --git a/crates/assists/src/handlers/auto_import.rs b/crates/assists/src/handlers/auto_import.rs index 37dd61266..d665837a2 100644 --- a/crates/assists/src/handlers/auto_import.rs +++ b/crates/assists/src/handlers/auto_import.rs | |||
@@ -98,7 +98,8 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
98 | 98 | ||
99 | let range = ctx.sema.original_range(import_assets.syntax_under_caret()).range; | 99 | let range = ctx.sema.original_range(import_assets.syntax_under_caret()).range; |
100 | let group = import_group_message(import_assets.import_candidate()); | 100 | let group = import_group_message(import_assets.import_candidate()); |
101 | let scope = ImportScope::find_insert_use_container(import_assets.syntax_under_caret(), ctx)?; | 101 | let scope = |
102 | ImportScope::find_insert_use_container(import_assets.syntax_under_caret(), &ctx.sema)?; | ||
102 | for (import, _) in proposed_imports { | 103 | for (import, _) in proposed_imports { |
103 | acc.add_group( | 104 | acc.add_group( |
104 | &group, | 105 | &group, |
diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index 067afabf2..cac77c49b 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -143,8 +143,7 @@ fn insert_import( | |||
143 | if let Some(mut mod_path) = mod_path { | 143 | if let Some(mut mod_path) = mod_path { |
144 | mod_path.segments.pop(); | 144 | mod_path.segments.pop(); |
145 | mod_path.segments.push(variant_hir_name.clone()); | 145 | mod_path.segments.push(variant_hir_name.clone()); |
146 | let scope = ImportScope::find_insert_use_container(scope_node, ctx)?; | 146 | let scope = ImportScope::find_insert_use_container(scope_node, &ctx.sema)?; |
147 | |||
148 | *rewriter += insert_use(&scope, mod_path_to_ast(&mod_path), ctx.config.insert_use.merge); | 147 | *rewriter += insert_use(&scope, mod_path_to_ast(&mod_path), ctx.config.insert_use.merge); |
149 | } | 148 | } |
150 | Some(()) | 149 | Some(()) |
diff --git a/crates/assists/src/handlers/replace_qualified_name_with_use.rs b/crates/assists/src/handlers/replace_qualified_name_with_use.rs index d7e1d9580..a66db9ae3 100644 --- a/crates/assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -34,7 +34,7 @@ pub(crate) fn replace_qualified_name_with_use( | |||
34 | } | 34 | } |
35 | 35 | ||
36 | let target = path.syntax().text_range(); | 36 | let target = path.syntax().text_range(); |
37 | let scope = ImportScope::find_insert_use_container(path.syntax(), ctx)?; | 37 | let scope = ImportScope::find_insert_use_container(path.syntax(), &ctx.sema)?; |
38 | let syntax = scope.as_syntax_node(); | 38 | let syntax = scope.as_syntax_node(); |
39 | acc.add( | 39 | acc.add( |
40 | AssistId("replace_qualified_name_with_use", AssistKind::RefactorRewrite), | 40 | AssistId("replace_qualified_name_with_use", AssistKind::RefactorRewrite), |
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 7bd338e99..caabc44de 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs | |||
@@ -21,8 +21,7 @@ use crate::{ | |||
21 | ast_transform::{self, AstTransform, QualifyPaths, SubstituteTypeParams}, | 21 | ast_transform::{self, AstTransform, QualifyPaths, SubstituteTypeParams}, |
22 | }; | 22 | }; |
23 | 23 | ||
24 | pub use insert_use::MergeBehaviour; | 24 | pub use insert_use::{insert_use, ImportScope, MergeBehaviour}; |
25 | pub(crate) use insert_use::{insert_use, ImportScope}; | ||
26 | 25 | ||
27 | pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path { | 26 | pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path { |
28 | let mut segments = Vec::new(); | 27 | let mut segments = Vec::new(); |
diff --git a/crates/assists/src/utils/insert_use.rs b/crates/assists/src/utils/insert_use.rs index af3fc96b6..1aa727e11 100644 --- a/crates/assists/src/utils/insert_use.rs +++ b/crates/assists/src/utils/insert_use.rs | |||
@@ -1,6 +1,8 @@ | |||
1 | //! Handle syntactic aspects of inserting a new `use`. | 1 | //! Handle syntactic aspects of inserting a new `use`. |
2 | use std::{cmp::Ordering, iter::successors}; | 2 | use std::{cmp::Ordering, iter::successors}; |
3 | 3 | ||
4 | use hir::Semantics; | ||
5 | use ide_db::RootDatabase; | ||
4 | use itertools::{EitherOrBoth, Itertools}; | 6 | use itertools::{EitherOrBoth, Itertools}; |
5 | use syntax::{ | 7 | use syntax::{ |
6 | algo::SyntaxRewriter, | 8 | algo::SyntaxRewriter, |
@@ -14,7 +16,7 @@ use syntax::{ | |||
14 | use test_utils::mark; | 16 | use test_utils::mark; |
15 | 17 | ||
16 | #[derive(Debug)] | 18 | #[derive(Debug)] |
17 | pub(crate) enum ImportScope { | 19 | pub enum ImportScope { |
18 | File(ast::SourceFile), | 20 | File(ast::SourceFile), |
19 | Module(ast::ItemList), | 21 | Module(ast::ItemList), |
20 | } | 22 | } |
@@ -31,14 +33,14 @@ impl ImportScope { | |||
31 | } | 33 | } |
32 | 34 | ||
33 | /// Determines the containing syntax node in which to insert a `use` statement affecting `position`. | 35 | /// Determines the containing syntax node in which to insert a `use` statement affecting `position`. |
34 | pub(crate) fn find_insert_use_container( | 36 | pub fn find_insert_use_container( |
35 | position: &SyntaxNode, | 37 | position: &SyntaxNode, |
36 | ctx: &crate::assist_context::AssistContext, | 38 | sema: &Semantics<'_, RootDatabase>, |
37 | ) -> Option<Self> { | 39 | ) -> Option<Self> { |
38 | ctx.sema.ancestors_with_macros(position.clone()).find_map(Self::from) | 40 | sema.ancestors_with_macros(position.clone()).find_map(Self::from) |
39 | } | 41 | } |
40 | 42 | ||
41 | pub(crate) fn as_syntax_node(&self) -> &SyntaxNode { | 43 | pub fn as_syntax_node(&self) -> &SyntaxNode { |
42 | match self { | 44 | match self { |
43 | ImportScope::File(file) => file.syntax(), | 45 | ImportScope::File(file) => file.syntax(), |
44 | ImportScope::Module(item_list) => item_list.syntax(), | 46 | ImportScope::Module(item_list) => item_list.syntax(), |
@@ -88,7 +90,7 @@ fn is_inner_comment(token: SyntaxToken) -> bool { | |||
88 | } | 90 | } |
89 | 91 | ||
90 | /// Insert an import path into the given file/node. A `merge` value of none indicates that no import merging is allowed to occur. | 92 | /// Insert an import path into the given file/node. A `merge` value of none indicates that no import merging is allowed to occur. |
91 | pub(crate) fn insert_use<'a>( | 93 | pub fn insert_use<'a>( |
92 | scope: &ImportScope, | 94 | scope: &ImportScope, |
93 | path: ast::Path, | 95 | path: ast::Path, |
94 | merge: Option<MergeBehaviour>, | 96 | merge: Option<MergeBehaviour>, |
diff --git a/crates/completion/Cargo.toml b/crates/completion/Cargo.toml index 3015ec9e0..799b4a3d5 100644 --- a/crates/completion/Cargo.toml +++ b/crates/completion/Cargo.toml | |||
@@ -13,6 +13,7 @@ doctest = false | |||
13 | itertools = "0.9.0" | 13 | itertools = "0.9.0" |
14 | log = "0.4.8" | 14 | log = "0.4.8" |
15 | rustc-hash = "1.1.0" | 15 | rustc-hash = "1.1.0" |
16 | either = "1.6.1" | ||
16 | 17 | ||
17 | assists = { path = "../assists", version = "0.0.0" } | 18 | assists = { path = "../assists", version = "0.0.0" } |
18 | stdx = { path = "../stdx", version = "0.0.0" } | 19 | stdx = { path = "../stdx", version = "0.0.0" } |
@@ -21,6 +22,7 @@ text_edit = { path = "../text_edit", version = "0.0.0" } | |||
21 | base_db = { path = "../base_db", version = "0.0.0" } | 22 | base_db = { path = "../base_db", version = "0.0.0" } |
22 | ide_db = { path = "../ide_db", version = "0.0.0" } | 23 | ide_db = { path = "../ide_db", version = "0.0.0" } |
23 | profile = { path = "../profile", version = "0.0.0" } | 24 | profile = { path = "../profile", version = "0.0.0" } |
25 | assists = { path = "../assists", version = "0.0.0" } | ||
24 | test_utils = { path = "../test_utils", version = "0.0.0" } | 26 | test_utils = { path = "../test_utils", version = "0.0.0" } |
25 | 27 | ||
26 | # completions crate should depend only on the top-level `hir` package. if you need | 28 | # completions crate should depend only on the top-level `hir` package. if you need |
diff --git a/crates/completion/src/completions.rs b/crates/completion/src/completions.rs index 75dbb1a23..99db5f998 100644 --- a/crates/completion/src/completions.rs +++ b/crates/completion/src/completions.rs | |||
@@ -13,6 +13,7 @@ pub(crate) mod postfix; | |||
13 | pub(crate) mod macro_in_item_position; | 13 | pub(crate) mod macro_in_item_position; |
14 | pub(crate) mod trait_impl; | 14 | pub(crate) mod trait_impl; |
15 | pub(crate) mod mod_; | 15 | pub(crate) mod mod_; |
16 | pub(crate) mod complete_magic; | ||
16 | 17 | ||
17 | use hir::{ModPath, ScopeDef, Type}; | 18 | use hir::{ModPath, ScopeDef, Type}; |
18 | 19 | ||
diff --git a/crates/completion/src/completions/complete_magic.rs b/crates/completion/src/completions/complete_magic.rs new file mode 100644 index 000000000..857a0b620 --- /dev/null +++ b/crates/completion/src/completions/complete_magic.rs | |||
@@ -0,0 +1,114 @@ | |||
1 | //! TODO kb move this into the complete_unqualified_path when starts to work properly | ||
2 | |||
3 | use assists::utils::{insert_use, mod_path_to_ast, ImportScope, MergeBehaviour}; | ||
4 | use hir::Query; | ||
5 | use itertools::Itertools; | ||
6 | use syntax::AstNode; | ||
7 | use text_edit::TextEdit; | ||
8 | |||
9 | use crate::{context::CompletionContext, item::CompletionKind, CompletionItem, CompletionItemKind}; | ||
10 | |||
11 | use super::Completions; | ||
12 | |||
13 | pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { | ||
14 | if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) { | ||
15 | return None; | ||
16 | } | ||
17 | let current_module = ctx.scope.module()?; | ||
18 | let anchor = ctx.name_ref_syntax.as_ref()?; | ||
19 | let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; | ||
20 | // TODO kb now this is the whole file, which is not disjoint with any other change in the same file, fix it | ||
21 | // otherwise it's impossible to correctly add the use statement and also change the completed text into something more meaningful | ||
22 | let import_syntax = import_scope.as_syntax_node(); | ||
23 | |||
24 | // TODO kb consider heuristics, such as "don't show `hash_map` import if `HashMap` is the import for completion" | ||
25 | // TODO kb module functions are not completed, consider `std::io::stdin` one | ||
26 | let potential_import_name = ctx.token.to_string(); | ||
27 | |||
28 | let possible_imports = ctx | ||
29 | .krate? | ||
30 | // TODO kb use imports_locator instead? | ||
31 | .query_external_importables(ctx.db, Query::new(&potential_import_name).limit(40)) | ||
32 | .unique() | ||
33 | .filter_map(|import_candidate| match import_candidate { | ||
34 | either::Either::Left(module_def) => current_module.find_use_path(ctx.db, module_def), | ||
35 | either::Either::Right(macro_def) => current_module.find_use_path(ctx.db, macro_def), | ||
36 | }) | ||
37 | .filter_map(|mod_path| { | ||
38 | let correct_qualifier = mod_path.segments.last()?.to_string(); | ||
39 | let rewriter = | ||
40 | insert_use(&import_scope, mod_path_to_ast(&mod_path), Some(MergeBehaviour::Full)); | ||
41 | let rewritten_node = rewriter.rewrite(import_syntax); | ||
42 | let insert_use_edit = | ||
43 | TextEdit::replace(import_syntax.text_range(), rewritten_node.to_string()); | ||
44 | let mut completion_edit = | ||
45 | TextEdit::replace(anchor.syntax().text_range(), correct_qualifier); | ||
46 | completion_edit.union(insert_use_edit).expect("TODO kb"); | ||
47 | |||
48 | let completion_item: CompletionItem = CompletionItem::new( | ||
49 | CompletionKind::Magic, | ||
50 | ctx.source_range(), | ||
51 | mod_path.to_string(), | ||
52 | ) | ||
53 | .kind(CompletionItemKind::Struct) | ||
54 | .text_edit(completion_edit) | ||
55 | .into(); | ||
56 | Some(completion_item) | ||
57 | }); | ||
58 | acc.add_all(possible_imports); | ||
59 | |||
60 | Some(()) | ||
61 | } | ||
62 | |||
63 | #[cfg(test)] | ||
64 | mod tests { | ||
65 | use expect_test::{expect, Expect}; | ||
66 | |||
67 | use crate::{ | ||
68 | item::CompletionKind, | ||
69 | test_utils::{check_edit, completion_list}, | ||
70 | }; | ||
71 | |||
72 | fn check(ra_fixture: &str, expect: Expect) { | ||
73 | let actual = completion_list(ra_fixture, CompletionKind::Magic); | ||
74 | expect.assert_eq(&actual) | ||
75 | } | ||
76 | |||
77 | #[test] | ||
78 | fn case_insensitive_magic_completion_works() { | ||
79 | check( | ||
80 | r#" | ||
81 | //- /lib.rs crate:dep | ||
82 | pub struct TestStruct; | ||
83 | |||
84 | //- /main.rs crate:main deps:dep | ||
85 | fn main() { | ||
86 | teru<|> | ||
87 | } | ||
88 | "#, | ||
89 | expect![[r#" | ||
90 | st dep::TestStruct | ||
91 | "#]], | ||
92 | ); | ||
93 | |||
94 | check_edit( | ||
95 | "dep::TestStruct", | ||
96 | r#" | ||
97 | //- /lib.rs crate:dep | ||
98 | pub struct TestStruct; | ||
99 | |||
100 | //- /main.rs crate:main deps:dep | ||
101 | fn main() { | ||
102 | teru<|> | ||
103 | } | ||
104 | "#, | ||
105 | r#" | ||
106 | use dep::TestStruct; | ||
107 | |||
108 | fn main() { | ||
109 | TestStruct | ||
110 | } | ||
111 | "#, | ||
112 | ); | ||
113 | } | ||
114 | } | ||
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index 6d1d085f4..f23913935 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs | |||
@@ -31,6 +31,7 @@ pub struct CompletionItem { | |||
31 | /// | 31 | /// |
32 | /// Typically, replaces `source_range` with new identifier. | 32 | /// Typically, replaces `source_range` with new identifier. |
33 | text_edit: TextEdit, | 33 | text_edit: TextEdit, |
34 | |||
34 | insert_text_format: InsertTextFormat, | 35 | insert_text_format: InsertTextFormat, |
35 | 36 | ||
36 | /// What item (struct, function, etc) are we completing. | 37 | /// What item (struct, function, etc) are we completing. |
diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index cb6e0554e..e920fa6b5 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs | |||
@@ -118,6 +118,7 @@ pub fn completions( | |||
118 | completions::macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); | 118 | completions::macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); |
119 | completions::trait_impl::complete_trait_impl(&mut acc, &ctx); | 119 | completions::trait_impl::complete_trait_impl(&mut acc, &ctx); |
120 | completions::mod_::complete_mod(&mut acc, &ctx); | 120 | completions::mod_::complete_mod(&mut acc, &ctx); |
121 | completions::complete_magic::complete_magic(&mut acc, &ctx); | ||
121 | 122 | ||
122 | Some(acc) | 123 | Some(acc) |
123 | } | 124 | } |
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 30a5e4580..37ed092ad 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -110,15 +110,9 @@ impl Crate { | |||
110 | pub fn query_external_importables( | 110 | pub fn query_external_importables( |
111 | self, | 111 | self, |
112 | db: &dyn DefDatabase, | 112 | db: &dyn DefDatabase, |
113 | query: &str, | 113 | query: import_map::Query, |
114 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 114 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
115 | import_map::search_dependencies( | 115 | import_map::search_dependencies(db, self.into(), query).into_iter().map(|item| match item { |
116 | db, | ||
117 | self.into(), | ||
118 | import_map::Query::new(query).anchor_end().case_sensitive().limit(40), | ||
119 | ) | ||
120 | .into_iter() | ||
121 | .map(|item| match item { | ||
122 | ItemInNs::Types(mod_id) | ItemInNs::Values(mod_id) => Either::Left(mod_id.into()), | 116 | ItemInNs::Types(mod_id) | ItemInNs::Values(mod_id) => Either::Left(mod_id.into()), |
123 | ItemInNs::Macros(mac_id) => Either::Right(mac_id.into()), | 117 | ItemInNs::Macros(mac_id) => Either::Right(mac_id.into()), |
124 | }) | 118 | }) |
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 0d184379f..ad58a7cfe 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -49,6 +49,7 @@ pub use hir_def::{ | |||
49 | builtin_type::BuiltinType, | 49 | builtin_type::BuiltinType, |
50 | docs::Documentation, | 50 | docs::Documentation, |
51 | find_path::PrefixKind, | 51 | find_path::PrefixKind, |
52 | import_map::Query, | ||
52 | item_scope::ItemInNs, | 53 | item_scope::ItemInNs, |
53 | nameres::ModuleSource, | 54 | nameres::ModuleSource, |
54 | path::{ModPath, PathKind}, | 55 | path::{ModPath, PathKind}, |
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index df74be00b..e4f4b5427 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs | |||
@@ -1,12 +1,12 @@ | |||
1 | //! This module contains an import search funcionality that is provided to the assists module. | 1 | //! This module contains an import search funcionality that is provided to the assists module. |
2 | //! Later, this should be moved away to a separate crate that is accessible from the assists module. | 2 | //! Later, this should be moved away to a separate crate that is accessible from the assists module. |
3 | 3 | ||
4 | use hir::{Crate, MacroDef, ModuleDef, Semantics}; | 4 | use hir::{Crate, MacroDef, ModuleDef, Query as ImportMapQuery, Semantics}; |
5 | use syntax::{ast, AstNode, SyntaxKind::NAME}; | 5 | use syntax::{ast, AstNode, SyntaxKind::NAME}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | defs::{Definition, NameClass}, | 8 | defs::{Definition, NameClass}, |
9 | symbol_index::{self, FileSymbol, Query}, | 9 | symbol_index::{self, FileSymbol, Query as SymbolQuery}, |
10 | RootDatabase, | 10 | RootDatabase, |
11 | }; | 11 | }; |
12 | use either::Either; | 12 | use either::Either; |
@@ -21,12 +21,16 @@ pub fn find_imports<'a>( | |||
21 | let db = sema.db; | 21 | let db = sema.db; |
22 | 22 | ||
23 | // Query dependencies first. | 23 | // Query dependencies first. |
24 | let mut candidates: FxHashSet<_> = | 24 | let mut candidates: FxHashSet<_> = krate |
25 | krate.query_external_importables(db, name_to_import).collect(); | 25 | .query_external_importables( |
26 | db, | ||
27 | ImportMapQuery::new(name_to_import).anchor_end().case_sensitive().limit(40), | ||
28 | ) | ||
29 | .collect(); | ||
26 | 30 | ||
27 | // Query the local crate using the symbol index. | 31 | // Query the local crate using the symbol index. |
28 | let local_results = { | 32 | let local_results = { |
29 | let mut query = Query::new(name_to_import.to_string()); | 33 | let mut query = SymbolQuery::new(name_to_import.to_string()); |
30 | query.exact(); | 34 | query.exact(); |
31 | query.limit(40); | 35 | query.limit(40); |
32 | symbol_index::crate_symbols(db, krate.into(), query) | 36 | symbol_index::crate_symbols(db, krate.into(), query) |