Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 85311a8

Browse files
bors[bot]Jonas Schievink
andauthored
11761: internal: Rename call info to "signature help" r=jonas-schievink a=jonas-schievink It is no longer limited to just calls bors r+ Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 parents 8c16b07 + 55d2a25 commit 85311a8

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

crates/ide/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod navigation_target;
2424

2525
mod annotations;
2626
mod call_hierarchy;
27-
mod call_info;
27+
mod signature_help;
2828
mod doc_links;
2929
mod highlight_related;
3030
mod expand_macro;
@@ -75,7 +75,6 @@ use crate::navigation_target::{ToNav, TryToNav};
7575
pub use crate::{
7676
annotations::{Annotation, AnnotationConfig, AnnotationKind},
7777
call_hierarchy::CallItem,
78-
call_info::CallInfo,
7978
expand_macro::ExpandedMacro,
8079
file_structure::{StructureNode, StructureNodeKind},
8180
folding_ranges::{Fold, FoldKind},
@@ -91,6 +90,7 @@ pub use crate::{
9190
references::ReferenceSearchResult,
9291
rename::RenameError,
9392
runnables::{Runnable, RunnableKind, TestId},
93+
signature_help::SignatureHelp,
9494
static_index::{StaticIndex, StaticIndexedFile, TokenId, TokenStaticData},
9595
syntax_highlighting::{
9696
tags::{Highlight, HlMod, HlMods, HlOperator, HlPunct, HlTag},
@@ -450,9 +450,9 @@ impl Analysis {
450450
self.with_db(|db| doc_links::external_docs(db, &position))
451451
}
452452

453-
/// Computes parameter information for the given call expression.
454-
pub fn call_info(&self, position: FilePosition) -> Cancellable<Option<CallInfo>> {
455-
self.with_db(|db| call_info::call_info(db, position))
453+
/// Computes parameter information at the given position.
454+
pub fn signature_help(&self, position: FilePosition) -> Cancellable<Option<SignatureHelp>> {
455+
self.with_db(|db| signature_help::signature_help(db, position))
456456
}
457457

458458
/// Computes call hierarchy candidates for the given file position.

crates/ide/src/call_info.rs renamed to crates/ide/src/signature_help.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! This module provides primitives for tracking the information about a call site.
1+
//! This module provides primitives for showing type and function parameter information when editing
2+
//! a call or use-site.
23
34
use either::Either;
45
use hir::{HasAttrs, HirDisplay, Semantics};
@@ -11,17 +12,19 @@ use syntax::{algo, AstNode, Direction, TextRange, TextSize};
1112

1213
use crate::RootDatabase;
1314

14-
/// Contains information about a call site. Specifically the
15-
/// `FunctionSignature`and current parameter.
15+
/// Contains information about an item signature as seen from a use site.
16+
///
17+
/// This includes the "active parameter", which is the parameter whose value is currently being
18+
/// edited.
1619
#[derive(Debug)]
17-
pub struct CallInfo {
20+
pub struct SignatureHelp {
1821
pub doc: Option<String>,
1922
pub signature: String,
2023
pub active_parameter: Option<usize>,
2124
parameters: Vec<TextRange>,
2225
}
2326

24-
impl CallInfo {
27+
impl SignatureHelp {
2528
pub fn parameter_labels(&self) -> impl Iterator<Item = &str> + '_ {
2629
self.parameters.iter().map(move |&it| &self.signature[it])
2730
}
@@ -49,8 +52,8 @@ impl CallInfo {
4952
}
5053
}
5154

52-
/// Computes parameter information for the given call expression.
53-
pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {
55+
/// Computes parameter information for the given position.
56+
pub(crate) fn signature_help(db: &RootDatabase, position: FilePosition) -> Option<SignatureHelp> {
5457
let sema = Semantics::new(db);
5558
let file = sema.parse(position.file_id);
5659
let file = file.syntax();
@@ -63,23 +66,23 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
6366
let token = sema.descend_into_macros_single(token);
6467

6568
if let Some((callable, active_parameter)) = callable_for_token(&sema, token.clone()) {
66-
return Some(call_info_for_callable(db, callable, active_parameter));
69+
return Some(signature_help_for_callable(db, callable, active_parameter));
6770
}
6871

6972
if let Some((generic_def, active_parameter)) = generics_for_token(&sema, token.clone()) {
70-
return call_info_for_generics(db, generic_def, active_parameter);
73+
return signature_help_for_generics(db, generic_def, active_parameter);
7174
}
7275

7376
None
7477
}
7578

76-
fn call_info_for_callable(
79+
fn signature_help_for_callable(
7780
db: &RootDatabase,
7881
callable: hir::Callable,
7982
active_parameter: Option<usize>,
80-
) -> CallInfo {
83+
) -> SignatureHelp {
8184
let mut res =
82-
CallInfo { doc: None, signature: String::new(), parameters: vec![], active_parameter };
85+
SignatureHelp { doc: None, signature: String::new(), parameters: vec![], active_parameter };
8386

8487
match callable.kind() {
8588
hir::CallableKind::Function(func) => {
@@ -134,12 +137,12 @@ fn call_info_for_callable(
134137
res
135138
}
136139

137-
fn call_info_for_generics(
140+
fn signature_help_for_generics(
138141
db: &RootDatabase,
139142
mut generics_def: hir::GenericDef,
140143
active_parameter: usize,
141-
) -> Option<CallInfo> {
142-
let mut res = CallInfo {
144+
) -> Option<SignatureHelp> {
145+
let mut res = SignatureHelp {
143146
doc: None,
144147
signature: String::new(),
145148
parameters: vec![],
@@ -230,7 +233,7 @@ mod tests {
230233
"#
231234
);
232235
let (db, position) = position(&fixture);
233-
let call_info = crate::call_info::call_info(&db, position);
236+
let call_info = crate::signature_help::signature_help(&db, position);
234237
let actual = match call_info {
235238
Some(call_info) => {
236239
let docs = match &call_info.doc {

crates/rust-analyzer/src/handlers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,13 +895,12 @@ pub(crate) fn handle_signature_help(
895895
) -> Result<Option<lsp_types::SignatureHelp>> {
896896
let _p = profile::span("handle_signature_help");
897897
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
898-
let call_info = match snap.analysis.call_info(position)? {
898+
let help = match snap.analysis.signature_help(position)? {
899899
Some(it) => it,
900900
None => return Ok(None),
901901
};
902902
let concise = !snap.config.call_info_full();
903-
let res =
904-
to_proto::signature_help(call_info, concise, snap.config.signature_help_label_offsets());
903+
let res = to_proto::signature_help(help, concise, snap.config.signature_help_label_offsets());
905904
Ok(Some(res))
906905
}
907906

crates/rust-analyzer/src/to_proto.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use std::{
66
};
77

88
use ide::{
9-
Annotation, AnnotationKind, Assist, AssistKind, CallInfo, Cancellable, CompletionItem,
9+
Annotation, AnnotationKind, Assist, AssistKind, Cancellable, CompletionItem,
1010
CompletionItemKind, CompletionRelevance, Documentation, FileId, FileRange, FileSystemEdit,
1111
Fold, FoldKind, Highlight, HlMod, HlOperator, HlPunct, HlRange, HlTag, Indel, InlayHint,
1212
InlayKind, Markup, NavigationTarget, ReferenceCategory, RenameError, Runnable, Severity,
13-
SourceChange, StructureNodeKind, SymbolKind, TextEdit, TextRange, TextSize,
13+
SignatureHelp, SourceChange, StructureNodeKind, SymbolKind, TextEdit, TextRange, TextSize,
1414
};
1515
use itertools::Itertools;
1616
use serde_json::to_value;
@@ -336,7 +336,7 @@ fn completion_item(
336336
}
337337

338338
pub(crate) fn signature_help(
339-
call_info: CallInfo,
339+
call_info: SignatureHelp,
340340
concise: bool,
341341
label_offsets: bool,
342342
) -> lsp_types::SignatureHelp {

0 commit comments

Comments
 (0)