From b1bf5f0edcb531163daa30f192a3f161b5666063 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 18 May 2020 18:08:28 +0200 Subject: [PATCH] vfmt: wrap long sum type definitions --- vlib/v/ast/ast.v | 11 +++++++++-- vlib/v/fmt/fmt.v | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index e0044cb80f..1a62284931 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -9,9 +9,16 @@ import v.errors pub type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl -pub type Expr = AnonFn | ArrayInit | AsCast | AssignExpr | Assoc | BoolLiteral | CallExpr | CastExpr | CharLiteral | ConcatExpr | EnumVal | FloatLiteral | Ident | IfExpr | IfGuardExpr | IndexExpr | InfixExpr | IntegerLiteral | MapInit | MatchExpr | None | OrExpr | ParExpr | PostfixExpr | PrefixExpr | RangeExpr | SelectorExpr | SizeOf | StringInterLiteral | StringLiteral | StructInit | Type | TypeOf +pub type Expr = AnonFn | ArrayInit | AsCast | AssignExpr | Assoc | BoolLiteral | CallExpr | + CastExpr | CharLiteral | ConcatExpr | EnumVal | FloatLiteral | Ident | IfExpr | IfGuardExpr | + IndexExpr | InfixExpr | IntegerLiteral | MapInit | MatchExpr | None | OrExpr | ParExpr | PostfixExpr | + PrefixExpr | RangeExpr | SelectorExpr | SizeOf | StringInterLiteral | StringLiteral | StructInit | + Type | TypeOf -pub type Stmt = AssertStmt | AssignStmt | Attr | Block | BranchStmt | Comment | CompIf | ConstDecl | DeferStmt | EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt | ForStmt | GlobalDecl | GoStmt | GotoLabel | GotoStmt | HashStmt | Import | InterfaceDecl | Module | Return | StructDecl | TypeDecl | UnsafeStmt +pub type Stmt = AssertStmt | AssignStmt | Attr | Block | BranchStmt | Comment | CompIf | ConstDecl | + DeferStmt | EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt | ForStmt | GlobalDecl | GoStmt | + GotoLabel | GotoStmt | HashStmt | Import | InterfaceDecl | Module | Return | StructDecl | TypeDecl | + UnsafeStmt pub type ScopeObject = ConstField | GlobalDecl | Var diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 76b8d1edd4..8158169591 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -413,7 +413,14 @@ fn (mut f Fmt) type_decl(node ast.TypeDecl) { sum_type_names << f.type_to_str(t) } sum_type_names.sort() - f.write(sum_type_names.join(' | ')) + for i, name in sum_type_names { + f.write(name) + if i < sum_type_names.len - 1 { + f.write(' | ') + } + f.wrap_long_line() + } + // f.write(sum_type_names.join(' | ')) } } f.writeln('\n')