diff options
-rw-r--r-- | Cargo.lock | 57 | ||||
-rw-r--r-- | crates/ra_cli/src/analysis_bench.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 86 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 3 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_tree.rs | 14 | ||||
-rw-r--r-- | crates/ra_ide_api/src/typing.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 14 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 64 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 7 |
9 files changed, 133 insertions, 118 deletions
diff --git a/Cargo.lock b/Cargo.lock index 528a33224..fd4d876de 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -291,11 +291,10 @@ dependencies = [ | |||
291 | 291 | ||
292 | [[package]] | 292 | [[package]] |
293 | name = "crossbeam-channel" | 293 | name = "crossbeam-channel" |
294 | version = "0.3.8" | 294 | version = "0.3.9" |
295 | source = "registry+https://github.com/rust-lang/crates.io-index" | 295 | source = "registry+https://github.com/rust-lang/crates.io-index" |
296 | dependencies = [ | 296 | dependencies = [ |
297 | "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 297 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", |
298 | "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
299 | ] | 298 | ] |
300 | 299 | ||
301 | [[package]] | 300 | [[package]] |
@@ -303,21 +302,21 @@ name = "crossbeam-deque" | |||
303 | version = "0.6.3" | 302 | version = "0.6.3" |
304 | source = "registry+https://github.com/rust-lang/crates.io-index" | 303 | source = "registry+https://github.com/rust-lang/crates.io-index" |
305 | dependencies = [ | 304 | dependencies = [ |
306 | "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | 305 | "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", |
307 | "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 306 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", |
308 | ] | 307 | ] |
309 | 308 | ||
310 | [[package]] | 309 | [[package]] |
311 | name = "crossbeam-epoch" | 310 | name = "crossbeam-epoch" |
312 | version = "0.7.1" | 311 | version = "0.7.2" |
313 | source = "registry+https://github.com/rust-lang/crates.io-index" | 312 | source = "registry+https://github.com/rust-lang/crates.io-index" |
314 | dependencies = [ | 313 | dependencies = [ |
315 | "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", | 314 | "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", |
316 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | 315 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", |
317 | "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 316 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", |
318 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 317 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
319 | "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 318 | "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", |
320 | "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", | 319 | "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
321 | ] | 320 | ] |
322 | 321 | ||
323 | [[package]] | 322 | [[package]] |
@@ -325,12 +324,12 @@ name = "crossbeam-queue" | |||
325 | version = "0.1.2" | 324 | version = "0.1.2" |
326 | source = "registry+https://github.com/rust-lang/crates.io-index" | 325 | source = "registry+https://github.com/rust-lang/crates.io-index" |
327 | dependencies = [ | 326 | dependencies = [ |
328 | "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 327 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", |
329 | ] | 328 | ] |
330 | 329 | ||
331 | [[package]] | 330 | [[package]] |
332 | name = "crossbeam-utils" | 331 | name = "crossbeam-utils" |
333 | version = "0.6.5" | 332 | version = "0.6.6" |
334 | source = "registry+https://github.com/rust-lang/crates.io-index" | 333 | source = "registry+https://github.com/rust-lang/crates.io-index" |
335 | dependencies = [ | 334 | dependencies = [ |
336 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | 335 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -537,7 +536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
537 | name = "gen_lsp_server" | 536 | name = "gen_lsp_server" |
538 | version = "0.2.0" | 537 | version = "0.2.0" |
539 | dependencies = [ | 538 | dependencies = [ |
540 | "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | 539 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", |
541 | "flexi_logger 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", | 540 | "flexi_logger 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", |
542 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 541 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
543 | "lsp-types 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)", | 542 | "lsp-types 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -804,8 +803,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
804 | 803 | ||
805 | [[package]] | 804 | [[package]] |
806 | name = "memoffset" | 805 | name = "memoffset" |
807 | version = "0.2.1" | 806 | version = "0.5.1" |
808 | source = "registry+https://github.com/rust-lang/crates.io-index" | 807 | source = "registry+https://github.com/rust-lang/crates.io-index" |
808 | dependencies = [ | ||
809 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
810 | ] | ||
809 | 811 | ||
810 | [[package]] | 812 | [[package]] |
811 | name = "mio" | 813 | name = "mio" |
@@ -1239,7 +1241,7 @@ dependencies = [ | |||
1239 | name = "ra_lsp_server" | 1241 | name = "ra_lsp_server" |
1240 | version = "0.1.0" | 1242 | version = "0.1.0" |
1241 | dependencies = [ | 1243 | dependencies = [ |
1242 | "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1244 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", |
1243 | "flexi_logger 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1245 | "flexi_logger 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1244 | "gen_lsp_server 0.2.0", | 1246 | "gen_lsp_server 0.2.0", |
1245 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 1247 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1362,7 +1364,7 @@ name = "ra_vfs" | |||
1362 | version = "0.2.5" | 1364 | version = "0.2.5" |
1363 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1365 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1364 | dependencies = [ | 1366 | dependencies = [ |
1365 | "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1367 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", |
1366 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 1368 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
1367 | "notify 4.0.12 (registry+https://github.com/rust-lang/crates.io-index)", | 1369 | "notify 4.0.12 (registry+https://github.com/rust-lang/crates.io-index)", |
1368 | "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1370 | "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1396,7 +1398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1396 | dependencies = [ | 1398 | dependencies = [ |
1397 | "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1399 | "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1398 | "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", | 1400 | "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", |
1399 | "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1401 | "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1400 | "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1402 | "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1401 | "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1403 | "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1402 | "rand_pcg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1404 | "rand_pcg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1413,10 +1415,9 @@ dependencies = [ | |||
1413 | 1415 | ||
1414 | [[package]] | 1416 | [[package]] |
1415 | name = "rand_chacha" | 1417 | name = "rand_chacha" |
1416 | version = "0.2.0" | 1418 | version = "0.2.1" |
1417 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1419 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1418 | dependencies = [ | 1420 | dependencies = [ |
1419 | "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1420 | "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1421 | "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1421 | "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1422 | "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1422 | ] | 1423 | ] |
@@ -1532,7 +1533,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1532 | dependencies = [ | 1533 | dependencies = [ |
1533 | "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1534 | "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1534 | "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1535 | "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1535 | "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1536 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1536 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1537 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1537 | "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1538 | "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1538 | ] | 1539 | ] |
@@ -1666,11 +1667,6 @@ dependencies = [ | |||
1666 | 1667 | ||
1667 | [[package]] | 1668 | [[package]] |
1668 | name = "scopeguard" | 1669 | name = "scopeguard" |
1669 | version = "0.3.3" | ||
1670 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1671 | |||
1672 | [[package]] | ||
1673 | name = "scopeguard" | ||
1674 | version = "1.0.0" | 1670 | version = "1.0.0" |
1675 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1671 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1676 | 1672 | ||
@@ -1896,7 +1892,7 @@ dependencies = [ | |||
1896 | name = "thread_worker" | 1892 | name = "thread_worker" |
1897 | version = "0.1.0" | 1893 | version = "0.1.0" |
1898 | dependencies = [ | 1894 | dependencies = [ |
1899 | "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1895 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", |
1900 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 1896 | "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
1901 | ] | 1897 | ] |
1902 | 1898 | ||
@@ -2161,11 +2157,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2161 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 2157 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
2162 | "checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" | 2158 | "checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" |
2163 | "checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035" | 2159 | "checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035" |
2164 | "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" | 2160 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" |
2165 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" | 2161 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" |
2166 | "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" | 2162 | "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" |
2167 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" | 2163 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" |
2168 | "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" | 2164 | "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" |
2169 | "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" | 2165 | "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" |
2170 | "checksum derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c3fd04571b29c91cfbe1e7c9a228e069ac8635f180ffb4ccd6a6907617ee8bb0" | 2166 | "checksum derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c3fd04571b29c91cfbe1e7c9a228e069ac8635f180ffb4ccd6a6907617ee8bb0" |
2171 | "checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" | 2167 | "checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" |
@@ -2226,7 +2222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2226 | "checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" | 2222 | "checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" |
2227 | "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" | 2223 | "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" |
2228 | "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" | 2224 | "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" |
2229 | "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" | 2225 | "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" |
2230 | "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" | 2226 | "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" |
2231 | "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" | 2227 | "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" |
2232 | "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" | 2228 | "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" |
@@ -2264,7 +2260,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2264 | "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" | 2260 | "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" |
2265 | "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" | 2261 | "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" |
2266 | "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" | 2262 | "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" |
2267 | "checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" | 2263 | "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" |
2268 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" | 2264 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" |
2269 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" | 2265 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" |
2270 | "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" | 2266 | "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" |
@@ -2293,7 +2289,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2293 | "checksum salsa 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2891cd628406e8a0ca714b827511de1bff76f796e3382cc72a3de732ccad5aea" | 2289 | "checksum salsa 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2891cd628406e8a0ca714b827511de1bff76f796e3382cc72a3de732ccad5aea" |
2294 | "checksum salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7f1e25ca2b995bdf032946174929d62156ffd57abd7ff88dc6f9bdeb5ac0c59" | 2290 | "checksum salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7f1e25ca2b995bdf032946174929d62156ffd57abd7ff88dc6f9bdeb5ac0c59" |
2295 | "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" | 2291 | "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" |
2296 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" | ||
2297 | "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" | 2292 | "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" |
2298 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | 2293 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" |
2299 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" | 2294 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" |
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 639ac763e..5e9d0c16d 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs | |||
@@ -55,7 +55,7 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
55 | Op::Complete { line, column, .. } => { | 55 | Op::Complete { line, column, .. } => { |
56 | let offset = host | 56 | let offset = host |
57 | .analysis() | 57 | .analysis() |
58 | .file_line_index(file_id) | 58 | .file_line_index(file_id)? |
59 | .offset(LineCol { line, col_utf16: column }); | 59 | .offset(LineCol { line, col_utf16: column }); |
60 | let file_postion = FilePosition { file_id, offset }; | 60 | let file_postion = FilePosition { file_id, offset }; |
61 | 61 | ||
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 16ffb03ce..edb646c11 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -317,24 +317,24 @@ impl Analysis { | |||
317 | } | 317 | } |
318 | 318 | ||
319 | /// Debug info about the current state of the analysis | 319 | /// Debug info about the current state of the analysis |
320 | pub fn status(&self) -> String { | 320 | pub fn status(&self) -> Cancelable<String> { |
321 | status::status(&*self.db) | 321 | self.with_db(|db| status::status(&*db)) |
322 | } | 322 | } |
323 | 323 | ||
324 | /// Gets the text of the source file. | 324 | /// Gets the text of the source file. |
325 | pub fn file_text(&self, file_id: FileId) -> Arc<String> { | 325 | pub fn file_text(&self, file_id: FileId) -> Cancelable<Arc<String>> { |
326 | self.db.file_text(file_id) | 326 | self.with_db(|db| db.file_text(file_id)) |
327 | } | 327 | } |
328 | 328 | ||
329 | /// Gets the syntax tree of the file. | 329 | /// Gets the syntax tree of the file. |
330 | pub fn parse(&self, file_id: FileId) -> SourceFile { | 330 | pub fn parse(&self, file_id: FileId) -> Cancelable<SourceFile> { |
331 | self.db.parse(file_id).tree() | 331 | self.with_db(|db| db.parse(file_id).tree()) |
332 | } | 332 | } |
333 | 333 | ||
334 | /// Gets the file's `LineIndex`: data structure to convert between absolute | 334 | /// Gets the file's `LineIndex`: data structure to convert between absolute |
335 | /// offsets and line/column representation. | 335 | /// offsets and line/column representation. |
336 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 336 | pub fn file_line_index(&self, file_id: FileId) -> Cancelable<Arc<LineIndex>> { |
337 | self.db.line_index(file_id) | 337 | self.with_db(|db| db.line_index(file_id)) |
338 | } | 338 | } |
339 | 339 | ||
340 | /// Selects the next syntactic nodes encompassing the range. | 340 | /// Selects the next syntactic nodes encompassing the range. |
@@ -344,58 +344,67 @@ impl Analysis { | |||
344 | 344 | ||
345 | /// Returns position of the matching brace (all types of braces are | 345 | /// Returns position of the matching brace (all types of braces are |
346 | /// supported). | 346 | /// supported). |
347 | pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> { | 347 | pub fn matching_brace(&self, position: FilePosition) -> Cancelable<Option<TextUnit>> { |
348 | let parse = self.db.parse(position.file_id); | 348 | self.with_db(|db| { |
349 | let file = parse.tree(); | 349 | let parse = db.parse(position.file_id); |
350 | matching_brace::matching_brace(&file, position.offset) | 350 | let file = parse.tree(); |
351 | matching_brace::matching_brace(&file, position.offset) | ||
352 | }) | ||
351 | } | 353 | } |
352 | 354 | ||
353 | /// Returns a syntax tree represented as `String`, for debug purposes. | 355 | /// Returns a syntax tree represented as `String`, for debug purposes. |
354 | // FIXME: use a better name here. | 356 | // FIXME: use a better name here. |
355 | pub fn syntax_tree(&self, file_id: FileId, text_range: Option<TextRange>) -> String { | 357 | pub fn syntax_tree( |
356 | syntax_tree::syntax_tree(&self.db, file_id, text_range) | 358 | &self, |
359 | file_id: FileId, | ||
360 | text_range: Option<TextRange>, | ||
361 | ) -> Cancelable<String> { | ||
362 | self.with_db(|db| syntax_tree::syntax_tree(&db, file_id, text_range)) | ||
357 | } | 363 | } |
358 | 364 | ||
359 | /// Returns an edit to remove all newlines in the range, cleaning up minor | 365 | /// Returns an edit to remove all newlines in the range, cleaning up minor |
360 | /// stuff like trailing commas. | 366 | /// stuff like trailing commas. |
361 | pub fn join_lines(&self, frange: FileRange) -> SourceChange { | 367 | pub fn join_lines(&self, frange: FileRange) -> Cancelable<SourceChange> { |
362 | let parse = self.db.parse(frange.file_id); | 368 | self.with_db(|db| { |
363 | let file_edit = SourceFileEdit { | 369 | let parse = db.parse(frange.file_id); |
364 | file_id: frange.file_id, | 370 | let file_edit = SourceFileEdit { |
365 | edit: join_lines::join_lines(&parse.tree(), frange.range), | 371 | file_id: frange.file_id, |
366 | }; | 372 | edit: join_lines::join_lines(&parse.tree(), frange.range), |
367 | SourceChange::source_file_edit("join lines", file_edit) | 373 | }; |
374 | SourceChange::source_file_edit("join lines", file_edit) | ||
375 | }) | ||
368 | } | 376 | } |
369 | 377 | ||
370 | /// Returns an edit which should be applied when opening a new line, fixing | 378 | /// Returns an edit which should be applied when opening a new line, fixing |
371 | /// up minor stuff like continuing the comment. | 379 | /// up minor stuff like continuing the comment. |
372 | pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { | 380 | pub fn on_enter(&self, position: FilePosition) -> Cancelable<Option<SourceChange>> { |
373 | typing::on_enter(&self.db, position) | 381 | self.with_db(|db| typing::on_enter(&db, position)) |
374 | } | 382 | } |
375 | 383 | ||
376 | /// Returns an edit which should be applied after `=` was typed. Primarily, | 384 | /// Returns an edit which should be applied after `=` was typed. Primarily, |
377 | /// this works when adding `let =`. | 385 | /// this works when adding `let =`. |
378 | // FIXME: use a snippet completion instead of this hack here. | 386 | // FIXME: use a snippet completion instead of this hack here. |
379 | pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { | 387 | pub fn on_eq_typed(&self, position: FilePosition) -> Cancelable<Option<SourceChange>> { |
380 | let parse = self.db.parse(position.file_id); | 388 | self.with_db(|db| { |
381 | let file = parse.tree(); | 389 | let parse = db.parse(position.file_id); |
382 | let edit = typing::on_eq_typed(&file, position.offset)?; | 390 | let file = parse.tree(); |
383 | Some(SourceChange::source_file_edit( | 391 | let edit = typing::on_eq_typed(&file, position.offset)?; |
384 | "add semicolon", | 392 | Some(SourceChange::source_file_edit( |
385 | SourceFileEdit { edit, file_id: position.file_id }, | 393 | "add semicolon", |
386 | )) | 394 | SourceFileEdit { edit, file_id: position.file_id }, |
395 | )) | ||
396 | }) | ||
387 | } | 397 | } |
388 | 398 | ||
389 | /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. | 399 | /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. |
390 | pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> { | 400 | pub fn on_dot_typed(&self, position: FilePosition) -> Cancelable<Option<SourceChange>> { |
391 | typing::on_dot_typed(&self.db, position) | 401 | self.with_db(|db| typing::on_dot_typed(&db, position)) |
392 | } | 402 | } |
393 | 403 | ||
394 | /// Returns a tree representation of symbols in the file. Useful to draw a | 404 | /// Returns a tree representation of symbols in the file. Useful to draw a |
395 | /// file outline. | 405 | /// file outline. |
396 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { | 406 | pub fn file_structure(&self, file_id: FileId) -> Cancelable<Vec<StructureNode>> { |
397 | let parse = self.db.parse(file_id); | 407 | self.with_db(|db| file_structure(&db.parse(file_id).tree())) |
398 | file_structure(&parse.tree()) | ||
399 | } | 408 | } |
400 | 409 | ||
401 | /// Returns a list of the places in the file where type hints can be displayed. | 410 | /// Returns a list of the places in the file where type hints can be displayed. |
@@ -404,9 +413,8 @@ impl Analysis { | |||
404 | } | 413 | } |
405 | 414 | ||
406 | /// Returns the set of folding ranges. | 415 | /// Returns the set of folding ranges. |
407 | pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> { | 416 | pub fn folding_ranges(&self, file_id: FileId) -> Cancelable<Vec<Fold>> { |
408 | let parse = self.db.parse(file_id); | 417 | self.with_db(|db| folding_ranges::folding_ranges(&db.parse(file_id).tree())) |
409 | folding_ranges::folding_ranges(&parse.tree()) | ||
410 | } | 418 | } |
411 | 419 | ||
412 | /// Fuzzy searches for a symbol. | 420 | /// Fuzzy searches for a symbol. |
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 5c74d3e36..89984e642 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -372,7 +372,8 @@ mod tests { | |||
372 | } | 372 | } |
373 | } | 373 | } |
374 | } | 374 | } |
375 | let result = text_edit_builder.finish().apply(&*analysis.file_text(file_id.unwrap())); | 375 | let result = |
376 | text_edit_builder.finish().apply(&*analysis.file_text(file_id.unwrap()).unwrap()); | ||
376 | assert_eq_text!(expected, &*result); | 377 | assert_eq_text!(expected, &*result); |
377 | } | 378 | } |
378 | } | 379 | } |
diff --git a/crates/ra_ide_api/src/syntax_tree.rs b/crates/ra_ide_api/src/syntax_tree.rs index a07e670fa..dd31b9093 100644 --- a/crates/ra_ide_api/src/syntax_tree.rs +++ b/crates/ra_ide_api/src/syntax_tree.rs | |||
@@ -101,7 +101,7 @@ mod tests { | |||
101 | fn test_syntax_tree_without_range() { | 101 | fn test_syntax_tree_without_range() { |
102 | // Basic syntax | 102 | // Basic syntax |
103 | let (analysis, file_id) = single_file(r#"fn foo() {}"#); | 103 | let (analysis, file_id) = single_file(r#"fn foo() {}"#); |
104 | let syn = analysis.syntax_tree(file_id, None); | 104 | let syn = analysis.syntax_tree(file_id, None).unwrap(); |
105 | 105 | ||
106 | assert_eq_text!( | 106 | assert_eq_text!( |
107 | syn.trim(), | 107 | syn.trim(), |
@@ -133,7 +133,7 @@ fn test() { | |||
133 | }"# | 133 | }"# |
134 | .trim(), | 134 | .trim(), |
135 | ); | 135 | ); |
136 | let syn = analysis.syntax_tree(file_id, None); | 136 | let syn = analysis.syntax_tree(file_id, None).unwrap(); |
137 | 137 | ||
138 | assert_eq_text!( | 138 | assert_eq_text!( |
139 | syn.trim(), | 139 | syn.trim(), |
@@ -176,7 +176,7 @@ SOURCE_FILE@[0; 60) | |||
176 | #[test] | 176 | #[test] |
177 | fn test_syntax_tree_with_range() { | 177 | fn test_syntax_tree_with_range() { |
178 | let (analysis, range) = single_file_with_range(r#"<|>fn foo() {}<|>"#.trim()); | 178 | let (analysis, range) = single_file_with_range(r#"<|>fn foo() {}<|>"#.trim()); |
179 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)); | 179 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); |
180 | 180 | ||
181 | assert_eq_text!( | 181 | assert_eq_text!( |
182 | syn.trim(), | 182 | syn.trim(), |
@@ -206,7 +206,7 @@ FN_DEF@[0; 11) | |||
206 | }"# | 206 | }"# |
207 | .trim(), | 207 | .trim(), |
208 | ); | 208 | ); |
209 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)); | 209 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); |
210 | 210 | ||
211 | assert_eq_text!( | 211 | assert_eq_text!( |
212 | syn.trim(), | 212 | syn.trim(), |
@@ -244,7 +244,7 @@ fn bar() { | |||
244 | }"# | 244 | }"# |
245 | .trim(), | 245 | .trim(), |
246 | ); | 246 | ); |
247 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)); | 247 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); |
248 | assert_eq_text!( | 248 | assert_eq_text!( |
249 | syn.trim(), | 249 | syn.trim(), |
250 | r#" | 250 | r#" |
@@ -278,7 +278,7 @@ fn bar() { | |||
278 | }"### | 278 | }"### |
279 | .trim(), | 279 | .trim(), |
280 | ); | 280 | ); |
281 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)); | 281 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); |
282 | assert_eq_text!( | 282 | assert_eq_text!( |
283 | syn.trim(), | 283 | syn.trim(), |
284 | r#" | 284 | r#" |
@@ -311,7 +311,7 @@ fn bar() { | |||
311 | }"### | 311 | }"### |
312 | .trim(), | 312 | .trim(), |
313 | ); | 313 | ); |
314 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)); | 314 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); |
315 | assert_eq_text!( | 315 | assert_eq_text!( |
316 | syn.trim(), | 316 | syn.trim(), |
317 | r#" | 317 | r#" |
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs index 6b3fd5904..2d4491442 100644 --- a/crates/ra_ide_api/src/typing.rs +++ b/crates/ra_ide_api/src/typing.rs | |||
@@ -195,7 +195,7 @@ fn foo() { | |||
195 | edit.insert(offset, ".".to_string()); | 195 | edit.insert(offset, ".".to_string()); |
196 | let before = edit.finish().apply(&before); | 196 | let before = edit.finish().apply(&before); |
197 | let (analysis, file_id) = single_file(&before); | 197 | let (analysis, file_id) = single_file(&before); |
198 | if let Some(result) = analysis.on_dot_typed(FilePosition { offset, file_id }) { | 198 | if let Some(result) = analysis.on_dot_typed(FilePosition { offset, file_id }).unwrap() { |
199 | assert_eq!(result.source_file_edits.len(), 1); | 199 | assert_eq!(result.source_file_edits.len(), 1); |
200 | let actual = result.source_file_edits[0].edit.apply(&before); | 200 | let actual = result.source_file_edits[0].edit.apply(&before); |
201 | assert_eq_text!(after, &actual); | 201 | assert_eq_text!(after, &actual); |
@@ -377,7 +377,7 @@ fn foo() { | |||
377 | fn apply_on_enter(before: &str) -> Option<String> { | 377 | fn apply_on_enter(before: &str) -> Option<String> { |
378 | let (offset, before) = extract_offset(before); | 378 | let (offset, before) = extract_offset(before); |
379 | let (analysis, file_id) = single_file(&before); | 379 | let (analysis, file_id) = single_file(&before); |
380 | let result = analysis.on_enter(FilePosition { offset, file_id })?; | 380 | let result = analysis.on_enter(FilePosition { offset, file_id }).unwrap()?; |
381 | 381 | ||
382 | assert_eq!(result.source_file_edits.len(), 1); | 382 | assert_eq!(result.source_file_edits.len(), 1); |
383 | let actual = result.source_file_edits[0].edit.apply(&before); | 383 | let actual = result.source_file_edits[0].edit.apply(&before); |
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 82c7e757f..6b3be444f 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -272,7 +272,7 @@ impl<'a> TryConvWith for &'a TextDocumentPositionParams { | |||
272 | type Output = FilePosition; | 272 | type Output = FilePosition; |
273 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<FilePosition> { | 273 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<FilePosition> { |
274 | let file_id = self.text_document.try_conv_with(world)?; | 274 | let file_id = self.text_document.try_conv_with(world)?; |
275 | let line_index = world.analysis().file_line_index(file_id); | 275 | let line_index = world.analysis().file_line_index(file_id)?; |
276 | let offset = self.position.conv_with(&line_index); | 276 | let offset = self.position.conv_with(&line_index); |
277 | Ok(FilePosition { file_id, offset }) | 277 | Ok(FilePosition { file_id, offset }) |
278 | } | 278 | } |
@@ -283,7 +283,7 @@ impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) { | |||
283 | type Output = FileRange; | 283 | type Output = FileRange; |
284 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileRange> { | 284 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileRange> { |
285 | let file_id = self.0.try_conv_with(world)?; | 285 | let file_id = self.0.try_conv_with(world)?; |
286 | let line_index = world.analysis().file_line_index(file_id); | 286 | let line_index = world.analysis().file_line_index(file_id)?; |
287 | let range = self.1.conv_with(&line_index); | 287 | let range = self.1.conv_with(&line_index); |
288 | Ok(FileRange { file_id, range }) | 288 | Ok(FileRange { file_id, range }) |
289 | } | 289 | } |
@@ -308,7 +308,7 @@ impl TryConvWith for SourceChange { | |||
308 | let cursor_position = match self.cursor_position { | 308 | let cursor_position = match self.cursor_position { |
309 | None => None, | 309 | None => None, |
310 | Some(pos) => { | 310 | Some(pos) => { |
311 | let line_index = world.analysis().file_line_index(pos.file_id); | 311 | let line_index = world.analysis().file_line_index(pos.file_id)?; |
312 | let edit = self | 312 | let edit = self |
313 | .source_file_edits | 313 | .source_file_edits |
314 | .iter() | 314 | .iter() |
@@ -349,7 +349,7 @@ impl TryConvWith for SourceFileEdit { | |||
349 | uri: self.file_id.try_conv_with(world)?, | 349 | uri: self.file_id.try_conv_with(world)?, |
350 | version: None, | 350 | version: None, |
351 | }; | 351 | }; |
352 | let line_index = world.analysis().file_line_index(self.file_id); | 352 | let line_index = world.analysis().file_line_index(self.file_id)?; |
353 | let edits = self.edit.as_atoms().iter().map_conv_with(&line_index).collect(); | 353 | let edits = self.edit.as_atoms().iter().map_conv_with(&line_index).collect(); |
354 | Ok(TextDocumentEdit { text_document, edits }) | 354 | Ok(TextDocumentEdit { text_document, edits }) |
355 | } | 355 | } |
@@ -378,7 +378,7 @@ impl TryConvWith for &NavigationTarget { | |||
378 | type Ctx = WorldSnapshot; | 378 | type Ctx = WorldSnapshot; |
379 | type Output = Location; | 379 | type Output = Location; |
380 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<Location> { | 380 | fn try_conv_with(self, world: &WorldSnapshot) -> Result<Location> { |
381 | let line_index = world.analysis().file_line_index(self.file_id()); | 381 | let line_index = world.analysis().file_line_index(self.file_id())?; |
382 | let range = self.range(); | 382 | let range = self.range(); |
383 | to_location(self.file_id(), range, &world, &line_index) | 383 | to_location(self.file_id(), range, &world, &line_index) |
384 | } | 384 | } |
@@ -391,8 +391,8 @@ impl TryConvWith for (FileId, RangeInfo<NavigationTarget>) { | |||
391 | let (src_file_id, target) = self; | 391 | let (src_file_id, target) = self; |
392 | 392 | ||
393 | let target_uri = target.info.file_id().try_conv_with(world)?; | 393 | let target_uri = target.info.file_id().try_conv_with(world)?; |
394 | let src_line_index = world.analysis().file_line_index(src_file_id); | 394 | let src_line_index = world.analysis().file_line_index(src_file_id)?; |
395 | let tgt_line_index = world.analysis().file_line_index(target.info.file_id()); | 395 | let tgt_line_index = world.analysis().file_line_index(target.info.file_id())?; |
396 | 396 | ||
397 | let target_range = target.info.full_range().conv_with(&tgt_line_index); | 397 | let target_range = target.info.full_range().conv_with(&tgt_line_index); |
398 | 398 | ||
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5bf950a53..14619ede2 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -39,9 +39,9 @@ pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> { | |||
39 | 39 | ||
40 | pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) -> Result<String> { | 40 | pub fn handle_syntax_tree(world: WorldSnapshot, params: req::SyntaxTreeParams) -> Result<String> { |
41 | let id = params.text_document.try_conv_with(&world)?; | 41 | let id = params.text_document.try_conv_with(&world)?; |
42 | let line_index = world.analysis().file_line_index(id); | 42 | let line_index = world.analysis().file_line_index(id)?; |
43 | let text_range = params.range.map(|p| p.conv_with(&line_index)); | 43 | let text_range = params.range.map(|p| p.conv_with(&line_index)); |
44 | let res = world.analysis().syntax_tree(id, text_range); | 44 | let res = world.analysis().syntax_tree(id, text_range)?; |
45 | Ok(res) | 45 | Ok(res) |
46 | } | 46 | } |
47 | 47 | ||
@@ -55,7 +55,7 @@ pub fn handle_extend_selection( | |||
55 | use the new selection range API in LSP", | 55 | use the new selection range API in LSP", |
56 | ); | 56 | ); |
57 | let file_id = params.text_document.try_conv_with(&world)?; | 57 | let file_id = params.text_document.try_conv_with(&world)?; |
58 | let line_index = world.analysis().file_line_index(file_id); | 58 | let line_index = world.analysis().file_line_index(file_id)?; |
59 | let selections = params | 59 | let selections = params |
60 | .selections | 60 | .selections |
61 | .into_iter() | 61 | .into_iter() |
@@ -72,7 +72,7 @@ pub fn handle_selection_range( | |||
72 | ) -> Result<Vec<req::SelectionRange>> { | 72 | ) -> Result<Vec<req::SelectionRange>> { |
73 | let _p = profile("handle_selection_range"); | 73 | let _p = profile("handle_selection_range"); |
74 | let file_id = params.text_document.try_conv_with(&world)?; | 74 | let file_id = params.text_document.try_conv_with(&world)?; |
75 | let line_index = world.analysis().file_line_index(file_id); | 75 | let line_index = world.analysis().file_line_index(file_id)?; |
76 | params | 76 | params |
77 | .positions | 77 | .positions |
78 | .into_iter() | 78 | .into_iter() |
@@ -113,13 +113,19 @@ pub fn handle_find_matching_brace( | |||
113 | ) -> Result<Vec<Position>> { | 113 | ) -> Result<Vec<Position>> { |
114 | let _p = profile("handle_find_matching_brace"); | 114 | let _p = profile("handle_find_matching_brace"); |
115 | let file_id = params.text_document.try_conv_with(&world)?; | 115 | let file_id = params.text_document.try_conv_with(&world)?; |
116 | let line_index = world.analysis().file_line_index(file_id); | 116 | let line_index = world.analysis().file_line_index(file_id)?; |
117 | let res = params | 117 | let res = params |
118 | .offsets | 118 | .offsets |
119 | .into_iter() | 119 | .into_iter() |
120 | .map_conv_with(&line_index) | 120 | .map_conv_with(&line_index) |
121 | .map(|offset| { | 121 | .map(|offset| { |
122 | world.analysis().matching_brace(FilePosition { file_id, offset }).unwrap_or(offset) | 122 | if let Ok(Some(matching_brace_offset)) = |
123 | world.analysis().matching_brace(FilePosition { file_id, offset }) | ||
124 | { | ||
125 | matching_brace_offset | ||
126 | } else { | ||
127 | offset | ||
128 | } | ||
123 | }) | 129 | }) |
124 | .map_conv_with(&line_index) | 130 | .map_conv_with(&line_index) |
125 | .collect(); | 131 | .collect(); |
@@ -132,7 +138,7 @@ pub fn handle_join_lines( | |||
132 | ) -> Result<req::SourceChange> { | 138 | ) -> Result<req::SourceChange> { |
133 | let _p = profile("handle_join_lines"); | 139 | let _p = profile("handle_join_lines"); |
134 | let frange = (¶ms.text_document, params.range).try_conv_with(&world)?; | 140 | let frange = (¶ms.text_document, params.range).try_conv_with(&world)?; |
135 | world.analysis().join_lines(frange).try_conv_with(&world) | 141 | world.analysis().join_lines(frange)?.try_conv_with(&world) |
136 | } | 142 | } |
137 | 143 | ||
138 | pub fn handle_on_enter( | 144 | pub fn handle_on_enter( |
@@ -141,7 +147,7 @@ pub fn handle_on_enter( | |||
141 | ) -> Result<Option<req::SourceChange>> { | 147 | ) -> Result<Option<req::SourceChange>> { |
142 | let _p = profile("handle_on_enter"); | 148 | let _p = profile("handle_on_enter"); |
143 | let position = params.try_conv_with(&world)?; | 149 | let position = params.try_conv_with(&world)?; |
144 | match world.analysis().on_enter(position) { | 150 | match world.analysis().on_enter(position)? { |
145 | None => Ok(None), | 151 | None => Ok(None), |
146 | Some(edit) => Ok(Some(edit.try_conv_with(&world)?)), | 152 | Some(edit) => Ok(Some(edit.try_conv_with(&world)?)), |
147 | } | 153 | } |
@@ -153,7 +159,7 @@ pub fn handle_on_type_formatting( | |||
153 | ) -> Result<Option<Vec<TextEdit>>> { | 159 | ) -> Result<Option<Vec<TextEdit>>> { |
154 | let _p = profile("handle_on_type_formatting"); | 160 | let _p = profile("handle_on_type_formatting"); |
155 | let mut position = params.text_document_position.try_conv_with(&world)?; | 161 | let mut position = params.text_document_position.try_conv_with(&world)?; |
156 | let line_index = world.analysis().file_line_index(position.file_id); | 162 | let line_index = world.analysis().file_line_index(position.file_id)?; |
157 | 163 | ||
158 | // in `ra_ide_api`, the `on_type` invariant is that | 164 | // in `ra_ide_api`, the `on_type` invariant is that |
159 | // `text.char_at(position) == typed_char`. | 165 | // `text.char_at(position) == typed_char`. |
@@ -163,7 +169,7 @@ pub fn handle_on_type_formatting( | |||
163 | "=" => world.analysis().on_eq_typed(position), | 169 | "=" => world.analysis().on_eq_typed(position), |
164 | "." => world.analysis().on_dot_typed(position), | 170 | "." => world.analysis().on_dot_typed(position), |
165 | _ => return Ok(None), | 171 | _ => return Ok(None), |
166 | }; | 172 | }?; |
167 | let mut edit = match edit { | 173 | let mut edit = match edit { |
168 | Some(it) => it, | 174 | Some(it) => it, |
169 | None => return Ok(None), | 175 | None => return Ok(None), |
@@ -181,11 +187,11 @@ pub fn handle_document_symbol( | |||
181 | params: req::DocumentSymbolParams, | 187 | params: req::DocumentSymbolParams, |
182 | ) -> Result<Option<req::DocumentSymbolResponse>> { | 188 | ) -> Result<Option<req::DocumentSymbolResponse>> { |
183 | let file_id = params.text_document.try_conv_with(&world)?; | 189 | let file_id = params.text_document.try_conv_with(&world)?; |
184 | let line_index = world.analysis().file_line_index(file_id); | 190 | let line_index = world.analysis().file_line_index(file_id)?; |
185 | 191 | ||
186 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); | 192 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); |
187 | 193 | ||
188 | for symbol in world.analysis().file_structure(file_id) { | 194 | for symbol in world.analysis().file_structure(file_id)? { |
189 | let doc_symbol = DocumentSymbol { | 195 | let doc_symbol = DocumentSymbol { |
190 | name: symbol.label, | 196 | name: symbol.label, |
191 | detail: symbol.detail, | 197 | detail: symbol.detail, |
@@ -309,7 +315,7 @@ pub fn handle_runnables( | |||
309 | params: req::RunnablesParams, | 315 | params: req::RunnablesParams, |
310 | ) -> Result<Vec<req::Runnable>> { | 316 | ) -> Result<Vec<req::Runnable>> { |
311 | let file_id = params.text_document.try_conv_with(&world)?; | 317 | let file_id = params.text_document.try_conv_with(&world)?; |
312 | let line_index = world.analysis().file_line_index(file_id); | 318 | let line_index = world.analysis().file_line_index(file_id)?; |
313 | let offset = params.position.map(|it| it.conv_with(&line_index)); | 319 | let offset = params.position.map(|it| it.conv_with(&line_index)); |
314 | let mut res = Vec::new(); | 320 | let mut res = Vec::new(); |
315 | let workspace_root = world.workspace_root_for(file_id); | 321 | let workspace_root = world.workspace_root_for(file_id); |
@@ -383,7 +389,7 @@ pub fn handle_completion( | |||
383 | let mut res = false; | 389 | let mut res = false; |
384 | if let Some(ctx) = params.context { | 390 | if let Some(ctx) = params.context { |
385 | if ctx.trigger_character.unwrap_or_default() == ":" { | 391 | if ctx.trigger_character.unwrap_or_default() == ":" { |
386 | let source_file = world.analysis().parse(position.file_id); | 392 | let source_file = world.analysis().parse(position.file_id)?; |
387 | let syntax = source_file.syntax(); | 393 | let syntax = source_file.syntax(); |
388 | let text = syntax.text(); | 394 | let text = syntax.text(); |
389 | if let Some(next_char) = text.char_at(position.offset) { | 395 | if let Some(next_char) = text.char_at(position.offset) { |
@@ -405,7 +411,7 @@ pub fn handle_completion( | |||
405 | None => return Ok(None), | 411 | None => return Ok(None), |
406 | Some(items) => items, | 412 | Some(items) => items, |
407 | }; | 413 | }; |
408 | let line_index = world.analysis().file_line_index(position.file_id); | 414 | let line_index = world.analysis().file_line_index(position.file_id)?; |
409 | let items: Vec<CompletionItem> = | 415 | let items: Vec<CompletionItem> = |
410 | items.into_iter().map(|item| item.conv_with(&line_index)).collect(); | 416 | items.into_iter().map(|item| item.conv_with(&line_index)).collect(); |
411 | 417 | ||
@@ -417,12 +423,12 @@ pub fn handle_folding_range( | |||
417 | params: FoldingRangeParams, | 423 | params: FoldingRangeParams, |
418 | ) -> Result<Option<Vec<FoldingRange>>> { | 424 | ) -> Result<Option<Vec<FoldingRange>>> { |
419 | let file_id = params.text_document.try_conv_with(&world)?; | 425 | let file_id = params.text_document.try_conv_with(&world)?; |
420 | let line_index = world.analysis().file_line_index(file_id); | 426 | let line_index = world.analysis().file_line_index(file_id)?; |
421 | 427 | ||
422 | let res = Some( | 428 | let res = Some( |
423 | world | 429 | world |
424 | .analysis() | 430 | .analysis() |
425 | .folding_ranges(file_id) | 431 | .folding_ranges(file_id)? |
426 | .into_iter() | 432 | .into_iter() |
427 | .map(|fold| { | 433 | .map(|fold| { |
428 | let kind = match fold.kind { | 434 | let kind = match fold.kind { |
@@ -474,7 +480,7 @@ pub fn handle_hover( | |||
474 | None => return Ok(None), | 480 | None => return Ok(None), |
475 | Some(info) => info, | 481 | Some(info) => info, |
476 | }; | 482 | }; |
477 | let line_index = world.analysis.file_line_index(position.file_id); | 483 | let line_index = world.analysis.file_line_index(position.file_id)?; |
478 | let range = info.range.conv_with(&line_index); | 484 | let range = info.range.conv_with(&line_index); |
479 | let res = Hover { | 485 | let res = Hover { |
480 | contents: HoverContents::Markup(MarkupContent { | 486 | contents: HoverContents::Markup(MarkupContent { |
@@ -503,7 +509,7 @@ pub fn handle_prepare_rename( | |||
503 | // Refs should always have a declaration | 509 | // Refs should always have a declaration |
504 | let r = refs.declaration(); | 510 | let r = refs.declaration(); |
505 | let file_id = params.text_document.try_conv_with(&world)?; | 511 | let file_id = params.text_document.try_conv_with(&world)?; |
506 | let line_index = world.analysis().file_line_index(file_id); | 512 | let line_index = world.analysis().file_line_index(file_id)?; |
507 | let loc = to_location(r.file_id(), r.range(), &world, &line_index)?; | 513 | let loc = to_location(r.file_id(), r.range(), &world, &line_index)?; |
508 | 514 | ||
509 | Ok(Some(PrepareRenameResponse::Range(loc.range))) | 515 | Ok(Some(PrepareRenameResponse::Range(loc.range))) |
@@ -536,7 +542,7 @@ pub fn handle_references( | |||
536 | params: req::ReferenceParams, | 542 | params: req::ReferenceParams, |
537 | ) -> Result<Option<Vec<Location>>> { | 543 | ) -> Result<Option<Vec<Location>>> { |
538 | let position = params.text_document_position.try_conv_with(&world)?; | 544 | let position = params.text_document_position.try_conv_with(&world)?; |
539 | let line_index = world.analysis().file_line_index(position.file_id); | 545 | let line_index = world.analysis().file_line_index(position.file_id)?; |
540 | 546 | ||
541 | let refs = match world.analysis().find_all_refs(position)? { | 547 | let refs = match world.analysis().find_all_refs(position)? { |
542 | None => return Ok(None), | 548 | None => return Ok(None), |
@@ -563,9 +569,9 @@ pub fn handle_formatting( | |||
563 | params: DocumentFormattingParams, | 569 | params: DocumentFormattingParams, |
564 | ) -> Result<Option<Vec<TextEdit>>> { | 570 | ) -> Result<Option<Vec<TextEdit>>> { |
565 | let file_id = params.text_document.try_conv_with(&world)?; | 571 | let file_id = params.text_document.try_conv_with(&world)?; |
566 | let file = world.analysis().file_text(file_id); | 572 | let file = world.analysis().file_text(file_id)?; |
567 | 573 | ||
568 | let file_line_index = world.analysis().file_line_index(file_id); | 574 | let file_line_index = world.analysis().file_line_index(file_id)?; |
569 | let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); | 575 | let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); |
570 | 576 | ||
571 | use std::process; | 577 | use std::process; |
@@ -623,7 +629,7 @@ pub fn handle_code_action( | |||
623 | ) -> Result<Option<CodeActionResponse>> { | 629 | ) -> Result<Option<CodeActionResponse>> { |
624 | let _p = profile("handle_code_action"); | 630 | let _p = profile("handle_code_action"); |
625 | let file_id = params.text_document.try_conv_with(&world)?; | 631 | let file_id = params.text_document.try_conv_with(&world)?; |
626 | let line_index = world.analysis().file_line_index(file_id); | 632 | let line_index = world.analysis().file_line_index(file_id)?; |
627 | let range = params.range.conv_with(&line_index); | 633 | let range = params.range.conv_with(&line_index); |
628 | 634 | ||
629 | let assists = world.analysis().assists(FileRange { file_id, range })?.into_iter(); | 635 | let assists = world.analysis().assists(FileRange { file_id, range })?.into_iter(); |
@@ -685,7 +691,7 @@ pub fn handle_code_lens( | |||
685 | params: req::CodeLensParams, | 691 | params: req::CodeLensParams, |
686 | ) -> Result<Option<Vec<CodeLens>>> { | 692 | ) -> Result<Option<Vec<CodeLens>>> { |
687 | let file_id = params.text_document.try_conv_with(&world)?; | 693 | let file_id = params.text_document.try_conv_with(&world)?; |
688 | let line_index = world.analysis().file_line_index(file_id); | 694 | let line_index = world.analysis().file_line_index(file_id)?; |
689 | 695 | ||
690 | let mut lenses: Vec<CodeLens> = Default::default(); | 696 | let mut lenses: Vec<CodeLens> = Default::default(); |
691 | let workspace_root = world.workspace_root_for(file_id); | 697 | let workspace_root = world.workspace_root_for(file_id); |
@@ -730,7 +736,7 @@ pub fn handle_code_lens( | |||
730 | lenses.extend( | 736 | lenses.extend( |
731 | world | 737 | world |
732 | .analysis() | 738 | .analysis() |
733 | .file_structure(file_id) | 739 | .file_structure(file_id)? |
734 | .into_iter() | 740 | .into_iter() |
735 | .filter(|it| match it.kind { | 741 | .filter(|it| match it.kind { |
736 | SyntaxKind::TRAIT_DEF | SyntaxKind::STRUCT_DEF | SyntaxKind::ENUM_DEF => true, | 742 | SyntaxKind::TRAIT_DEF | SyntaxKind::STRUCT_DEF | SyntaxKind::ENUM_DEF => true, |
@@ -807,7 +813,7 @@ pub fn handle_document_highlight( | |||
807 | params: req::TextDocumentPositionParams, | 813 | params: req::TextDocumentPositionParams, |
808 | ) -> Result<Option<Vec<DocumentHighlight>>> { | 814 | ) -> Result<Option<Vec<DocumentHighlight>>> { |
809 | let file_id = params.text_document.try_conv_with(&world)?; | 815 | let file_id = params.text_document.try_conv_with(&world)?; |
810 | let line_index = world.analysis().file_line_index(file_id); | 816 | let line_index = world.analysis().file_line_index(file_id)?; |
811 | 817 | ||
812 | let refs = match world.analysis().find_all_refs(params.try_conv_with(&world)?)? { | 818 | let refs = match world.analysis().find_all_refs(params.try_conv_with(&world)?)? { |
813 | None => return Ok(None), | 819 | None => return Ok(None), |
@@ -826,7 +832,7 @@ pub fn publish_diagnostics( | |||
826 | file_id: FileId, | 832 | file_id: FileId, |
827 | ) -> Result<req::PublishDiagnosticsParams> { | 833 | ) -> Result<req::PublishDiagnosticsParams> { |
828 | let uri = world.file_id_to_uri(file_id)?; | 834 | let uri = world.file_id_to_uri(file_id)?; |
829 | let line_index = world.analysis().file_line_index(file_id); | 835 | let line_index = world.analysis().file_line_index(file_id)?; |
830 | let diagnostics = world | 836 | let diagnostics = world |
831 | .analysis() | 837 | .analysis() |
832 | .diagnostics(file_id)? | 838 | .diagnostics(file_id)? |
@@ -852,7 +858,7 @@ pub fn publish_decorations( | |||
852 | } | 858 | } |
853 | 859 | ||
854 | fn highlight(world: &WorldSnapshot, file_id: FileId) -> Result<Vec<Decoration>> { | 860 | fn highlight(world: &WorldSnapshot, file_id: FileId) -> Result<Vec<Decoration>> { |
855 | let line_index = world.analysis().file_line_index(file_id); | 861 | let line_index = world.analysis().file_line_index(file_id)?; |
856 | let res = world | 862 | let res = world |
857 | .analysis() | 863 | .analysis() |
858 | .highlight(file_id)? | 864 | .highlight(file_id)? |
@@ -881,7 +887,7 @@ pub fn handle_inlay_hints( | |||
881 | ) -> Result<Vec<InlayHint>> { | 887 | ) -> Result<Vec<InlayHint>> { |
882 | let file_id = params.text_document.try_conv_with(&world)?; | 888 | let file_id = params.text_document.try_conv_with(&world)?; |
883 | let analysis = world.analysis(); | 889 | let analysis = world.analysis(); |
884 | let line_index = analysis.file_line_index(file_id); | 890 | let line_index = analysis.file_line_index(file_id)?; |
885 | Ok(analysis | 891 | Ok(analysis |
886 | .inlay_hints(file_id)? | 892 | .inlay_hints(file_id)? |
887 | .into_iter() | 893 | .into_iter() |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 9fd654305..1d7755910 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -215,7 +215,12 @@ impl WorldSnapshot { | |||
215 | } | 215 | } |
216 | } | 216 | } |
217 | res.push_str("\nanalysis:\n"); | 217 | res.push_str("\nanalysis:\n"); |
218 | res.push_str(&self.analysis.status()); | 218 | res.push_str( |
219 | &self | ||
220 | .analysis | ||
221 | .status() | ||
222 | .unwrap_or_else(|_| "Analysis retrieval was cancelled".to_owned()), | ||
223 | ); | ||
219 | res | 224 | res |
220 | } | 225 | } |
221 | 226 | ||