(class js_ast.Class)
| 1026 | } |
| 1027 | |
| 1028 | func (p *printer) printClass(class js_ast.Class) { |
| 1029 | if class.ExtendsOrNil.Data != nil { |
| 1030 | p.print(" extends") |
| 1031 | p.printSpace() |
| 1032 | p.printExpr(class.ExtendsOrNil, js_ast.LNew-1, 0) |
| 1033 | } |
| 1034 | p.printSpace() |
| 1035 | |
| 1036 | p.addSourceMapping(class.BodyLoc) |
| 1037 | p.print("{") |
| 1038 | p.printNewline() |
| 1039 | p.options.Indent++ |
| 1040 | |
| 1041 | for _, item := range class.Properties { |
| 1042 | p.printSemicolonIfNeeded() |
| 1043 | omitIndent := p.printDecorators(item.Decorators, printNewlineAfterDecorator) |
| 1044 | if !omitIndent { |
| 1045 | p.printIndent() |
| 1046 | } |
| 1047 | |
| 1048 | if item.Kind == js_ast.PropertyClassStaticBlock { |
| 1049 | p.addSourceMapping(item.Loc) |
| 1050 | p.print("static") |
| 1051 | p.printSpace() |
| 1052 | p.printBlock(item.ClassStaticBlock.Loc, item.ClassStaticBlock.Block) |
| 1053 | p.printNewline() |
| 1054 | continue |
| 1055 | } |
| 1056 | |
| 1057 | p.printProperty(item) |
| 1058 | |
| 1059 | // Need semicolons after class fields |
| 1060 | if item.ValueOrNil.Data == nil { |
| 1061 | p.printSemicolonAfterStatement() |
| 1062 | } else { |
| 1063 | p.printNewline() |
| 1064 | } |
| 1065 | } |
| 1066 | |
| 1067 | p.needsSemicolon = false |
| 1068 | p.printExprCommentsAfterCloseTokenAtLoc(class.CloseBraceLoc) |
| 1069 | p.options.Indent-- |
| 1070 | p.printIndent() |
| 1071 | if class.CloseBraceLoc.Start > class.BodyLoc.Start { |
| 1072 | p.addSourceMapping(class.CloseBraceLoc) |
| 1073 | } |
| 1074 | p.print("}") |
| 1075 | } |
| 1076 | |
| 1077 | func (p *printer) printProperty(property js_ast.Property) { |
| 1078 | p.printExprCommentsAtLoc(property.Loc) |
no test coverage detected