From 4f94af3c4aaa57ebb4cb01f7e4edfb3a0821b09b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov <aleksey.kladov@gmail.com> Date: Tue, 11 Jun 2019 16:49:56 +0300 Subject: use Source for Function --- crates/ra_ide_api/src/completion/presentation.rs | 2 +- crates/ra_ide_api/src/display/function_signature.rs | 2 +- crates/ra_ide_api/src/display/navigation_target.rs | 8 +------- crates/ra_ide_api/src/hover.rs | 12 ++++++------ 4 files changed, 9 insertions(+), 15 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index d405161d6..e9ae20225 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -100,7 +100,7 @@ impl Completions { ) { let sig = func.signature(ctx.db); let name = name.unwrap_or_else(|| sig.name().to_string()); - let (_, ast_node) = func.source(ctx.db); + let ast_node = func.source(ctx.db).ast; let detail = function_label(&ast_node); let mut builder = CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name) diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs index d09950bce..d0c155de7 100644 --- a/crates/ra_ide_api/src/display/function_signature.rs +++ b/crates/ra_ide_api/src/display/function_signature.rs @@ -33,7 +33,7 @@ impl FunctionSignature { pub(crate) fn from_hir(db: &db::RootDatabase, function: hir::Function) -> Self { let doc = function.docs(db); - let (_, ast_node) = function.source(db); + let ast_node = function.source(db).ast; FunctionSignature::from(&*ast_node).with_doc_opt(doc) } } diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index bef5f0980..3333771ab 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -164,13 +164,7 @@ impl NavigationTarget { } pub(crate) fn from_function(db: &RootDatabase, func: hir::Function) -> NavigationTarget { - let (file_id, fn_def) = func.source(db); - NavigationTarget::from_named( - file_id.original_file(db), - &*fn_def, - fn_def.doc_comment_text(), - fn_def.short_label(), - ) + NavigationTarget::from_def_source(db, func) } pub(crate) fn from_field(db: &RootDatabase, field: hir::StructField) -> NavigationTarget { diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index ee0f2dde8..4dd3c1b9f 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs @@ -96,8 +96,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn match classify_name_ref(db, &analyzer, name_ref) { Some(Method(it)) => { - let it = it.source(db).1; - res.extend(hover_text(it.doc_comment_text(), it.short_label())); + let src = it.source(db); + res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())); } Some(Macro(it)) => { let it = it.source(db).1; @@ -111,8 +111,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn } Some(AssocItem(it)) => match it { hir::ImplItem::Method(it) => { - let it = it.source(db).1; - res.extend(hover_text(it.doc_comment_text(), it.short_label())) + let src = it.source(db); + res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) } hir::ImplItem::Const(it) => { let it = it.source(db).1; @@ -132,8 +132,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn } } hir::ModuleDef::Function(it) => { - let it = it.source(db).1; - res.extend(hover_text(it.doc_comment_text(), it.short_label())) + let src = it.source(db); + res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) } hir::ModuleDef::Struct(it) => { let src = it.source(db); -- cgit v1.2.3