Skip to content

Commit 1167ed6

Browse files
authored
[ty] Rename functionArgumentNames to callArgumentNames inlay hint setting (#19911)
## Summary This PR renames `ty.inlayHints.functionArgumentNames` to `ty.inlayHints.callArgumentNames` which would contain both function calls and class initialization calls i.e., it represents a generic call expression.
1 parent 2ee47d8 commit 1167ed6

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

crates/ty_ide/src/inlay_hints.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'db> InlayHint<'db> {
2424
#[derive(Debug, Clone, Eq, PartialEq)]
2525
pub enum InlayHintContent<'db> {
2626
Type(Type<'db>),
27-
FunctionArgumentName(String),
27+
CallArgumentName(String),
2828
}
2929

3030
impl<'db> InlayHintContent<'db> {
@@ -44,7 +44,7 @@ impl fmt::Display for DisplayInlayHint<'_, '_> {
4444
InlayHintContent::Type(ty) => {
4545
write!(f, ": {}", ty.display(self.db))
4646
}
47-
InlayHintContent::FunctionArgumentName(name) => {
47+
InlayHintContent::CallArgumentName(name) => {
4848
write!(f, "{name}=")
4949
}
5050
}
@@ -77,21 +77,21 @@ pub struct InlayHintSettings {
7777
/// ```
7878
pub variable_types: bool,
7979

80-
/// Whether to show function argument names.
80+
/// Whether to show call argument names.
8181
///
8282
/// For example, this would enable / disable hints like the ones quoted below:
8383
/// ```python
8484
/// def foo(x: int): pass
8585
/// foo("x="1)
8686
/// ```
87-
pub function_argument_names: bool,
87+
pub call_argument_names: bool,
8888
}
8989

9090
impl Default for InlayHintSettings {
9191
fn default() -> Self {
9292
Self {
9393
variable_types: true,
94-
function_argument_names: true,
94+
call_argument_names: true,
9595
}
9696
}
9797
}
@@ -127,8 +127,8 @@ impl<'a, 'db> InlayHintVisitor<'a, 'db> {
127127
});
128128
}
129129

130-
fn add_function_argument_name(&mut self, position: TextSize, name: String) {
131-
if !self.settings.function_argument_names {
130+
fn add_call_argument_name(&mut self, position: TextSize, name: String) {
131+
if !self.settings.call_argument_names {
132132
return;
133133
}
134134

@@ -138,7 +138,7 @@ impl<'a, 'db> InlayHintVisitor<'a, 'db> {
138138

139139
self.hints.push(InlayHint {
140140
position,
141-
content: InlayHintContent::FunctionArgumentName(name),
141+
content: InlayHintContent::CallArgumentName(name),
142142
});
143143
}
144144
}
@@ -205,7 +205,7 @@ impl SourceOrderVisitor<'_> for InlayHintVisitor<'_, '_> {
205205

206206
for (index, arg_or_keyword) in call.arguments.arguments_source_order().enumerate() {
207207
if let Some(name) = argument_names.get(&index) {
208-
self.add_function_argument_name(
208+
self.add_call_argument_name(
209209
arg_or_keyword.range().start(),
210210
name.to_string(),
211211
);
@@ -301,7 +301,7 @@ mod tests {
301301
fn inlay_hints(&self) -> String {
302302
self.inlay_hints_with_settings(&InlayHintSettings {
303303
variable_types: true,
304-
function_argument_names: true,
304+
call_argument_names: true,
305305
})
306306
}
307307

@@ -857,7 +857,7 @@ mod tests {
857857
);
858858

859859
assert_snapshot!(test.inlay_hints_with_settings(&InlayHintSettings {
860-
function_argument_names: false,
860+
call_argument_names: false,
861861
..Default::default()
862862
}), @r"
863863
def foo(x: int): pass

crates/ty_server/src/session/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ impl WorkspaceOptions {
237237
#[serde(rename_all = "camelCase")]
238238
struct InlayHintOptions {
239239
variable_types: Option<bool>,
240-
function_argument_names: Option<bool>,
240+
call_argument_names: Option<bool>,
241241
}
242242

243243
impl InlayHintOptions {
244244
fn into_settings(self) -> InlayHintSettings {
245245
InlayHintSettings {
246246
variable_types: self.variable_types.unwrap_or(true),
247-
function_argument_names: self.function_argument_names.unwrap_or(true),
247+
call_argument_names: self.call_argument_names.unwrap_or(true),
248248
}
249249
}
250250
}

crates/ty_wasm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl Workspace {
438438
// TODO: Provide a way to configure this
439439
&InlayHintSettings {
440440
variable_types: true,
441-
function_argument_names: true,
441+
call_argument_names: true,
442442
},
443443
);
444444

0 commit comments

Comments
 (0)