aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/doc_links.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 6b2ecf725..5ef708647 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -7,11 +7,9 @@ use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions};
7use pulldown_cmark::{CowStr, Event, LinkType, Options, Parser, Tag}; 7use pulldown_cmark::{CowStr, Event, LinkType, Options, Parser, Tag};
8use url::Url; 8use url::Url;
9 9
10use ide_db::{defs::Definition, RootDatabase};
11
12use hir::{ 10use hir::{
13 db::{DefDatabase, HirDatabase}, 11 db::{DefDatabase, HirDatabase},
14 Adt, AsName, AssocItem, Crate, Field, HasAttrs, ItemInNs, MethodOwner, ModuleDef, AssocItemContainer, AsAssocItem 12 Adt, AsName, AssocItem, Crate, Field, HasAttrs, ItemInNs, ModuleDef, AssocItemContainer, AsAssocItem
15}; 13};
16use ide_db::{ 14use ide_db::{
17 defs::{classify_name, classify_name_ref, Definition}, 15 defs::{classify_name, classify_name_ref, Definition},
@@ -95,12 +93,6 @@ pub fn remove_links(markdown: &str) -> String {
95 out 93 out
96} 94}
97 95
98pub fn get_doc_link<T: Resolvable + Clone>(db: &dyn HirDatabase, definition: &T) -> Option<String> {
99 let module_def = definition.clone().try_into_module_def()?;
100
101 get_doc_link_impl(db, &module_def)
102}
103
104// FIXME: 96// FIXME:
105// BUG: For Option::Some 97// BUG: For Option::Some
106// Returns https://doc.rust-lang.org/nightly/core/prelude/v1/enum.Option.html#variant.Some 98// Returns https://doc.rust-lang.org/nightly/core/prelude/v1/enum.Option.html#variant.Some
@@ -129,8 +121,8 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
129 let module = definition.module(db)?; 121 let module = definition.module(db)?;
130 let krate = module.krate(); 122 let krate = module.krate();
131 let import_map = db.import_map(krate.into()); 123 let import_map = db.import_map(krate.into());
132 let base = once(krate.display_name(db)?) 124 let base = once(krate.declaration_name(db)?.to_string())
133 .chain(import_map.path_of(ns)?.segments.iter().map(|name| format!("{}", name))) 125 .chain(import_map.path_of(ns)?.segments.iter().map(|name| name.to_string()))
134 .join("/"); 126 .join("/");
135 127
136 let filename = get_symbol_filename(db, &target_def); 128 let filename = get_symbol_filename(db, &target_def);
@@ -433,10 +425,10 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> {
433mod tests { 425mod tests {
434 use expect_test::{expect, Expect}; 426 use expect_test::{expect, Expect};
435 427
436 use crate::mock_analysis::analysis_and_position; 428 use crate::fixture;
437 429
438 fn check(ra_fixture: &str, expect: Expect) { 430 fn check(ra_fixture: &str, expect: Expect) {
439 let (analysis, position) = analysis_and_position(ra_fixture); 431 let (analysis, position) = fixture::position(ra_fixture);
440 let url = analysis.external_docs(position).unwrap().expect("could not find url for symbol"); 432 let url = analysis.external_docs(position).unwrap().expect("could not find url for symbol");
441 433
442 expect.assert_eq(&url) 434 expect.assert_eq(&url)