fmt: fix formatting enum with attributes (#6551)

pull/6554/head
Enzo 2020-10-03 20:33:02 +02:00 committed by GitHub
parent c5e46c9e55
commit c84848c417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 0 deletions

View File

@ -686,6 +686,7 @@ pub:
is_multi_allowed bool is_multi_allowed bool
comments []Comment // enum Abc { /* comments */ ... } comments []Comment // enum Abc { /* comments */ ... }
fields []EnumField fields []EnumField
attrs []table.Attr
pos token.Position pos token.Position
} }

View File

@ -319,6 +319,7 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) {
f.writeln('}') f.writeln('}')
} }
ast.EnumDecl { ast.EnumDecl {
f.attrs(it.attrs)
if it.is_pub { if it.is_pub {
f.write('pub ') f.write('pub ')
} }

View File

@ -14,3 +14,9 @@ struct User {
typ int [json: 'type'] typ int [json: 'type']
pets string [raw; json: 'pet_animals'] pets string [raw; json: 'pet_animals']
} }
[_allow_multiple_values]
enum Example {
value1 = 1
value1_again = 1
}

View File

@ -1804,6 +1804,7 @@ $pubfn (mut e $enum_name) toggle(flag $enum_name) { unsafe{ *e = int(*e) ^ (
is_multi_allowed: is_multi_allowed is_multi_allowed: is_multi_allowed
fields: fields fields: fields
pos: start_pos.extend(end_pos) pos: start_pos.extend(end_pos)
attrs: p.attrs
comments: enum_decl_comments comments: enum_decl_comments
} }
} }