diff options
-rw-r--r-- | Cargo.lock | 41 | ||||
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 16 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 61 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references/rename.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references/search_scope.rs | 87 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 11 |
10 files changed, 159 insertions, 74 deletions
diff --git a/Cargo.lock b/Cargo.lock index 61fd24ef7..c902caeb4 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -208,21 +208,6 @@ dependencies = [ | |||
208 | 208 | ||
209 | [[package]] | 209 | [[package]] |
210 | name = "console" | 210 | name = "console" |
211 | version = "0.8.0" | ||
212 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
213 | dependencies = [ | ||
214 | "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
215 | "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
216 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
217 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", | ||
218 | "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
219 | "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
220 | "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
221 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
222 | ] | ||
223 | |||
224 | [[package]] | ||
225 | name = "console" | ||
226 | version = "0.9.0" | 211 | version = "0.9.0" |
227 | source = "registry+https://github.com/rust-lang/crates.io-index" | 212 | source = "registry+https://github.com/rust-lang/crates.io-index" |
228 | dependencies = [ | 213 | dependencies = [ |
@@ -510,16 +495,16 @@ dependencies = [ | |||
510 | 495 | ||
511 | [[package]] | 496 | [[package]] |
512 | name = "insta" | 497 | name = "insta" |
513 | version = "0.11.0" | 498 | version = "0.12.0" |
514 | source = "registry+https://github.com/rust-lang/crates.io-index" | 499 | source = "registry+https://github.com/rust-lang/crates.io-index" |
515 | dependencies = [ | 500 | dependencies = [ |
516 | "console 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 501 | "console 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
517 | "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 502 | "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
518 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 503 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
519 | "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", | 504 | "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", |
520 | "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", | 505 | "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", |
521 | "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", | 506 | "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", |
522 | "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", | 507 | "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", |
523 | ] | 508 | ] |
524 | 509 | ||
525 | [[package]] | 510 | [[package]] |
@@ -998,7 +983,7 @@ dependencies = [ | |||
998 | "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", | 983 | "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", |
999 | "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)", | 984 | "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)", |
1000 | "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", | 985 | "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1001 | "insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", | 986 | "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1002 | "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", | 987 | "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1003 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 988 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1004 | "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 989 | "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1021,7 +1006,7 @@ version = "0.1.0" | |||
1021 | dependencies = [ | 1006 | dependencies = [ |
1022 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1007 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1023 | "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1008 | "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1024 | "insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1009 | "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1025 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1010 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1026 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1011 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1027 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1012 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1200,7 +1185,7 @@ dependencies = [ | |||
1200 | "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1185 | "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1201 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1186 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1202 | "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1187 | "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1203 | "rand_pcg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1188 | "rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1204 | ] | 1189 | ] |
1205 | 1190 | ||
1206 | [[package]] | 1191 | [[package]] |
@@ -1300,10 +1285,9 @@ dependencies = [ | |||
1300 | 1285 | ||
1301 | [[package]] | 1286 | [[package]] |
1302 | name = "rand_pcg" | 1287 | name = "rand_pcg" |
1303 | version = "0.2.0" | 1288 | version = "0.2.1" |
1304 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1289 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1305 | dependencies = [ | 1290 | dependencies = [ |
1306 | "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1307 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1291 | "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1308 | ] | 1292 | ] |
1309 | 1293 | ||
@@ -1694,10 +1678,10 @@ dependencies = [ | |||
1694 | 1678 | ||
1695 | [[package]] | 1679 | [[package]] |
1696 | name = "uuid" | 1680 | name = "uuid" |
1697 | version = "0.7.4" | 1681 | version = "0.8.1" |
1698 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1682 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1699 | dependencies = [ | 1683 | dependencies = [ |
1700 | "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1684 | "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1701 | "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", | 1685 | "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", |
1702 | ] | 1686 | ] |
1703 | 1687 | ||
@@ -1818,7 +1802,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1818 | "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" | 1802 | "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" |
1819 | "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" | 1803 | "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" |
1820 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 1804 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
1821 | "checksum console 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242" | ||
1822 | "checksum console 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62828f51cfa18f8c31d3d55a43c6ce6af3f87f754cba9fbba7ff38089b9f5612" | 1805 | "checksum console 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62828f51cfa18f8c31d3d55a43c6ce6af3f87f754cba9fbba7ff38089b9f5612" |
1823 | "checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" | 1806 | "checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" |
1824 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" | 1807 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" |
@@ -1854,7 +1837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1854 | "checksum indicatif 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8d596a9576eaa1446996092642d72bfef35cf47243129b7ab883baf5faec31e" | 1837 | "checksum indicatif 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8d596a9576eaa1446996092642d72bfef35cf47243129b7ab883baf5faec31e" |
1855 | "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" | 1838 | "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" |
1856 | "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" | 1839 | "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" |
1857 | "checksum insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23f83ab4ee86f38b292f0420c27fd412690a4baa9ea0ad4e3fa624bf34379b76" | 1840 | "checksum insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d499dc062e841590a67230d853bce62d0abeb91304927871670b7c55c461349" |
1858 | "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" | 1841 | "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" |
1859 | "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" | 1842 | "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" |
1860 | "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" | 1843 | "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" |
@@ -1916,7 +1899,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1916 | "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" | 1899 | "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" |
1917 | "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" | 1900 | "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" |
1918 | "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" | 1901 | "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" |
1919 | "checksum rand_pcg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e196346cbbc5c70c77e7b4926147ee8e383a38ee4d15d58a08098b169e492b6" | 1902 | "checksum rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" |
1920 | "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" | 1903 | "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" |
1921 | "checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" | 1904 | "checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" |
1922 | "checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" | 1905 | "checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" |
@@ -1963,7 +1946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1963 | "checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" | 1946 | "checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" |
1964 | "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" | 1947 | "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" |
1965 | "checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" | 1948 | "checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" |
1966 | "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" | 1949 | "checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" |
1967 | "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" | 1950 | "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" |
1968 | "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" | 1951 | "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" |
1969 | "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" | 1952 | "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" |
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index cda5cafb8..04aba3743 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -13,6 +13,7 @@ pub fn run( | |||
13 | memory_usage: bool, | 13 | memory_usage: bool, |
14 | path: &Path, | 14 | path: &Path, |
15 | only: Option<&str>, | 15 | only: Option<&str>, |
16 | with_deps: bool, | ||
16 | ) -> Result<()> { | 17 | ) -> Result<()> { |
17 | let db_load_time = Instant::now(); | 18 | let db_load_time = Instant::now(); |
18 | let (mut host, roots) = ra_batch::load_cargo(path)?; | 19 | let (mut host, roots) = ra_batch::load_cargo(path)?; |
@@ -23,18 +24,17 @@ pub fn run( | |||
23 | let mut visited_modules = HashSet::new(); | 24 | let mut visited_modules = HashSet::new(); |
24 | let mut visit_queue = Vec::new(); | 25 | let mut visit_queue = Vec::new(); |
25 | 26 | ||
26 | let members = roots | 27 | let members = |
27 | .into_iter() | 28 | roots |
28 | .filter_map( | 29 | .into_iter() |
29 | |(source_root_id, project_root)| { | 30 | .filter_map(|(source_root_id, project_root)| { |
30 | if project_root.is_member() { | 31 | if with_deps || project_root.is_member() { |
31 | Some(source_root_id) | 32 | Some(source_root_id) |
32 | } else { | 33 | } else { |
33 | None | 34 | None |
34 | } | 35 | } |
35 | }, | 36 | }) |
36 | ) | 37 | .collect::<HashSet<_>>(); |
37 | .collect::<HashSet<_>>(); | ||
38 | 38 | ||
39 | for krate in Crate::all(db) { | 39 | for krate in Crate::all(db) { |
40 | let module = krate.root_module(db).expect("crate without root module"); | 40 | let module = krate.root_module(db).expect("crate without root module"); |
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 2405eb4f4..a31fd5d6a 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -96,6 +96,7 @@ fn main() -> Result<()> { | |||
96 | }; | 96 | }; |
97 | let memory_usage = matches.contains("--memory-usage"); | 97 | let memory_usage = matches.contains("--memory-usage"); |
98 | let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?; | 98 | let only: Option<String> = matches.opt_value_from_str(["-o", "--only"])?; |
99 | let with_deps: bool = matches.contains("--with-deps"); | ||
99 | let path = { | 100 | let path = { |
100 | let mut trailing = matches.free()?; | 101 | let mut trailing = matches.free()?; |
101 | if trailing.len() != 1 { | 102 | if trailing.len() != 1 { |
@@ -109,6 +110,7 @@ fn main() -> Result<()> { | |||
109 | memory_usage, | 110 | memory_usage, |
110 | path.as_ref(), | 111 | path.as_ref(), |
111 | only.as_ref().map(String::as_ref), | 112 | only.as_ref().map(String::as_ref), |
113 | with_deps, | ||
112 | )?; | 114 | )?; |
113 | } | 115 | } |
114 | "analysis-bench" => { | 116 | "analysis-bench" => { |
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index edf1fa49b..54c09788a 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml | |||
@@ -28,4 +28,4 @@ chalk-ir = { git = "https://github.com/rust-lang/chalk.git" } | |||
28 | lalrpop-intern = "0.15.1" | 28 | lalrpop-intern = "0.15.1" |
29 | 29 | ||
30 | [dev-dependencies] | 30 | [dev-dependencies] |
31 | insta = "0.11.0" | 31 | insta = "0.12.0" |
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index f9bf0c686..f66f0a6ba 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml | |||
@@ -32,7 +32,7 @@ test_utils = { path = "../test_utils" } | |||
32 | ra_assists = { path = "../ra_assists" } | 32 | ra_assists = { path = "../ra_assists" } |
33 | 33 | ||
34 | [dev-dependencies] | 34 | [dev-dependencies] |
35 | insta = "0.11.0" | 35 | insta = "0.12.0" |
36 | 36 | ||
37 | [dev-dependencies.proptest] | 37 | [dev-dependencies.proptest] |
38 | version = "0.9.0" | 38 | version = "0.9.0" |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 19669a7f0..0832229fd 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -71,7 +71,7 @@ pub use crate::{ | |||
71 | inlay_hints::{InlayHint, InlayKind}, | 71 | inlay_hints::{InlayHint, InlayKind}, |
72 | line_index::{LineCol, LineIndex}, | 72 | line_index::{LineCol, LineIndex}, |
73 | line_index_utils::translate_offset_with_edit, | 73 | line_index_utils::translate_offset_with_edit, |
74 | references::ReferenceSearchResult, | 74 | references::{ReferenceSearchResult, SearchScope}, |
75 | runnables::{Runnable, RunnableKind}, | 75 | runnables::{Runnable, RunnableKind}, |
76 | syntax_highlighting::HighlightedRange, | 76 | syntax_highlighting::HighlightedRange, |
77 | }; | 77 | }; |
@@ -481,8 +481,9 @@ impl Analysis { | |||
481 | pub fn find_all_refs( | 481 | pub fn find_all_refs( |
482 | &self, | 482 | &self, |
483 | position: FilePosition, | 483 | position: FilePosition, |
484 | search_scope: Option<SearchScope>, | ||
484 | ) -> Cancelable<Option<ReferenceSearchResult>> { | 485 | ) -> Cancelable<Option<ReferenceSearchResult>> { |
485 | self.with_db(|db| references::find_all_refs(db, position).map(|it| it.info)) | 486 | self.with_db(|db| references::find_all_refs(db, position, search_scope).map(|it| it.info)) |
486 | } | 487 | } |
487 | 488 | ||
488 | /// Returns a short text describing element at position. | 489 | /// Returns a short text describing element at position. |
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 8200bd1ef..b5b1c9a16 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -27,6 +27,8 @@ pub(crate) use self::{ | |||
27 | rename::rename, | 27 | rename::rename, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | pub use self::search_scope::SearchScope; | ||
31 | |||
30 | #[derive(Debug, Clone)] | 32 | #[derive(Debug, Clone)] |
31 | pub struct ReferenceSearchResult { | 33 | pub struct ReferenceSearchResult { |
32 | declaration: NavigationTarget, | 34 | declaration: NavigationTarget, |
@@ -67,6 +69,7 @@ impl IntoIterator for ReferenceSearchResult { | |||
67 | pub(crate) fn find_all_refs( | 69 | pub(crate) fn find_all_refs( |
68 | db: &RootDatabase, | 70 | db: &RootDatabase, |
69 | position: FilePosition, | 71 | position: FilePosition, |
72 | search_scope: Option<SearchScope>, | ||
70 | ) -> Option<RangeInfo<ReferenceSearchResult>> { | 73 | ) -> Option<RangeInfo<ReferenceSearchResult>> { |
71 | let parse = db.parse(position.file_id); | 74 | let parse = db.parse(position.file_id); |
72 | let syntax = parse.tree().syntax().clone(); | 75 | let syntax = parse.tree().syntax().clone(); |
@@ -86,7 +89,15 @@ pub(crate) fn find_all_refs( | |||
86 | NameKind::GenericParam(_) => return None, | 89 | NameKind::GenericParam(_) => return None, |
87 | }; | 90 | }; |
88 | 91 | ||
89 | let references = process_definition(db, def, name); | 92 | let search_scope = { |
93 | let base = def.search_scope(db); | ||
94 | match search_scope { | ||
95 | None => base, | ||
96 | Some(scope) => base.intersection(&scope), | ||
97 | } | ||
98 | }; | ||
99 | |||
100 | let references = process_definition(db, def, name, search_scope); | ||
90 | 101 | ||
91 | Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references })) | 102 | Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references })) |
92 | } | 103 | } |
@@ -107,11 +118,15 @@ fn find_name<'a>( | |||
107 | Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) | 118 | Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) |
108 | } | 119 | } |
109 | 120 | ||
110 | fn process_definition(db: &RootDatabase, def: NameDefinition, name: String) -> Vec<FileRange> { | 121 | fn process_definition( |
122 | db: &RootDatabase, | ||
123 | def: NameDefinition, | ||
124 | name: String, | ||
125 | scope: SearchScope, | ||
126 | ) -> Vec<FileRange> { | ||
111 | let _p = profile("process_definition"); | 127 | let _p = profile("process_definition"); |
112 | 128 | ||
113 | let pat = name.as_str(); | 129 | let pat = name.as_str(); |
114 | let scope = def.search_scope(db); | ||
115 | let mut refs = vec![]; | 130 | let mut refs = vec![]; |
116 | 131 | ||
117 | for (file_id, search_range) in scope { | 132 | for (file_id, search_range) in scope { |
@@ -144,8 +159,8 @@ fn process_definition(db: &RootDatabase, def: NameDefinition, name: String) -> V | |||
144 | #[cfg(test)] | 159 | #[cfg(test)] |
145 | mod tests { | 160 | mod tests { |
146 | use crate::{ | 161 | use crate::{ |
147 | mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, | 162 | mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis}, |
148 | ReferenceSearchResult, | 163 | ReferenceSearchResult, SearchScope, |
149 | }; | 164 | }; |
150 | 165 | ||
151 | #[test] | 166 | #[test] |
@@ -270,7 +285,7 @@ mod tests { | |||
270 | "#; | 285 | "#; |
271 | 286 | ||
272 | let (analysis, pos) = analysis_and_position(code); | 287 | let (analysis, pos) = analysis_and_position(code); |
273 | let refs = analysis.find_all_refs(pos).unwrap().unwrap(); | 288 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
274 | assert_eq!(refs.len(), 3); | 289 | assert_eq!(refs.len(), 3); |
275 | } | 290 | } |
276 | 291 | ||
@@ -296,7 +311,7 @@ mod tests { | |||
296 | "#; | 311 | "#; |
297 | 312 | ||
298 | let (analysis, pos) = analysis_and_position(code); | 313 | let (analysis, pos) = analysis_and_position(code); |
299 | let refs = analysis.find_all_refs(pos).unwrap().unwrap(); | 314 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
300 | assert_eq!(refs.len(), 2); | 315 | assert_eq!(refs.len(), 2); |
301 | } | 316 | } |
302 | 317 | ||
@@ -321,12 +336,40 @@ mod tests { | |||
321 | "#; | 336 | "#; |
322 | 337 | ||
323 | let (analysis, pos) = analysis_and_position(code); | 338 | let (analysis, pos) = analysis_and_position(code); |
324 | let refs = analysis.find_all_refs(pos).unwrap().unwrap(); | 339 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
340 | assert_eq!(refs.len(), 3); | ||
341 | } | ||
342 | |||
343 | #[test] | ||
344 | fn test_find_all_refs_with_scope() { | ||
345 | let code = r#" | ||
346 | //- /lib.rs | ||
347 | mod foo; | ||
348 | mod bar; | ||
349 | |||
350 | pub fn quux<|>() {} | ||
351 | |||
352 | //- /foo.rs | ||
353 | fn f() { super::quux(); } | ||
354 | |||
355 | //- /bar.rs | ||
356 | fn f() { super::quux(); } | ||
357 | "#; | ||
358 | |||
359 | let (mock, pos) = MockAnalysis::with_files_and_position(code); | ||
360 | let bar = mock.id_of("/bar.rs"); | ||
361 | let analysis = mock.analysis(); | ||
362 | |||
363 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); | ||
325 | assert_eq!(refs.len(), 3); | 364 | assert_eq!(refs.len(), 3); |
365 | |||
366 | let refs = | ||
367 | analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap(); | ||
368 | assert_eq!(refs.len(), 2); | ||
326 | } | 369 | } |
327 | 370 | ||
328 | fn get_all_refs(text: &str) -> ReferenceSearchResult { | 371 | fn get_all_refs(text: &str) -> ReferenceSearchResult { |
329 | let (analysis, position) = single_file_with_position(text); | 372 | let (analysis, position) = single_file_with_position(text); |
330 | analysis.find_all_refs(position).unwrap().unwrap() | 373 | analysis.find_all_refs(position, None).unwrap().unwrap() |
331 | } | 374 | } |
332 | } | 375 | } |
diff --git a/crates/ra_ide_api/src/references/rename.rs b/crates/ra_ide_api/src/references/rename.rs index 0e2e088e0..ee6e73e1b 100644 --- a/crates/ra_ide_api/src/references/rename.rs +++ b/crates/ra_ide_api/src/references/rename.rs | |||
@@ -110,7 +110,7 @@ fn rename_reference( | |||
110 | position: FilePosition, | 110 | position: FilePosition, |
111 | new_name: &str, | 111 | new_name: &str, |
112 | ) -> Option<RangeInfo<SourceChange>> { | 112 | ) -> Option<RangeInfo<SourceChange>> { |
113 | let RangeInfo { range, info: refs } = find_all_refs(db, position)?; | 113 | let RangeInfo { range, info: refs } = find_all_refs(db, position, None)?; |
114 | 114 | ||
115 | let edit = refs | 115 | let edit = refs |
116 | .into_iter() | 116 | .into_iter() |
@@ -255,13 +255,13 @@ mod tests { | |||
255 | "#; | 255 | "#; |
256 | 256 | ||
257 | let (analysis, pos) = analysis_and_position(code); | 257 | let (analysis, pos) = analysis_and_position(code); |
258 | let refs = analysis.find_all_refs(pos).unwrap().unwrap(); | 258 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
259 | assert_eq!(refs.len(), 3); | 259 | assert_eq!(refs.len(), 3); |
260 | } | 260 | } |
261 | 261 | ||
262 | fn get_all_refs(text: &str) -> ReferenceSearchResult { | 262 | fn get_all_refs(text: &str) -> ReferenceSearchResult { |
263 | let (analysis, position) = single_file_with_position(text); | 263 | let (analysis, position) = single_file_with_position(text); |
264 | analysis.find_all_refs(position).unwrap().unwrap() | 264 | analysis.find_all_refs(position, None).unwrap().unwrap() |
265 | } | 265 | } |
266 | 266 | ||
267 | #[test] | 267 | #[test] |
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs index 21e667c83..b6eb248b7 100644 --- a/crates/ra_ide_api/src/references/search_scope.rs +++ b/crates/ra_ide_api/src/references/search_scope.rs | |||
@@ -2,33 +2,84 @@ | |||
2 | //! For `pub(crate)` things it's a crate, for `pub` things it's a crate and dependant crates. | 2 | //! For `pub(crate)` things it's a crate, for `pub` things it's a crate and dependant crates. |
3 | //! In some cases, the location of the references is known to within a `TextRange`, | 3 | //! In some cases, the location of the references is known to within a `TextRange`, |
4 | //! e.g. for things like local variables. | 4 | //! e.g. for things like local variables. |
5 | use std::mem; | ||
5 | 6 | ||
6 | use hir::{DefWithBody, HasSource, ModuleSource}; | 7 | use hir::{DefWithBody, HasSource, ModuleSource}; |
7 | use ra_db::{FileId, SourceDatabase, SourceDatabaseExt}; | 8 | use ra_db::{FileId, SourceDatabase, SourceDatabaseExt}; |
8 | use ra_prof::profile; | 9 | use ra_prof::profile; |
9 | use ra_syntax::{AstNode, TextRange}; | 10 | use ra_syntax::{AstNode, TextRange}; |
10 | use rustc_hash::FxHashSet; | 11 | use rustc_hash::FxHashMap; |
11 | 12 | ||
12 | use crate::db::RootDatabase; | 13 | use crate::db::RootDatabase; |
13 | 14 | ||
14 | use super::{NameDefinition, NameKind}; | 15 | use super::{NameDefinition, NameKind}; |
15 | 16 | ||
17 | pub struct SearchScope { | ||
18 | entries: FxHashMap<FileId, Option<TextRange>>, | ||
19 | } | ||
20 | |||
21 | impl SearchScope { | ||
22 | fn new(entries: FxHashMap<FileId, Option<TextRange>>) -> SearchScope { | ||
23 | SearchScope { entries } | ||
24 | } | ||
25 | pub fn single_file(file: FileId) -> SearchScope { | ||
26 | SearchScope::new(std::iter::once((file, None)).collect()) | ||
27 | } | ||
28 | pub(crate) fn intersection(&self, other: &SearchScope) -> SearchScope { | ||
29 | let (mut small, mut large) = (&self.entries, &other.entries); | ||
30 | if small.len() > large.len() { | ||
31 | mem::swap(&mut small, &mut large) | ||
32 | } | ||
33 | |||
34 | let res = small | ||
35 | .iter() | ||
36 | .filter_map(|(file_id, r1)| { | ||
37 | let r2 = large.get(file_id)?; | ||
38 | let r = intersect_ranges(*r1, *r2)?; | ||
39 | Some((*file_id, r)) | ||
40 | }) | ||
41 | .collect(); | ||
42 | return SearchScope::new(res); | ||
43 | |||
44 | fn intersect_ranges( | ||
45 | r1: Option<TextRange>, | ||
46 | r2: Option<TextRange>, | ||
47 | ) -> Option<Option<TextRange>> { | ||
48 | match (r1, r2) { | ||
49 | (None, r) | (r, None) => Some(r), | ||
50 | (Some(r1), Some(r2)) => { | ||
51 | let r = r1.intersection(&r2)?; | ||
52 | Some(Some(r)) | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | impl IntoIterator for SearchScope { | ||
60 | type Item = (FileId, Option<TextRange>); | ||
61 | type IntoIter = std::collections::hash_map::IntoIter<FileId, Option<TextRange>>; | ||
62 | fn into_iter(self) -> Self::IntoIter { | ||
63 | self.entries.into_iter() | ||
64 | } | ||
65 | } | ||
66 | |||
16 | impl NameDefinition { | 67 | impl NameDefinition { |
17 | pub(crate) fn search_scope(&self, db: &RootDatabase) -> FxHashSet<(FileId, Option<TextRange>)> { | 68 | pub(crate) fn search_scope(&self, db: &RootDatabase) -> SearchScope { |
18 | let _p = profile("search_scope"); | 69 | let _p = profile("search_scope"); |
19 | 70 | ||
20 | let module_src = self.container.definition_source(db); | 71 | let module_src = self.container.definition_source(db); |
21 | let file_id = module_src.file_id.original_file(db); | 72 | let file_id = module_src.file_id.original_file(db); |
22 | 73 | ||
23 | if let NameKind::Pat((def, _)) = self.kind { | 74 | if let NameKind::Pat((def, _)) = self.kind { |
24 | let mut res = FxHashSet::default(); | 75 | let mut res = FxHashMap::default(); |
25 | let range = match def { | 76 | let range = match def { |
26 | DefWithBody::Function(f) => f.source(db).ast.syntax().text_range(), | 77 | DefWithBody::Function(f) => f.source(db).ast.syntax().text_range(), |
27 | DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), | 78 | DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), |
28 | DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), | 79 | DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), |
29 | }; | 80 | }; |
30 | res.insert((file_id, Some(range))); | 81 | res.insert(file_id, Some(range)); |
31 | return res; | 82 | return SearchScope::new(res); |
32 | } | 83 | } |
33 | 84 | ||
34 | let vis = | 85 | let vis = |
@@ -36,37 +87,37 @@ impl NameDefinition { | |||
36 | 87 | ||
37 | if vis.as_str() == "pub(super)" { | 88 | if vis.as_str() == "pub(super)" { |
38 | if let Some(parent_module) = self.container.parent(db) { | 89 | if let Some(parent_module) = self.container.parent(db) { |
39 | let mut files = FxHashSet::default(); | 90 | let mut res = FxHashMap::default(); |
40 | let parent_src = parent_module.definition_source(db); | 91 | let parent_src = parent_module.definition_source(db); |
41 | let file_id = parent_src.file_id.original_file(db); | 92 | let file_id = parent_src.file_id.original_file(db); |
42 | 93 | ||
43 | match parent_src.ast { | 94 | match parent_src.ast { |
44 | ModuleSource::Module(m) => { | 95 | ModuleSource::Module(m) => { |
45 | let range = Some(m.syntax().text_range()); | 96 | let range = Some(m.syntax().text_range()); |
46 | files.insert((file_id, range)); | 97 | res.insert(file_id, range); |
47 | } | 98 | } |
48 | ModuleSource::SourceFile(_) => { | 99 | ModuleSource::SourceFile(_) => { |
49 | files.insert((file_id, None)); | 100 | res.insert(file_id, None); |
50 | files.extend(parent_module.children(db).map(|m| { | 101 | res.extend(parent_module.children(db).map(|m| { |
51 | let src = m.definition_source(db); | 102 | let src = m.definition_source(db); |
52 | (src.file_id.original_file(db), None) | 103 | (src.file_id.original_file(db), None) |
53 | })); | 104 | })); |
54 | } | 105 | } |
55 | } | 106 | } |
56 | return files; | 107 | return SearchScope::new(res); |
57 | } | 108 | } |
58 | } | 109 | } |
59 | 110 | ||
60 | if vis.as_str() != "" { | 111 | if vis.as_str() != "" { |
61 | let source_root_id = db.file_source_root(file_id); | 112 | let source_root_id = db.file_source_root(file_id); |
62 | let source_root = db.source_root(source_root_id); | 113 | let source_root = db.source_root(source_root_id); |
63 | let mut files = | 114 | let mut res = |
64 | source_root.walk().map(|id| (id.into(), None)).collect::<FxHashSet<_>>(); | 115 | source_root.walk().map(|id| (id.into(), None)).collect::<FxHashMap<_, _>>(); |
65 | 116 | ||
66 | // FIXME: add "pub(in path)" | 117 | // FIXME: add "pub(in path)" |
67 | 118 | ||
68 | if vis.as_str() == "pub(crate)" { | 119 | if vis.as_str() == "pub(crate)" { |
69 | return files; | 120 | return SearchScope::new(res); |
70 | } | 121 | } |
71 | if vis.as_str() == "pub" { | 122 | if vis.as_str() == "pub" { |
72 | let krate = self.container.krate(db).unwrap(); | 123 | let krate = self.container.krate(db).unwrap(); |
@@ -77,19 +128,19 @@ impl NameDefinition { | |||
77 | let root_file = crate_graph.crate_root(crate_id); | 128 | let root_file = crate_graph.crate_root(crate_id); |
78 | let source_root_id = db.file_source_root(root_file); | 129 | let source_root_id = db.file_source_root(root_file); |
79 | let source_root = db.source_root(source_root_id); | 130 | let source_root = db.source_root(source_root_id); |
80 | files.extend(source_root.walk().map(|id| (id.into(), None))); | 131 | res.extend(source_root.walk().map(|id| (id.into(), None))); |
81 | } | 132 | } |
82 | } | 133 | } |
83 | return files; | 134 | return SearchScope::new(res); |
84 | } | 135 | } |
85 | } | 136 | } |
86 | 137 | ||
87 | let mut res = FxHashSet::default(); | 138 | let mut res = FxHashMap::default(); |
88 | let range = match module_src.ast { | 139 | let range = match module_src.ast { |
89 | ModuleSource::Module(m) => Some(m.syntax().text_range()), | 140 | ModuleSource::Module(m) => Some(m.syntax().text_range()), |
90 | ModuleSource::SourceFile(_) => None, | 141 | ModuleSource::SourceFile(_) => None, |
91 | }; | 142 | }; |
92 | res.insert((file_id, range)); | 143 | res.insert(file_id, range); |
93 | res | 144 | SearchScope::new(res) |
94 | } | 145 | } |
95 | } | 146 | } |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index e65f075a6..a29971d10 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -9,7 +9,9 @@ use lsp_types::{ | |||
9 | Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse, | 9 | Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, PrepareRenameResponse, |
10 | Range, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, | 10 | Range, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, |
11 | }; | 11 | }; |
12 | use ra_ide_api::{AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind}; | 12 | use ra_ide_api::{ |
13 | AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind, SearchScope, | ||
14 | }; | ||
13 | use ra_prof::profile; | 15 | use ra_prof::profile; |
14 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; | 16 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; |
15 | use rustc_hash::FxHashMap; | 17 | use rustc_hash::FxHashMap; |
@@ -485,7 +487,7 @@ pub fn handle_references( | |||
485 | let _p = profile("handle_references"); | 487 | let _p = profile("handle_references"); |
486 | let position = params.text_document_position.try_conv_with(&world)?; | 488 | let position = params.text_document_position.try_conv_with(&world)?; |
487 | 489 | ||
488 | let refs = match world.analysis().find_all_refs(position)? { | 490 | let refs = match world.analysis().find_all_refs(position, None)? { |
489 | None => return Ok(None), | 491 | None => return Ok(None), |
490 | Some(refs) => refs, | 492 | Some(refs) => refs, |
491 | }; | 493 | }; |
@@ -748,7 +750,10 @@ pub fn handle_document_highlight( | |||
748 | let file_id = params.text_document.try_conv_with(&world)?; | 750 | let file_id = params.text_document.try_conv_with(&world)?; |
749 | let line_index = world.analysis().file_line_index(file_id)?; | 751 | let line_index = world.analysis().file_line_index(file_id)?; |
750 | 752 | ||
751 | let refs = match world.analysis().find_all_refs(params.try_conv_with(&world)?)? { | 753 | let refs = match world |
754 | .analysis() | ||
755 | .find_all_refs(params.try_conv_with(&world)?, Some(SearchScope::single_file(file_id)))? | ||
756 | { | ||
752 | None => return Ok(None), | 757 | None => return Ok(None), |
753 | Some(refs) => refs, | 758 | Some(refs) => refs, |
754 | }; | 759 | }; |