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