mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 14:00:51 -05:00
[ty] Enrich function argument auto-complete suggestions with annotated types
This commit is contained in:
committed by
Andrew Gallant
parent
eac8a90cc4
commit
e548ce1ca9
@@ -462,6 +462,9 @@ pub struct CallSignatureDetails<'db> {
|
||||
/// Parameter kinds, useful to determine correct autocomplete suggestions.
|
||||
pub parameter_kinds: Vec<ParameterKind<'db>>,
|
||||
|
||||
/// Parameter kinds, useful to determine correct autocomplete suggestions.
|
||||
pub parameter_types: Vec<Option<Type<'db>>>,
|
||||
|
||||
/// The definition where this callable was originally defined (useful for
|
||||
/// extracting docstrings).
|
||||
pub definition: Option<Definition<'db>>,
|
||||
@@ -520,11 +523,12 @@ pub fn call_signature_details<'db>(
|
||||
let display_details = signature.display(model.db()).to_string_parts();
|
||||
let parameter_label_offsets = display_details.parameter_ranges;
|
||||
let parameter_names = display_details.parameter_names;
|
||||
let parameter_kinds = signature
|
||||
.parameters()
|
||||
.iter()
|
||||
.map(|param| param.kind().clone())
|
||||
.collect();
|
||||
let (parameter_kinds, parameter_types): (Vec<ParameterKind>, Vec<Option<Type>>) =
|
||||
signature
|
||||
.parameters()
|
||||
.iter()
|
||||
.map(|param| (param.kind().clone(), param.annotated_type()))
|
||||
.unzip();
|
||||
|
||||
CallSignatureDetails {
|
||||
definition: signature.definition(),
|
||||
@@ -533,6 +537,7 @@ pub fn call_signature_details<'db>(
|
||||
parameter_label_offsets,
|
||||
parameter_names,
|
||||
parameter_kinds,
|
||||
parameter_types,
|
||||
argument_to_parameter_mapping,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user