ast: add comments for struct 'StructInit' and 'StructInitField' (#13551)

pull/13553/head
yuyi 2022-02-21 18:48:53 +08:00 committed by GitHub
parent 8ba4a3dd01
commit 83cdd8bedd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -368,6 +368,7 @@ pub mut:
are_embeds_expanded bool are_embeds_expanded bool
} }
// `field1: val1`
pub struct StructInitField { pub struct StructInitField {
pub: pub:
pos token.Pos pos token.Pos
@ -375,9 +376,9 @@ pub:
comments []Comment comments []Comment
next_comments []Comment next_comments []Comment
pub mut: pub mut:
expr Expr expr Expr // `val1`
name string name string // 'field1'
typ Type typ Type // the type of this field
expected_type Type expected_type Type
parent_type Type parent_type Type
} }
@ -394,22 +395,26 @@ pub mut:
expected_type Type expected_type Type
} }
// `s := Foo{
// ...a
// field1: 'hello'
// }`
pub struct StructInit { pub struct StructInit {
pub: pub:
pos token.Pos pos token.Pos
name_pos token.Pos name_pos token.Pos
is_short bool is_short bool // Foo{val1, val2}
is_short_syntax bool is_short_syntax bool // foo(field1: val1, field2: val2)
pub mut: pub mut:
unresolved bool unresolved bool
pre_comments []Comment pre_comments []Comment
typ_str string typ_str string // 'Foo'
typ Type typ Type // the type of this struct
update_expr Expr update_expr Expr // `a` in `...a`
update_expr_type Type update_expr_type Type
update_expr_comments []Comment update_expr_comments []Comment
is_update_embed bool is_update_embed bool
has_update_expr bool has_update_expr bool // has `...a`
fields []StructInitField fields []StructInitField
embeds []StructInitEmbed embeds []StructInitEmbed
generic_types []Type generic_types []Type