diff options
-rw-r--r-- | Cargo.lock | 85 | ||||
-rw-r--r-- | crates/ra_ide/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/hover.rs | 44 |
3 files changed, 31 insertions, 102 deletions
diff --git a/Cargo.lock b/Cargo.lock index 572fb868e..9bd5fac2d 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -409,17 +409,6 @@ dependencies = [ | |||
409 | ] | 409 | ] |
410 | 410 | ||
411 | [[package]] | 411 | [[package]] |
412 | name = "getrandom" | ||
413 | version = "0.1.14" | ||
414 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
415 | checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" | ||
416 | dependencies = [ | ||
417 | "cfg-if", | ||
418 | "libc", | ||
419 | "wasi", | ||
420 | ] | ||
421 | |||
422 | [[package]] | ||
423 | name = "gimli" | 412 | name = "gimli" |
424 | version = "0.22.0" | 413 | version = "0.22.0" |
425 | source = "registry+https://github.com/rust-lang/crates.io-index" | 414 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -640,12 +629,6 @@ dependencies = [ | |||
640 | ] | 629 | ] |
641 | 630 | ||
642 | [[package]] | 631 | [[package]] |
643 | name = "maplit" | ||
644 | version = "1.0.2" | ||
645 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
646 | checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" | ||
647 | |||
648 | [[package]] | ||
649 | name = "matchers" | 632 | name = "matchers" |
650 | version = "0.0.1" | 633 | version = "0.0.1" |
651 | source = "registry+https://github.com/rust-lang/crates.io-index" | 634 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -908,12 +891,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
908 | checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" | 891 | checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" |
909 | 892 | ||
910 | [[package]] | 893 | [[package]] |
911 | name = "ppv-lite86" | ||
912 | version = "0.2.8" | ||
913 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
914 | checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" | ||
915 | |||
916 | [[package]] | ||
917 | name = "proc-macro2" | 894 | name = "proc-macro2" |
918 | version = "1.0.19" | 895 | version = "1.0.19" |
919 | source = "registry+https://github.com/rust-lang/crates.io-index" | 896 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1105,9 +1082,8 @@ dependencies = [ | |||
1105 | "expect", | 1082 | "expect", |
1106 | "indexmap", | 1083 | "indexmap", |
1107 | "itertools", | 1084 | "itertools", |
1108 | "lazy_static", | ||
1109 | "log", | 1085 | "log", |
1110 | "maplit", | 1086 | "once_cell", |
1111 | "oorandom", | 1087 | "oorandom", |
1112 | "pulldown-cmark", | 1088 | "pulldown-cmark", |
1113 | "pulldown-cmark-to-cmark", | 1089 | "pulldown-cmark-to-cmark", |
@@ -1124,11 +1100,9 @@ dependencies = [ | |||
1124 | "ra_syntax", | 1100 | "ra_syntax", |
1125 | "ra_text_edit", | 1101 | "ra_text_edit", |
1126 | "ra_tt", | 1102 | "ra_tt", |
1127 | "rand", | ||
1128 | "rustc-hash", | 1103 | "rustc-hash", |
1129 | "stdx", | 1104 | "stdx", |
1130 | "test_utils", | 1105 | "test_utils", |
1131 | "url", | ||
1132 | ] | 1106 | ] |
1133 | 1107 | ||
1134 | [[package]] | 1108 | [[package]] |
@@ -1289,57 +1263,6 @@ dependencies = [ | |||
1289 | ] | 1263 | ] |
1290 | 1264 | ||
1291 | [[package]] | 1265 | [[package]] |
1292 | name = "rand" | ||
1293 | version = "0.7.3" | ||
1294 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1295 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" | ||
1296 | dependencies = [ | ||
1297 | "getrandom", | ||
1298 | "libc", | ||
1299 | "rand_chacha", | ||
1300 | "rand_core", | ||
1301 | "rand_hc", | ||
1302 | "rand_pcg", | ||
1303 | ] | ||
1304 | |||
1305 | [[package]] | ||
1306 | name = "rand_chacha" | ||
1307 | version = "0.2.2" | ||
1308 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1309 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" | ||
1310 | dependencies = [ | ||
1311 | "ppv-lite86", | ||
1312 | "rand_core", | ||
1313 | ] | ||
1314 | |||
1315 | [[package]] | ||
1316 | name = "rand_core" | ||
1317 | version = "0.5.1" | ||
1318 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1319 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" | ||
1320 | dependencies = [ | ||
1321 | "getrandom", | ||
1322 | ] | ||
1323 | |||
1324 | [[package]] | ||
1325 | name = "rand_hc" | ||
1326 | version = "0.2.0" | ||
1327 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1328 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" | ||
1329 | dependencies = [ | ||
1330 | "rand_core", | ||
1331 | ] | ||
1332 | |||
1333 | [[package]] | ||
1334 | name = "rand_pcg" | ||
1335 | version = "0.2.1" | ||
1336 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1337 | checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" | ||
1338 | dependencies = [ | ||
1339 | "rand_core", | ||
1340 | ] | ||
1341 | |||
1342 | [[package]] | ||
1343 | name = "rayon" | 1266 | name = "rayon" |
1344 | version = "1.3.1" | 1267 | version = "1.3.1" |
1345 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1268 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1924,12 +1847,6 @@ dependencies = [ | |||
1924 | ] | 1847 | ] |
1925 | 1848 | ||
1926 | [[package]] | 1849 | [[package]] |
1927 | name = "wasi" | ||
1928 | version = "0.9.0+wasi-snapshot-preview1" | ||
1929 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1930 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" | ||
1931 | |||
1932 | [[package]] | ||
1933 | name = "winapi" | 1850 | name = "winapi" |
1934 | version = "0.2.8" | 1851 | version = "0.2.8" |
1935 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1852 | source = "registry+https://github.com/rust-lang/crates.io-index" |
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 4e2ba6d61..6d5c9daf5 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml | |||
@@ -17,13 +17,11 @@ indexmap = "1.3.2" | |||
17 | itertools = "0.9.0" | 17 | itertools = "0.9.0" |
18 | log = "0.4.8" | 18 | log = "0.4.8" |
19 | rustc-hash = "1.1.0" | 19 | rustc-hash = "1.1.0" |
20 | rand = { version = "0.7.3", features = ["small_rng"] } | ||
21 | url = "*" | 20 | url = "*" |
22 | maplit = "*" | ||
23 | lazy_static = "*" | ||
24 | pulldown-cmark-to-cmark = "4.0.2" | 21 | pulldown-cmark-to-cmark = "4.0.2" |
25 | pulldown-cmark = "0.7.0" | 22 | pulldown-cmark = "0.7.0" |
26 | oorandom = "11.1.2" | 23 | oorandom = "11.1.2" |
24 | once_cell = "1" | ||
27 | 25 | ||
28 | stdx = { path = "../stdx" } | 26 | stdx = { path = "../stdx" } |
29 | 27 | ||
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a82fe6714..1531aca2e 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -1,5 +1,8 @@ | |||
1 | use std::collections::{HashMap, HashSet}; | 1 | use std::collections::{HashMap, HashSet}; |
2 | use std::iter::once; | 2 | use std::{ |
3 | iter::{once, FromIterator}, | ||
4 | sync::Mutex, | ||
5 | }; | ||
3 | 6 | ||
4 | use hir::{ | 7 | use hir::{ |
5 | db::DefDatabase, Adt, AsAssocItem, AsName, AssocItemContainer, AttrDef, Crate, Documentation, | 8 | db::DefDatabase, Adt, AsAssocItem, AsName, AssocItemContainer, AttrDef, Crate, Documentation, |
@@ -7,8 +10,7 @@ use hir::{ | |||
7 | ModuleSource, Semantics, | 10 | ModuleSource, Semantics, |
8 | }; | 11 | }; |
9 | use itertools::Itertools; | 12 | use itertools::Itertools; |
10 | use lazy_static::lazy_static; | 13 | use once_cell::sync::Lazy; |
11 | use maplit::{hashmap, hashset}; | ||
12 | use pulldown_cmark::{CowStr, Event, Options, Parser, Tag}; | 14 | use pulldown_cmark::{CowStr, Event, Options, Parser, Tag}; |
13 | use pulldown_cmark_to_cmark::cmark; | 15 | use pulldown_cmark_to_cmark::cmark; |
14 | use ra_db::SourceDatabase; | 16 | use ra_db::SourceDatabase; |
@@ -419,14 +421,26 @@ enum Namespace { | |||
419 | Macros, | 421 | Macros, |
420 | } | 422 | } |
421 | 423 | ||
422 | lazy_static!( | 424 | static NS_MAP: Lazy< |
423 | /// Map of namespaces to identifying prefixes and suffixes as defined by RFC1946. | 425 | HashMap<Namespace, (HashSet<&'static &'static str>, HashSet<&'static &'static str>)>, |
424 | static ref NS_MAP: HashMap<Namespace, (HashSet<&'static str>, HashSet<&'static str>)> = hashmap!{ | 426 | > = Lazy::new(|| { |
425 | Namespace::Types => (hashset!{"type", "struct", "enum", "mod", "trait", "union", "module"}, hashset!{}), | 427 | let mut map = HashMap::new(); |
426 | Namespace::Values => (hashset!{"value", "function", "fn", "method", "const", "static", "mod", "module"}, hashset!{"()"}), | 428 | map.insert(Namespace::Types, (HashSet::new(), HashSet::new())); |
427 | Namespace::Macros => (hashset!{"macro"}, hashset!{"!"}) | 429 | map.insert( |
428 | }; | 430 | Namespace::Values, |
429 | ); | 431 | ( |
432 | HashSet::from_iter( | ||
433 | ["value", "function", "fn", "method", "const", "static", "mod", "module"].iter(), | ||
434 | ), | ||
435 | HashSet::from_iter(["()"].iter()), | ||
436 | ), | ||
437 | ); | ||
438 | map.insert( | ||
439 | Namespace::Macros, | ||
440 | (HashSet::from_iter(["macro"].iter()), HashSet::from_iter(["!"].iter())), | ||
441 | ); | ||
442 | map | ||
443 | }); | ||
430 | 444 | ||
431 | impl Namespace { | 445 | impl Namespace { |
432 | /// Extract the specified namespace from an intra-doc-link if one exists. | 446 | /// Extract the specified namespace from an intra-doc-link if one exists. |
@@ -437,7 +451,7 @@ impl Namespace { | |||
437 | prefixes | 451 | prefixes |
438 | .iter() | 452 | .iter() |
439 | .map(|prefix| { | 453 | .map(|prefix| { |
440 | s.starts_with(prefix) | 454 | s.starts_with(*prefix) |
441 | && s.chars() | 455 | && s.chars() |
442 | .nth(prefix.len() + 1) | 456 | .nth(prefix.len() + 1) |
443 | .map(|c| c == '@' || c == ' ') | 457 | .map(|c| c == '@' || c == ' ') |
@@ -447,7 +461,7 @@ impl Namespace { | |||
447 | || suffixes | 461 | || suffixes |
448 | .iter() | 462 | .iter() |
449 | .map(|suffix| { | 463 | .map(|suffix| { |
450 | s.starts_with(suffix) | 464 | s.starts_with(*suffix) |
451 | && s.chars() | 465 | && s.chars() |
452 | .nth(suffix.len() + 1) | 466 | .nth(suffix.len() + 1) |
453 | .map(|c| c == '@' || c == ' ') | 467 | .map(|c| c == '@' || c == ' ') |
@@ -464,8 +478,8 @@ impl Namespace { | |||
464 | fn strip_prefixes_suffixes(mut s: &str) -> &str { | 478 | fn strip_prefixes_suffixes(mut s: &str) -> &str { |
465 | s = s.trim_matches('`'); | 479 | s = s.trim_matches('`'); |
466 | NS_MAP.iter().for_each(|(_, (prefixes, suffixes))| { | 480 | NS_MAP.iter().for_each(|(_, (prefixes, suffixes))| { |
467 | prefixes.iter().for_each(|prefix| s = s.trim_start_matches(prefix)); | 481 | prefixes.iter().for_each(|prefix| s = s.trim_start_matches(*prefix)); |
468 | suffixes.iter().for_each(|suffix| s = s.trim_end_matches(suffix)); | 482 | suffixes.iter().for_each(|suffix| s = s.trim_end_matches(*suffix)); |
469 | }); | 483 | }); |
470 | s.trim_start_matches("@").trim() | 484 | s.trim_start_matches("@").trim() |
471 | } | 485 | } |