dev: filter settable parameter if is in set context (#857)

This commit is contained in:
Myriad-Dreamin 2024-11-20 01:47:56 +08:00 committed by GitHub
parent e95e4284b1
commit 37ea3b8d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 4 deletions

View file

@ -223,10 +223,6 @@ impl<'a> PostTypeChecker<'a> {
log::debug!("post check call sig: {target:?} {sig:?}");
let mut resp = SignatureReceiver::default();
// if set && !param.attrs.settable {
// continue;
// }
match &target {
ParamTarget::Named(n) => {
let ident = n.cast::<ast::Ident>()?.into();
@ -256,6 +252,10 @@ impl<'a> PostTypeChecker<'a> {
// names
for field in sig.primary().named() {
if is_set && !field.attrs.settable {
continue;
}
resp.insert(Ty::Param(field.clone()), false);
}
}

View file

@ -0,0 +1,2 @@
/// contains: body, fill
#set text(/* range 0..1 */ )

View file

@ -0,0 +1,34 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (35..36)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/set_param.typ
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 5,
"label": "fill",
"labelDetails": {
"description": "color"
},
"sortText": "010",
"textEdit": {
"newText": "fill: ${1:}",
"range": {
"end": {
"character": 10,
"line": 1
},
"start": {
"character": 10,
"line": 1
}
}
}
}
]
}
]