aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs9
-rw-r--r--crates/ra_ide/src/hover.rs21
2 files changed, 13 insertions, 17 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index 325b247bb..c7bb1e69f 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -321,15 +321,6 @@ impl ToNav for hir::Adt {
321 } 321 }
322} 322}
323 323
324impl ToNav for hir::AdtOrTrait {
325 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
326 match self {
327 hir::AdtOrTrait::Adt(adt) => adt.to_nav(db),
328 hir::AdtOrTrait::Trait(trait_) => trait_.to_nav(db),
329 }
330 }
331}
332
333impl ToNav for hir::AssocItem { 324impl ToNav for hir::AssocItem {
334 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 325 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
335 match self { 326 match self {
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 2a06006e1..045713519 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -1,8 +1,8 @@
1use std::iter::once; 1use std::iter::once;
2 2
3use hir::{ 3use hir::{
4 Adt, AdtOrTrait, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, 4 Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay,
5 HirDisplay, Module, ModuleDef, ModuleSource, Semantics, 5 Module, ModuleDef, ModuleSource, Semantics,
6}; 6};
7use itertools::Itertools; 7use itertools::Itertools;
8use ra_db::SourceDatabase; 8use ra_db::SourceDatabase;
@@ -13,7 +13,9 @@ use ra_ide_db::{
13use ra_syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset}; 13use ra_syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset};
14 14
15use crate::{ 15use crate::{
16 display::{macro_label, rust_code_markup, rust_code_markup_with_doc, ShortLabel, ToNav}, 16 display::{
17 macro_label, rust_code_markup, rust_code_markup_with_doc, ShortLabel, ToNav, TryToNav,
18 },
17 runnables::runnable, 19 runnables::runnable,
18 FileId, FilePosition, NavigationTarget, RangeInfo, Runnable, 20 FileId, FilePosition, NavigationTarget, RangeInfo, Runnable,
19}; 21};
@@ -238,9 +240,11 @@ fn goto_type_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> {
238 .ty(db) 240 .ty(db)
239 .flattened_type_items(db) 241 .flattened_type_items(db)
240 .into_iter() 242 .into_iter()
241 .map(|it| HoverGotoTypeData { 243 .filter_map(|it| {
242 mod_path: adt_or_trait_mod_path(db, &it), 244 Some(HoverGotoTypeData {
243 nav: it.to_nav(db), 245 mod_path: mod_path(db, &it)?,
246 nav: it.try_to_nav(db)?,
247 })
244 }) 248 })
245 .collect_vec(); 249 .collect_vec();
246 250
@@ -294,8 +298,9 @@ fn determine_mod_path(db: &RootDatabase, module: Module, name: Option<String>) -
294 .join("::") 298 .join("::")
295} 299}
296 300
297fn adt_or_trait_mod_path(db: &RootDatabase, item: &AdtOrTrait) -> String { 301// returns None only for ModuleDef::BuiltinType
298 determine_mod_path(db, item.module(db), Some(item.name(db).to_string())) 302fn mod_path(db: &RootDatabase, item: &ModuleDef) -> Option<String> {
303 Some(determine_mod_path(db, item.module(db)?, item.name(db).map(|name| name.to_string())))
299} 304}
300 305
301fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> { 306fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {