mirror of
https://github.com/erg-lang/erg.git
synced 2025-07-07 21:25:31 +00:00
Update inlay_hint.rs
This commit is contained in:
parent
db61dd8742
commit
ddec7f50d6
1 changed files with 13 additions and 6 deletions
|
@ -172,9 +172,14 @@ impl<Checker: BuildRunnable> Server<Checker> {
|
|||
|
||||
fn get_lambda_hint(&self, lambda: &Lambda) -> Vec<InlayHint> {
|
||||
let mut result = vec![];
|
||||
result.extend(self.get_block_hint(&lambda.body));
|
||||
let subr_t = lambda.ref_t();
|
||||
let nd_ts = subr_t.non_default_params().unwrap();
|
||||
let d_ts = subr_t.default_params().unwrap();
|
||||
let Some(nd_ts) = subr_t.non_default_params() else {
|
||||
return result;
|
||||
};
|
||||
let Some(d_ts) = subr_t.default_params() else {
|
||||
return result;
|
||||
};
|
||||
for (nd_param, nd_t) in lambda.params.non_defaults.iter().zip(nd_ts) {
|
||||
if nd_param.t_spec.is_some() {
|
||||
continue;
|
||||
|
@ -215,7 +220,6 @@ impl<Checker: BuildRunnable> Server<Checker> {
|
|||
result.push(hint);
|
||||
}
|
||||
result.push(hint);
|
||||
result.extend(self.get_block_hint(&lambda.body));
|
||||
result
|
||||
}
|
||||
|
||||
|
@ -241,18 +245,21 @@ impl<Checker: BuildRunnable> Server<Checker> {
|
|||
result.extend(self.get_expr_hint(&pos_arg.expr));
|
||||
let index = if is_method { i + 1 } else { i };
|
||||
if let Some(name) = param_ts.clone().nth(index).and_then(|pt| pt.name()) {
|
||||
let (Some(ln_begin), Some(col_begin)) = (pos_arg.ln_begin(), pos_arg.col_begin()) else {
|
||||
continue;
|
||||
};
|
||||
// f i -> ...
|
||||
// NG: f(proc:= i: T): U -> ...
|
||||
// OK: f proc:= (i: T): U -> ...
|
||||
let (name, col_begin) = if arg_is_lambda {
|
||||
(
|
||||
format!(" {name}"),
|
||||
pos_arg.col_begin().unwrap().saturating_sub(1),
|
||||
col_begin.saturating_sub(1),
|
||||
)
|
||||
} else {
|
||||
(name.to_string(), pos_arg.col_begin().unwrap())
|
||||
(name.to_string(), col_begin)
|
||||
};
|
||||
let hint = param_anot(pos_arg.ln_begin().unwrap(), col_begin, name);
|
||||
let hint = param_anot(ln_begin, col_begin, name);
|
||||
result.push(hint);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue