diff --git a/crates/tinymist-query/src/analysis/post_tyck.rs b/crates/tinymist-query/src/analysis/post_tyck.rs index 7fa9e9be..5b04f144 100644 --- a/crates/tinymist-query/src/analysis/post_tyck.rs +++ b/crates/tinymist-query/src/analysis/post_tyck.rs @@ -87,9 +87,8 @@ fn check_signature<'a>( } // names - for (name, _) in sig_ins.named_params() { - // todo: reduce fields, fields ty - let field = ParamTy::new_untyped(name.clone(), ParamAttrs::named()); + for (name, ty) in sig_ins.named_params() { + let field = ParamTy::new(ty.clone(), name.clone(), ParamAttrs::named()); receiver.insert(Ty::Param(field), !pol); } diff --git a/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict.typ.snap b/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict.typ.snap index 0340f002..d3f31d9d 100644 --- a/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict.typ.snap +++ b/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict.typ.snap @@ -3,7 +3,6 @@ source: crates/tinymist-query/src/completion.rs description: Completion on ) (63..64) expression: "JsonRepr::new_pure(results)" input_file: crates/tinymist-query/src/fixtures/completion/sig_dict.typ -snapshot_kind: text --- [ { @@ -12,6 +11,9 @@ snapshot_kind: text { "kind": 5, "label": "cap", + "labelDetails": { + "description": "\"butt\" | \"round\" | \"square\"" + }, "sortText": "000", "textEdit": { "newText": "cap: ${1:}", @@ -30,6 +32,9 @@ snapshot_kind: text { "kind": 5, "label": "paint", + "labelDetails": { + "description": "color" + }, "sortText": "004", "textEdit": { "newText": "paint: ${1:}", diff --git a/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict_rest.typ.snap b/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict_rest.typ.snap index d538093c..59a42c96 100644 --- a/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict_rest.typ.snap +++ b/crates/tinymist-query/src/fixtures/completion/snaps/test@sig_dict_rest.typ.snap @@ -3,7 +3,6 @@ source: crates/tinymist-query/src/completion.rs description: Completion on ) (75..76) expression: "JsonRepr::new_pure(results)" input_file: crates/tinymist-query/src/fixtures/completion/sig_dict_rest.typ -snapshot_kind: text --- [ { @@ -12,6 +11,9 @@ snapshot_kind: text { "kind": 5, "label": "cap", + "labelDetails": { + "description": "\"butt\" | \"round\" | \"square\"" + }, "sortText": "000", "textEdit": { "newText": "cap: ${1:}", diff --git a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element.typ.snap b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element.typ.snap index eae0ef24..bcfe8ee2 100644 --- a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element.typ.snap +++ b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element.typ.snap @@ -4,4 +4,4 @@ description: "Check on \"\\\"Test\\\"\" (34)" expression: post_ty input_file: crates/tinymist-query/src/fixtures/post_type_check/text_font_element.typ --- -( ⪰ TextFont | "covers": Any | "name": Any | (TextFont | Array)) +( ⪰ TextFont | "covers": (Type(regex) | "latin-in-cjk") | "name": TextFont | (TextFont | Array)) diff --git a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element2.typ.snap b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element2.typ.snap index d6ab3b7a..da9e597b 100644 --- a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element2.typ.snap +++ b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_font_element2.typ.snap @@ -4,4 +4,4 @@ description: "Check on \"\\\"Test\\\"\" (31)" expression: post_ty input_file: crates/tinymist-query/src/fixtures/post_type_check/text_font_element2.typ --- -( ⪰ ( ⪰ "Test" ⪯ (TextFont | Array)) ⪯ TextFont & "covers": Any & "name": Any) +( ⪰ ( ⪰ "Test" ⪯ (TextFont | Array)) ⪯ TextFont & "covers": (Type(regex) | "latin-in-cjk") & "name": TextFont) diff --git a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke.typ.snap b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke.typ.snap index b73ef2c5..bccb9476 100644 --- a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke.typ.snap +++ b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke.typ.snap @@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs description: "Check on \")\" (82)" expression: post_ty input_file: crates/tinymist-query/src/fixtures/post_type_check/text_stroke.typ -snapshot_kind: text --- -( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any) +( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length) diff --git a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke1.typ.snap b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke1.typ.snap index a7bdcd6e..694f69de 100644 --- a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke1.typ.snap +++ b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke1.typ.snap @@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs description: "Check on \"(\" (61)" expression: post_ty input_file: crates/tinymist-query/src/fixtures/post_type_check/text_stroke1.typ -snapshot_kind: text --- -( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any) +( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length) diff --git a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke3.typ.snap b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke3.typ.snap index 6c43bb28..f7f0d19a 100644 --- a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke3.typ.snap +++ b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@text_stroke3.typ.snap @@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs description: "Check on \"(\" (49)" expression: post_ty input_file: crates/tinymist-query/src/fixtures/post_type_check/text_stroke3.typ -snapshot_kind: text --- -( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any) +( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length) diff --git a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@user_func_pos2.typ.snap b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@user_func_pos2.typ.snap index 3506f96f..f4a7fe7b 100644 --- a/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@user_func_pos2.typ.snap +++ b/crates/tinymist-query/src/fixtures/post_type_check/snaps/test@user_func_pos2.typ.snap @@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs description: "Check on \"(\" (85)" expression: post_ty input_file: crates/tinymist-query/src/fixtures/post_type_check/user_func_pos2.typ -snapshot_kind: text --- -( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any) +( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length) diff --git a/crates/tinymist-query/src/ty/def.rs b/crates/tinymist-query/src/ty/def.rs index ef890483..44dd664b 100644 --- a/crates/tinymist-query/src/ty/def.rs +++ b/crates/tinymist-query/src/ty/def.rs @@ -620,9 +620,14 @@ pub struct ParamTy { impl ParamTy { /// Create an untyped field type pub fn new_untyped(name: StrRef, attrs: ParamAttrs) -> Interned { + Self::new(Ty::Any, name, attrs) + } + + /// Create a typed field type + pub fn new(ty: Ty, name: StrRef, attrs: ParamAttrs) -> Interned { Interned::new(Self { name, - ty: Ty::Any, + ty, docs: None, default: None, attrs,