Skip to content

Commit 499066b

Browse files
jvansch1meta-codesync[bot]
authored andcommitted
Move add_literal_completions to completion module
Summary: Moves add_literal_completions to the completion module. Reviewed By: yangdanny97 Differential Revision: D91782197 fbshipit-source-id: 5c3e4ee9f219db22700ec9677cee6c63129f0a84
1 parent 67e5b08 commit 499066b

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

pyrefly/lib/lsp/wasm/completion.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,28 @@ impl Transaction<'_> {
292292
}
293293
has_added_any
294294
}
295+
296+
/// Adds literal completions for function call arguments based on parameter types.
297+
pub(crate) fn add_literal_completions(
298+
&self,
299+
handle: &Handle,
300+
position: TextSize,
301+
completions: &mut Vec<CompletionItem>,
302+
in_string_literal: bool,
303+
) {
304+
if let Some((callables, chosen_overload_index, active_argument, _)) =
305+
self.get_callables_from_call(handle, position)
306+
&& let Some(callable) = callables.get(chosen_overload_index)
307+
&& let Some(params) =
308+
Self::normalize_singleton_function_type_into_params(callable.clone())
309+
&& let Some(arg_index) = Self::active_parameter_index(&params, &active_argument)
310+
&& let Some(param) = params.get(arg_index)
311+
{
312+
Self::add_literal_completions_from_type(
313+
param.as_type(),
314+
completions,
315+
in_string_literal,
316+
);
317+
}
318+
}
295319
}

pyrefly/lib/state/lsp.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,29 +2695,6 @@ impl<'a> Transaction<'a> {
26952695
}
26962696
}
26972697

2698-
fn add_literal_completions(
2699-
&self,
2700-
handle: &Handle,
2701-
position: TextSize,
2702-
completions: &mut Vec<CompletionItem>,
2703-
in_string_literal: bool,
2704-
) {
2705-
if let Some((callables, chosen_overload_index, active_argument, _)) =
2706-
self.get_callables_from_call(handle, position)
2707-
&& let Some(callable) = callables.get(chosen_overload_index)
2708-
&& let Some(params) =
2709-
Self::normalize_singleton_function_type_into_params(callable.clone())
2710-
&& let Some(arg_index) = Self::active_parameter_index(&params, &active_argument)
2711-
&& let Some(param) = params.get(arg_index)
2712-
{
2713-
Self::add_literal_completions_from_type(
2714-
param.as_type(),
2715-
completions,
2716-
in_string_literal,
2717-
);
2718-
}
2719-
}
2720-
27212698
// Kept for backwards compatibility - used by external callers (lsp/server.rs, playground.rs)
27222699
// who don't need the is_incomplete flag
27232700
pub fn completion(

0 commit comments

Comments
 (0)