Skip to content

Commit 5066a4f

Browse files
committed
add doc comment for ActiveArgument enum
1 parent 9e335a0 commit 5066a4f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pyrefly/lib/state/lsp.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ use crate::types::callable::Params;
8686
use crate::types::module::ModuleType;
8787
use crate::types::types::Type;
8888

89-
#[derive(Debug, Clone)]
90-
enum ActiveArgument {
91-
Positional(usize),
92-
Keyword(Name),
93-
Next(usize),
94-
}
95-
9689
fn default_true() -> bool {
9790
true
9891
}
@@ -481,6 +474,14 @@ pub struct FindDefinitionItem {
481474
pub module: Module,
482475
}
483476

477+
/// The currently active argument in a function call for signature help.
478+
#[derive(Debug)]
479+
enum ActiveArgument {
480+
Positional(usize),
481+
Keyword(Name),
482+
Next(usize),
483+
}
484+
484485
impl<'a> Transaction<'a> {
485486
fn get_type(&self, handle: &Handle, key: &Key) -> Option<Type> {
486487
let idx = self.get_bindings(handle)?.key_to_idx(key);
@@ -872,7 +873,7 @@ impl<'a> Transaction<'a> {
872873
}
873874
}
874875
// Check keyword arguments
875-
let positional_count = call.arguments.args.len();
876+
let kwarg_start_idx = call.arguments.args.len();
876877
for (j, kw) in call.arguments.keywords.iter().enumerate() {
877878
if kw.range.contains_inclusive(find) {
878879
Self::visit_finding_signature_range(&kw.value, find, res);
@@ -881,7 +882,7 @@ impl<'a> Transaction<'a> {
881882
}
882883
let active_argument = match kw.arg.as_ref() {
883884
Some(identifier) => ActiveArgument::Keyword(identifier.id.clone()),
884-
None => ActiveArgument::Positional(positional_count + j),
885+
None => ActiveArgument::Positional(kwarg_start_idx + j),
885886
};
886887
*res = Some((call.func.range(), call.arguments.range, active_argument));
887888
return;

0 commit comments

Comments
 (0)