prettier-plugin-java 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/LICENSE +1 -1
  2. package/dist/base-cst-printer.js +22 -44
  3. package/dist/cst-printer.js +19 -27
  4. package/dist/index.js +19 -20
  5. package/dist/options.js +16 -21
  6. package/dist/parser.js +2 -4
  7. package/dist/printer.js +3 -5
  8. package/dist/printers/arrays.js +17 -41
  9. package/dist/printers/blocks-and-statements.js +289 -356
  10. package/dist/printers/classes.js +451 -495
  11. package/dist/printers/comments/comments-utils.js +5 -13
  12. package/dist/printers/comments/format-comments.js +34 -50
  13. package/dist/printers/comments/handle-comments.js +17 -23
  14. package/dist/printers/expressions.js +378 -386
  15. package/dist/printers/interfaces.js +148 -181
  16. package/dist/printers/lexical-structure.js +26 -58
  17. package/dist/printers/names.js +29 -53
  18. package/dist/printers/packages-and-modules.js +116 -143
  19. package/dist/printers/prettier-builder.js +21 -31
  20. package/dist/printers/printer-utils.js +173 -221
  21. package/dist/printers/types-values-and-variables.js +111 -149
  22. package/dist/types/utils.js +6 -15
  23. package/dist/utils/expressions-utils.js +7 -11
  24. package/dist/utils/index.js +2 -12
  25. package/dist/utils/isEmptyDoc.js +2 -4
  26. package/dist/utils/printArgumentListWithBraces.js +29 -19
  27. package/dist/utils/printSingleLambdaInvocation.js +15 -17
  28. package/package.json +10 -13
  29. package/dist/src/base-cst-printer.js +0 -77
  30. package/dist/src/cst-printer.js +0 -37
  31. package/dist/src/index.js +0 -67
  32. package/dist/src/options.js +0 -256
  33. package/dist/src/parser.js +0 -7
  34. package/dist/src/printer.js +0 -28
  35. package/dist/src/printers/arrays.js +0 -49
  36. package/dist/src/printers/blocks-and-statements.js +0 -493
  37. package/dist/src/printers/classes.js +0 -724
  38. package/dist/src/printers/comments/comments-utils.js +0 -29
  39. package/dist/src/printers/comments/format-comments.js +0 -187
  40. package/dist/src/printers/comments/handle-comments.js +0 -38
  41. package/dist/src/printers/expressions.js +0 -549
  42. package/dist/src/printers/interfaces.js +0 -251
  43. package/dist/src/printers/lexical-structure.js +0 -43
  44. package/dist/src/printers/names.js +0 -53
  45. package/dist/src/printers/packages-and-modules.js +0 -185
  46. package/dist/src/printers/prettier-builder.js +0 -47
  47. package/dist/src/printers/printer-utils.js +0 -577
  48. package/dist/src/printers/types-values-and-variables.js +0 -183
  49. package/dist/src/types/utils.js +0 -29
  50. package/dist/src/utils/expressions-utils.js +0 -29
  51. package/dist/src/utils/index.js +0 -10
  52. package/dist/src/utils/printArgumentListWithBraces.js +0 -21
  53. package/dist/src/utils/printSingleLambdaInvocation.js +0 -20
  54. package/dist/test/babel-register.js +0 -3
  55. package/dist/test/repository-test/core-test.js +0 -12
  56. package/dist/test/repository-test/jhipster-1-test.js +0 -17
  57. package/dist/test/repository-test/jhipster-2-test.js +0 -16
  58. package/dist/test/test-utils.js +0 -215
  59. package/dist/test/unit-test/annotation_type_declaration/annotation_type_declaration-spec.js +0 -6
  60. package/dist/test/unit-test/args/args-spec.js +0 -6
  61. package/dist/test/unit-test/assert/assert-spec.js +0 -6
  62. package/dist/test/unit-test/binary_expressions/binary_expressions-spec.js +0 -6
  63. package/dist/test/unit-test/blank_lines/blank_lines-spec.js +0 -6
  64. package/dist/test/unit-test/bug-fixes/bug-fixes-spec.js +0 -6
  65. package/dist/test/unit-test/cast/cast-spec.js +0 -6
  66. package/dist/test/unit-test/char_literal/char_literal-spec.js +0 -6
  67. package/dist/test/unit-test/classes/multiple_classes-spec.js +0 -6
  68. package/dist/test/unit-test/comments/comments-spec.js +0 -14
  69. package/dist/test/unit-test/complex_generic_class/complex_generic_class-spec.js +0 -6
  70. package/dist/test/unit-test/constructors/constructors-spec.js +0 -6
  71. package/dist/test/unit-test/empty_statement/empty_statement-spec.js +0 -6
  72. package/dist/test/unit-test/enum/enum-spec.js +0 -6
  73. package/dist/test/unit-test/expressions/expressions-spec.js +0 -6
  74. package/dist/test/unit-test/extends_abstract_class/extends_abstract_class-spec.js +0 -6
  75. package/dist/test/unit-test/extends_abstract_class_and_implements_interfaces/extends_abstract_class_and_implements_interfaces-spec.js +0 -6
  76. package/dist/test/unit-test/for/for-spec.js +0 -6
  77. package/dist/test/unit-test/generic_class/generic_class-spec.js +0 -6
  78. package/dist/test/unit-test/generic_questionmark/generic_questionmark-spec.js +0 -6
  79. package/dist/test/unit-test/hello-world/hello-word-spec.js +0 -6
  80. package/dist/test/unit-test/if/if-spec.js +0 -6
  81. package/dist/test/unit-test/indent/indent-spec.js +0 -6
  82. package/dist/test/unit-test/instantiation/instantiation-spec.js +0 -6
  83. package/dist/test/unit-test/interface/interface-spec.js +0 -6
  84. package/dist/test/unit-test/lambda/lambda-spec.js +0 -6
  85. package/dist/test/unit-test/marker_annotations/marker_annotations-spec.js +0 -6
  86. package/dist/test/unit-test/member_chain/member_chain-spec.js +0 -6
  87. package/dist/test/unit-test/method_reference/method_reference-spec.js +0 -6
  88. package/dist/test/unit-test/modifiers/modifiers-spec.js +0 -6
  89. package/dist/test/unit-test/modules/modules-spec.js +0 -6
  90. package/dist/test/unit-test/package_and_imports/package_and_imports-spec.js +0 -34
  91. package/dist/test/unit-test/pattern-matching/pattern-matching-spec.js +0 -6
  92. package/dist/test/unit-test/prettier-ignore/prettier-ignore-spec.js +0 -28
  93. package/dist/test/unit-test/records/records-spec.js +0 -6
  94. package/dist/test/unit-test/return/return-spec.js +0 -6
  95. package/dist/test/unit-test/sealed/sealed-spec.js +0 -6
  96. package/dist/test/unit-test/snippets/arrays/array-initializer.spec.js +0 -94
  97. package/dist/test/unit-test/snippets/arrays/variable-initializer-list.spec.js +0 -19
  98. package/dist/test/unit-test/snippets/blocks-and-statements/switch.spec.js +0 -26
  99. package/dist/test/unit-test/snippets/classes/class-body.spec.js +0 -181
  100. package/dist/test/unit-test/snippets/classes/enum-body.spec.js +0 -87
  101. package/dist/test/unit-test/snippets/classes/variableDeclarator/test.spec.js +0 -186
  102. package/dist/test/unit-test/snippets/interfaces/element-value-array-initializer.spec.js +0 -85
  103. package/dist/test/unit-test/snippets/names/ambiguousName/test.spec.js +0 -19
  104. package/dist/test/unit-test/snippets/names/expressionName/test.spec.js +0 -19
  105. package/dist/test/unit-test/snippets/names/methodName/test.spec.js +0 -12
  106. package/dist/test/unit-test/snippets/names/packageOrTypeName/test.spec.js +0 -19
  107. package/dist/test/unit-test/snippets/types-values-and-variables/floatingPointType/test.spec.js +0 -19
  108. package/dist/test/unit-test/snippets/types-values-and-variables/integralType/test.spec.js +0 -40
  109. package/dist/test/unit-test/snippets/types-values-and-variables/numericType/test.spec.js +0 -88
  110. package/dist/test/unit-test/snippets/types-values-and-variables/wildcard/test.spec.js +0 -112
  111. package/dist/test/unit-test/snippets/types-values-and-variables/wildcardBounds/test.spec.js +0 -81
  112. package/dist/test/unit-test/switch/switch-spec.js +0 -6
  113. package/dist/test/unit-test/synchronized/synchronized-spec.js +0 -6
  114. package/dist/test/unit-test/text-blocks/text-block-spec.js +0 -6
  115. package/dist/test/unit-test/throws/throws-spec.js +0 -6
  116. package/dist/test/unit-test/try_catch/try_catch-spec.js +0 -6
  117. package/dist/test/unit-test/types/types-spec.js +0 -6
  118. package/dist/test/unit-test/variables/variables-spec.js +0 -6
  119. package/dist/test/unit-test/while/while-spec.js +0 -6
  120. package/dist/test/unit-test/yield-statement/yield-statement-spec.js +0 -6
@@ -1,55 +1,19 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.ClassesPrettierVisitor = void 0;
33
- var forEach_1 = __importDefault(require("lodash/forEach"));
34
- var printer_utils_1 = require("./printer-utils");
35
- var prettier_builder_1 = require("./prettier-builder");
36
- var format_comments_1 = require("./comments/format-comments");
37
- var comments_utils_1 = require("./comments/comments-utils");
38
- var doc_1 = require("prettier/doc");
39
- var base_cst_printer_1 = require("../base-cst-printer");
40
- var utils_1 = require("../types/utils");
41
- var utils_2 = require("../utils");
42
- var line = doc_1.builders.line, softline = doc_1.builders.softline, hardline = doc_1.builders.hardline, lineSuffixBoundary = doc_1.builders.lineSuffixBoundary;
43
- var ClassesPrettierVisitor = /** @class */ (function (_super) {
44
- __extends(ClassesPrettierVisitor, _super);
45
- function ClassesPrettierVisitor() {
46
- return _super !== null && _super.apply(this, arguments) || this;
47
- }
48
- ClassesPrettierVisitor.prototype.classDeclaration = function (ctx) {
49
- var modifiers = (0, printer_utils_1.sortModifiers)(ctx.classModifier);
50
- var firstAnnotations = this.mapVisit(modifiers[0]);
51
- var otherModifiers = this.mapVisit(modifiers[1]);
52
- var classCST;
1
+ import forEach from "lodash/forEach.js";
2
+ import { displaySemicolon, getBlankLinesSeparator, getClassBodyDeclarationsSeparator, isStatementEmptyStatement, putIntoBraces, reject, rejectAndConcat, rejectAndJoin, rejectAndJoinSeps, sortClassTypeChildren, sortModifiers } from "./printer-utils.js";
3
+ import { concat, group, indent, join, indentIfBreak } from "./prettier-builder.js";
4
+ import { printTokenWithComments } from "./comments/format-comments.js";
5
+ import { hasLeadingComments, hasLeadingLineComments } from "./comments/comments-utils.js";
6
+ import { builders } from "prettier/doc";
7
+ import { BaseCstPrettierPrinter } from "../base-cst-printer.js";
8
+ import { isAnnotationCstNode, isTypeArgumentsCstNode } from "../types/utils.js";
9
+ import { printArgumentListWithBraces } from "../utils/index.js";
10
+ const { line, softline, hardline, lineSuffixBoundary } = builders;
11
+ export class ClassesPrettierVisitor extends BaseCstPrettierPrinter {
12
+ classDeclaration(ctx) {
13
+ const modifiers = sortModifiers(ctx.classModifier);
14
+ const firstAnnotations = this.mapVisit(modifiers[0]);
15
+ const otherModifiers = this.mapVisit(modifiers[1]);
16
+ let classCST;
53
17
  if (ctx.normalClassDeclaration !== undefined) {
54
18
  classCST = ctx.normalClassDeclaration;
55
19
  }
@@ -59,34 +23,34 @@ var ClassesPrettierVisitor = /** @class */ (function (_super) {
59
23
  else {
60
24
  classCST = ctx.recordDeclaration;
61
25
  }
62
- var classDoc = this.visit(classCST);
63
- return (0, printer_utils_1.rejectAndJoin)(hardline, [
64
- (0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
65
- (0, printer_utils_1.rejectAndJoin)(" ", [(0, prettier_builder_1.join)(" ", otherModifiers), classDoc])
26
+ const classDoc = this.visit(classCST);
27
+ return rejectAndJoin(hardline, [
28
+ rejectAndJoin(hardline, firstAnnotations),
29
+ rejectAndJoin(" ", [join(" ", otherModifiers), classDoc])
66
30
  ]);
67
- };
68
- ClassesPrettierVisitor.prototype.normalClassDeclaration = function (ctx) {
69
- var name = this.visit(ctx.typeIdentifier);
70
- var optionalTypeParams = this.visit(ctx.typeParameters);
71
- var optionalSuperClasses = this.visit(ctx.superclass);
72
- var optionalSuperInterfaces = this.visit(ctx.superinterfaces);
73
- var optionalClassPermits = this.visit(ctx.classPermits);
74
- var body = this.visit(ctx.classBody, { isNormalClassDeclaration: true });
75
- var superClassesPart = "";
31
+ }
32
+ normalClassDeclaration(ctx) {
33
+ const name = this.visit(ctx.typeIdentifier);
34
+ const optionalTypeParams = this.visit(ctx.typeParameters);
35
+ const optionalSuperClasses = this.visit(ctx.superclass);
36
+ const optionalSuperInterfaces = this.visit(ctx.superinterfaces);
37
+ const optionalClassPermits = this.visit(ctx.classPermits);
38
+ const body = this.visit(ctx.classBody, { isNormalClassDeclaration: true });
39
+ let superClassesPart = "";
76
40
  if (optionalSuperClasses) {
77
- superClassesPart = (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, optionalSuperClasses]));
41
+ superClassesPart = indent(rejectAndConcat([line, optionalSuperClasses]));
78
42
  }
79
- var superInterfacesPart = "";
43
+ let superInterfacesPart = "";
80
44
  if (optionalSuperInterfaces) {
81
- superInterfacesPart = (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, optionalSuperInterfaces]));
45
+ superInterfacesPart = indent(rejectAndConcat([line, optionalSuperInterfaces]));
82
46
  }
83
- var classPermits = "";
47
+ let classPermits = "";
84
48
  if (optionalClassPermits) {
85
- classPermits = (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, optionalClassPermits]));
49
+ classPermits = indent(rejectAndConcat([line, optionalClassPermits]));
86
50
  }
87
- return (0, printer_utils_1.rejectAndJoin)(" ", [
88
- (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([
89
- (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Class[0], name]),
51
+ return rejectAndJoin(" ", [
52
+ group(rejectAndConcat([
53
+ rejectAndJoin(" ", [ctx.Class[0], name]),
90
54
  optionalTypeParams,
91
55
  superClassesPart,
92
56
  superInterfacesPart,
@@ -94,114 +58,114 @@ var ClassesPrettierVisitor = /** @class */ (function (_super) {
94
58
  ])),
95
59
  body
96
60
  ]);
97
- };
98
- ClassesPrettierVisitor.prototype.classModifier = function (ctx) {
61
+ }
62
+ classModifier(ctx) {
99
63
  if (ctx.annotation) {
100
64
  return this.visit(ctx.annotation);
101
65
  }
102
66
  // public | protected | private | ...
103
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
104
- };
105
- ClassesPrettierVisitor.prototype.typeParameters = function (ctx) {
106
- var typeParameterList = this.visit(ctx.typeParameterList);
107
- return (0, printer_utils_1.putIntoBraces)(typeParameterList, softline, ctx.Less[0], ctx.Greater[0]);
108
- };
109
- ClassesPrettierVisitor.prototype.typeParameterList = function (ctx) {
110
- var typeParameter = this.mapVisit(ctx.typeParameter);
111
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
112
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoinSeps)(commas, typeParameter));
113
- };
114
- ClassesPrettierVisitor.prototype.superclass = function (ctx) {
115
- return (0, prettier_builder_1.join)(" ", [ctx.Extends[0], this.visit(ctx.classType)]);
116
- };
117
- ClassesPrettierVisitor.prototype.superinterfaces = function (ctx) {
118
- var interfaceTypeList = this.visit(ctx.interfaceTypeList);
119
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([
67
+ return printTokenWithComments(this.getSingle(ctx));
68
+ }
69
+ typeParameters(ctx) {
70
+ const typeParameterList = this.visit(ctx.typeParameterList);
71
+ return putIntoBraces(typeParameterList, softline, ctx.Less[0], ctx.Greater[0]);
72
+ }
73
+ typeParameterList(ctx) {
74
+ const typeParameter = this.mapVisit(ctx.typeParameter);
75
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
76
+ return group(rejectAndJoinSeps(commas, typeParameter));
77
+ }
78
+ superclass(ctx) {
79
+ return join(" ", [ctx.Extends[0], this.visit(ctx.classType)]);
80
+ }
81
+ superinterfaces(ctx) {
82
+ const interfaceTypeList = this.visit(ctx.interfaceTypeList);
83
+ return group(rejectAndConcat([
120
84
  ctx.Implements[0],
121
- (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, interfaceTypeList]))
85
+ indent(rejectAndConcat([line, interfaceTypeList]))
122
86
  ]));
123
- };
124
- ClassesPrettierVisitor.prototype.classPermits = function (ctx) {
125
- var typeNames = this.mapVisit(ctx.typeName);
126
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
127
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([
87
+ }
88
+ classPermits(ctx) {
89
+ const typeNames = this.mapVisit(ctx.typeName);
90
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
91
+ return group(rejectAndConcat([
128
92
  ctx.Permits[0],
129
- (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoinSeps)(commas, typeNames))]))
93
+ indent(rejectAndConcat([line, group(rejectAndJoinSeps(commas, typeNames))]))
130
94
  ]));
131
- };
132
- ClassesPrettierVisitor.prototype.interfaceTypeList = function (ctx) {
133
- var interfaceType = this.mapVisit(ctx.interfaceType);
134
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
135
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoinSeps)(commas, interfaceType));
136
- };
137
- ClassesPrettierVisitor.prototype.classBody = function (ctx, param) {
138
- var content = "";
95
+ }
96
+ interfaceTypeList(ctx) {
97
+ const interfaceType = this.mapVisit(ctx.interfaceType);
98
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
99
+ return group(rejectAndJoinSeps(commas, interfaceType));
100
+ }
101
+ classBody(ctx, param) {
102
+ let content = "";
139
103
  if (ctx.classBodyDeclaration !== undefined) {
140
- var classBodyDeclsVisited = (0, printer_utils_1.reject)(this.mapVisit(ctx.classBodyDeclaration));
141
- var separators = (0, printer_utils_1.getClassBodyDeclarationsSeparator)(ctx.classBodyDeclaration);
142
- content = (0, printer_utils_1.rejectAndJoinSeps)(separators, classBodyDeclsVisited);
104
+ const classBodyDeclsVisited = reject(this.mapVisit(ctx.classBodyDeclaration));
105
+ const separators = getClassBodyDeclarationsSeparator(ctx.classBodyDeclaration);
106
+ content = rejectAndJoinSeps(separators, classBodyDeclsVisited);
143
107
  // edge case when we have SemiColons
144
- var shouldHardline_1 = false;
145
- ctx.classBodyDeclaration.forEach(function (elt) {
108
+ let shouldHardline = false;
109
+ ctx.classBodyDeclaration.forEach(elt => {
146
110
  if ((elt.children.classMemberDeclaration &&
147
111
  !elt.children.classMemberDeclaration[0].children.Semicolon) ||
148
112
  elt.children.constructorDeclaration) {
149
- shouldHardline_1 = true;
113
+ shouldHardline = true;
150
114
  }
151
115
  });
152
116
  if ((ctx.classBodyDeclaration[0].children.classMemberDeclaration ||
153
117
  ctx.classBodyDeclaration[0].children.constructorDeclaration) &&
154
- shouldHardline_1 &&
118
+ shouldHardline &&
155
119
  param &&
156
120
  param.isNormalClassDeclaration) {
157
- content = (0, printer_utils_1.rejectAndConcat)([hardline, content]);
121
+ content = rejectAndConcat([hardline, content]);
158
122
  }
159
123
  }
160
- return (0, printer_utils_1.putIntoBraces)(content, hardline, ctx.LCurly[0], ctx.RCurly[0]);
161
- };
162
- ClassesPrettierVisitor.prototype.classBodyDeclaration = function (ctx) {
124
+ return putIntoBraces(content, hardline, ctx.LCurly[0], ctx.RCurly[0]);
125
+ }
126
+ classBodyDeclaration(ctx) {
163
127
  return this.visitSingle(ctx);
164
- };
165
- ClassesPrettierVisitor.prototype.classMemberDeclaration = function (ctx) {
128
+ }
129
+ classMemberDeclaration(ctx) {
166
130
  if (ctx.Semicolon) {
167
- return (0, printer_utils_1.displaySemicolon)(ctx.Semicolon[0]);
131
+ return displaySemicolon(ctx.Semicolon[0]);
168
132
  }
169
133
  return this.visitSingle(ctx);
170
- };
171
- ClassesPrettierVisitor.prototype.fieldDeclaration = function (ctx) {
172
- var modifiers = (0, printer_utils_1.sortModifiers)(ctx.fieldModifier);
173
- var firstAnnotations = this.mapVisit(modifiers[0]);
174
- var otherModifiers = this.mapVisit(modifiers[1]);
175
- var unannType = this.visit(ctx.unannType);
176
- var variableDeclaratorList = this.visit(ctx.variableDeclaratorList);
177
- return (0, printer_utils_1.rejectAndJoin)(hardline, [
178
- (0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
179
- (0, printer_utils_1.rejectAndJoin)(" ", [
180
- (0, printer_utils_1.rejectAndJoin)(" ", otherModifiers),
134
+ }
135
+ fieldDeclaration(ctx) {
136
+ const modifiers = sortModifiers(ctx.fieldModifier);
137
+ const firstAnnotations = this.mapVisit(modifiers[0]);
138
+ const otherModifiers = this.mapVisit(modifiers[1]);
139
+ const unannType = this.visit(ctx.unannType);
140
+ const variableDeclaratorList = this.visit(ctx.variableDeclaratorList);
141
+ return rejectAndJoin(hardline, [
142
+ rejectAndJoin(hardline, firstAnnotations),
143
+ rejectAndJoin(" ", [
144
+ rejectAndJoin(" ", otherModifiers),
181
145
  unannType,
182
- (0, prettier_builder_1.concat)([variableDeclaratorList, ctx.Semicolon[0]])
146
+ concat([variableDeclaratorList, ctx.Semicolon[0]])
183
147
  ])
184
148
  ]);
185
- };
186
- ClassesPrettierVisitor.prototype.fieldModifier = function (ctx) {
149
+ }
150
+ fieldModifier(ctx) {
187
151
  if (ctx.annotation) {
188
152
  return this.visit(ctx.annotation);
189
153
  }
190
154
  // public | protected | private | ...
191
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
192
- };
193
- ClassesPrettierVisitor.prototype.variableDeclaratorList = function (ctx) {
194
- var variableDeclarators = this.mapVisit(ctx.variableDeclarator);
195
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, " "]); }) : [];
196
- return (0, printer_utils_1.rejectAndJoinSeps)(commas, variableDeclarators);
197
- };
198
- ClassesPrettierVisitor.prototype.variableDeclarator = function (ctx) {
199
- var variableDeclaratorId = this.visit(ctx.variableDeclaratorId);
155
+ return printTokenWithComments(this.getSingle(ctx));
156
+ }
157
+ variableDeclaratorList(ctx) {
158
+ const variableDeclarators = this.mapVisit(ctx.variableDeclarator);
159
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, " "])) : [];
160
+ return rejectAndJoinSeps(commas, variableDeclarators);
161
+ }
162
+ variableDeclarator(ctx) {
163
+ const variableDeclaratorId = this.visit(ctx.variableDeclaratorId);
200
164
  if (ctx.Equals) {
201
- var variableInitializer = this.visit(ctx.variableInitializer);
202
- if ((0, comments_utils_1.hasLeadingLineComments)(ctx.variableInitializer[0])) {
203
- return (0, prettier_builder_1.group)((0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndJoin)(hardline, [
204
- (0, printer_utils_1.rejectAndJoin)(" ", [variableDeclaratorId, ctx.Equals[0]]),
165
+ const variableInitializer = this.visit(ctx.variableInitializer);
166
+ if (hasLeadingLineComments(ctx.variableInitializer[0])) {
167
+ return group(indent(rejectAndJoin(hardline, [
168
+ rejectAndJoin(" ", [variableDeclaratorId, ctx.Equals[0]]),
205
169
  variableInitializer
206
170
  ])));
207
171
  }
@@ -216,527 +180,519 @@ var ClassesPrettierVisitor = /** @class */ (function (_super) {
216
180
  .ternaryExpression !== undefined &&
217
181
  ctx.variableInitializer[0].children.expression[0].children
218
182
  .ternaryExpression[0].children.QuestionMark !== undefined)) {
219
- var groupId = Symbol("assignment");
220
- return (0, prettier_builder_1.group)([
221
- (0, prettier_builder_1.group)(variableDeclaratorId),
183
+ const groupId = Symbol("assignment");
184
+ return group([
185
+ group(variableDeclaratorId),
222
186
  " ",
223
187
  ctx.Equals[0],
224
- (0, prettier_builder_1.group)((0, prettier_builder_1.indent)(line), { id: groupId }),
188
+ group(indent(line), { id: groupId }),
225
189
  lineSuffixBoundary,
226
- (0, prettier_builder_1.indentIfBreak)(variableInitializer, { groupId: groupId })
190
+ indentIfBreak(variableInitializer, { groupId })
227
191
  ]);
228
192
  }
229
193
  if (ctx.variableInitializer[0].children.expression[0].children
230
194
  .ternaryExpression !== undefined) {
231
- var unaryExpressions = ctx.variableInitializer[0].children.expression[0].children
195
+ const unaryExpressions = ctx.variableInitializer[0].children.expression[0].children
232
196
  .ternaryExpression[0].children.binaryExpression[0].children
233
197
  .unaryExpression;
234
- var firstPrimary = unaryExpressions[0].children.primary[0];
198
+ const firstPrimary = unaryExpressions[0].children.primary[0];
235
199
  // Cast Expression
236
200
  if (firstPrimary.children.primaryPrefix[0].children.castExpression !==
237
201
  undefined &&
238
202
  unaryExpressions.length === 1) {
239
- var groupId = Symbol("assignment");
240
- return (0, prettier_builder_1.group)([
241
- (0, prettier_builder_1.group)(variableDeclaratorId),
203
+ const groupId = Symbol("assignment");
204
+ return group([
205
+ group(variableDeclaratorId),
242
206
  " ",
243
207
  ctx.Equals[0],
244
- (0, prettier_builder_1.group)((0, prettier_builder_1.indent)(line), { id: groupId }),
208
+ group(indent(line), { id: groupId }),
245
209
  lineSuffixBoundary,
246
- (0, prettier_builder_1.indentIfBreak)(variableInitializer, { groupId: groupId })
210
+ indentIfBreak(variableInitializer, { groupId })
247
211
  ]);
248
212
  }
249
213
  // New Expression
250
214
  if (firstPrimary.children.primaryPrefix[0].children.newExpression !==
251
215
  undefined) {
252
- var groupId = Symbol("assignment");
253
- return (0, prettier_builder_1.group)([
254
- (0, prettier_builder_1.group)(variableDeclaratorId),
216
+ const groupId = Symbol("assignment");
217
+ return group([
218
+ group(variableDeclaratorId),
255
219
  " ",
256
220
  ctx.Equals[0],
257
- (0, prettier_builder_1.group)((0, prettier_builder_1.indent)(line), { id: groupId }),
221
+ group(indent(line), { id: groupId }),
258
222
  lineSuffixBoundary,
259
- (0, prettier_builder_1.indentIfBreak)(variableInitializer, { groupId: groupId })
223
+ indentIfBreak(variableInitializer, { groupId })
260
224
  ]);
261
225
  }
262
226
  // Method Invocation
263
- var isMethodInvocation = firstPrimary.children.primarySuffix !== undefined &&
227
+ const isMethodInvocation = firstPrimary.children.primarySuffix !== undefined &&
264
228
  firstPrimary.children.primarySuffix[0].children
265
229
  .methodInvocationSuffix !== undefined;
266
- var isUniqueUnaryExpression = ctx.variableInitializer[0].children.expression[0].children
230
+ const isUniqueUnaryExpression = ctx.variableInitializer[0].children.expression[0].children
267
231
  .ternaryExpression[0].children.binaryExpression[0].children
268
232
  .unaryExpression.length === 1;
269
- var isUniqueMethodInvocation = isMethodInvocation && isUniqueUnaryExpression;
233
+ const isUniqueMethodInvocation = isMethodInvocation && isUniqueUnaryExpression;
270
234
  if (isUniqueMethodInvocation) {
271
- var groupId = Symbol("assignment");
272
- return (0, prettier_builder_1.group)([
273
- (0, prettier_builder_1.group)(variableDeclaratorId),
235
+ const groupId = Symbol("assignment");
236
+ return group([
237
+ group(variableDeclaratorId),
274
238
  " ",
275
239
  ctx.Equals[0],
276
- (0, prettier_builder_1.group)((0, prettier_builder_1.indent)(line), { id: groupId }),
240
+ group(indent(line), { id: groupId }),
277
241
  lineSuffixBoundary,
278
- (0, prettier_builder_1.indentIfBreak)(variableInitializer, { groupId: groupId })
242
+ indentIfBreak(variableInitializer, { groupId })
279
243
  ]);
280
244
  }
281
245
  }
282
- return (0, prettier_builder_1.group)((0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndJoin)(line, [
283
- (0, printer_utils_1.rejectAndJoin)(" ", [variableDeclaratorId, ctx.Equals[0]]),
246
+ return group(indent(rejectAndJoin(line, [
247
+ rejectAndJoin(" ", [variableDeclaratorId, ctx.Equals[0]]),
284
248
  variableInitializer
285
249
  ])));
286
250
  }
287
251
  return variableDeclaratorId;
288
- };
289
- ClassesPrettierVisitor.prototype.variableDeclaratorId = function (ctx) {
290
- var identifier = ctx.Identifier[0];
291
- var dims = this.visit(ctx.dims);
292
- return (0, printer_utils_1.rejectAndConcat)([identifier, dims]);
293
- };
294
- ClassesPrettierVisitor.prototype.variableInitializer = function (ctx) {
252
+ }
253
+ variableDeclaratorId(ctx) {
254
+ if (ctx.Underscore) {
255
+ return printTokenWithComments(ctx.Underscore[0]);
256
+ }
257
+ const identifier = ctx.Identifier[0];
258
+ const dims = this.visit(ctx.dims);
259
+ return rejectAndConcat([identifier, dims]);
260
+ }
261
+ variableInitializer(ctx) {
295
262
  return this.visitSingle(ctx);
296
- };
297
- ClassesPrettierVisitor.prototype.unannType = function (ctx) {
263
+ }
264
+ unannType(ctx) {
298
265
  return this.visitSingle(ctx);
299
- };
300
- ClassesPrettierVisitor.prototype.unannPrimitiveTypeWithOptionalDimsSuffix = function (ctx) {
301
- var unannPrimitiveType = this.visit(ctx.unannPrimitiveType);
302
- var dims = this.visit(ctx.dims);
303
- return (0, printer_utils_1.rejectAndConcat)([unannPrimitiveType, dims]);
304
- };
305
- ClassesPrettierVisitor.prototype.unannPrimitiveType = function (ctx) {
266
+ }
267
+ unannPrimitiveTypeWithOptionalDimsSuffix(ctx) {
268
+ const unannPrimitiveType = this.visit(ctx.unannPrimitiveType);
269
+ const dims = this.visit(ctx.dims);
270
+ return rejectAndConcat([unannPrimitiveType, dims]);
271
+ }
272
+ unannPrimitiveType(ctx) {
306
273
  if (ctx.numericType) {
307
274
  return this.visitSingle(ctx);
308
275
  }
309
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
310
- };
311
- ClassesPrettierVisitor.prototype.unannReferenceType = function (ctx) {
312
- var unannClassOrInterfaceType = this.visit(ctx.unannClassOrInterfaceType);
313
- var dims = this.visit(ctx.dims);
314
- return (0, printer_utils_1.rejectAndConcat)([unannClassOrInterfaceType, dims]);
315
- };
316
- ClassesPrettierVisitor.prototype.unannClassOrInterfaceType = function (ctx) {
276
+ return printTokenWithComments(this.getSingle(ctx));
277
+ }
278
+ unannReferenceType(ctx) {
279
+ const unannClassOrInterfaceType = this.visit(ctx.unannClassOrInterfaceType);
280
+ const dims = this.visit(ctx.dims);
281
+ return rejectAndConcat([unannClassOrInterfaceType, dims]);
282
+ }
283
+ unannClassOrInterfaceType(ctx) {
317
284
  return this.visit(ctx.unannClassType);
318
- };
319
- ClassesPrettierVisitor.prototype.unannClassType = function (ctx) {
320
- var _this = this;
321
- var tokens = (0, printer_utils_1.sortClassTypeChildren)(ctx.annotation, ctx.typeArguments, ctx.Identifier);
322
- var segments = [];
323
- var currentSegment = [];
324
- (0, forEach_1.default)(tokens, function (token, i) {
325
- if ((0, utils_1.isTypeArgumentsCstNode)(token)) {
326
- currentSegment.push(_this.visit([token]));
327
- segments.push((0, printer_utils_1.rejectAndConcat)(currentSegment));
285
+ }
286
+ unannClassType(ctx) {
287
+ const tokens = sortClassTypeChildren(ctx.annotation, ctx.typeArguments, ctx.Identifier);
288
+ const segments = [];
289
+ let currentSegment = [];
290
+ forEach(tokens, (token, i) => {
291
+ if (isTypeArgumentsCstNode(token)) {
292
+ currentSegment.push(this.visit([token]));
293
+ segments.push(rejectAndConcat(currentSegment));
328
294
  currentSegment = [];
329
295
  }
330
- else if ((0, utils_1.isAnnotationCstNode)(token)) {
331
- currentSegment.push(_this.visit([token]));
296
+ else if (isAnnotationCstNode(token)) {
297
+ currentSegment.push(this.visit([token]));
332
298
  currentSegment.push(" ");
333
299
  }
334
300
  else {
335
301
  currentSegment.push(token);
336
- if ((i + 1 < tokens.length && !(0, utils_1.isTypeArgumentsCstNode)(tokens[i + 1])) ||
302
+ if ((i + 1 < tokens.length && !isTypeArgumentsCstNode(tokens[i + 1])) ||
337
303
  i + 1 === tokens.length) {
338
- segments.push((0, printer_utils_1.rejectAndConcat)(currentSegment));
304
+ segments.push(rejectAndConcat(currentSegment));
339
305
  currentSegment = [];
340
306
  }
341
307
  }
342
308
  });
343
- return (0, printer_utils_1.rejectAndJoinSeps)(ctx.Dot, segments);
344
- };
345
- ClassesPrettierVisitor.prototype.unannInterfaceType = function (ctx) {
309
+ return rejectAndJoinSeps(ctx.Dot, segments);
310
+ }
311
+ unannInterfaceType(ctx) {
346
312
  return this.visit(ctx.unannClassType);
347
- };
348
- ClassesPrettierVisitor.prototype.unannTypeVariable = function (ctx) {
349
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
350
- };
351
- ClassesPrettierVisitor.prototype.methodDeclaration = function (ctx) {
352
- var modifiers = (0, printer_utils_1.sortModifiers)(ctx.methodModifier);
353
- var firstAnnotations = this.mapVisit(modifiers[0]);
354
- var otherModifiers = this.mapVisit(modifiers[1]);
355
- var header = this.visit(ctx.methodHeader);
356
- var body = this.visit(ctx.methodBody);
357
- var headerBodySeparator = (0, printer_utils_1.isStatementEmptyStatement)(body) ? "" : " ";
358
- return (0, printer_utils_1.rejectAndJoin)(hardline, [
359
- (0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
360
- (0, printer_utils_1.rejectAndJoin)(" ", [
361
- (0, printer_utils_1.rejectAndJoin)(" ", otherModifiers),
362
- (0, printer_utils_1.rejectAndJoin)(headerBodySeparator, [header, body])
313
+ }
314
+ unannTypeVariable(ctx) {
315
+ return printTokenWithComments(this.getSingle(ctx));
316
+ }
317
+ methodDeclaration(ctx) {
318
+ const modifiers = sortModifiers(ctx.methodModifier);
319
+ const firstAnnotations = this.mapVisit(modifiers[0]);
320
+ const otherModifiers = this.mapVisit(modifiers[1]);
321
+ const header = this.visit(ctx.methodHeader);
322
+ const body = this.visit(ctx.methodBody);
323
+ const headerBodySeparator = isStatementEmptyStatement(body) ? "" : " ";
324
+ return rejectAndJoin(hardline, [
325
+ rejectAndJoin(hardline, firstAnnotations),
326
+ rejectAndJoin(" ", [
327
+ rejectAndJoin(" ", otherModifiers),
328
+ rejectAndJoin(headerBodySeparator, [header, body])
363
329
  ])
364
330
  ]);
365
- };
366
- ClassesPrettierVisitor.prototype.methodModifier = function (ctx) {
331
+ }
332
+ methodModifier(ctx) {
367
333
  if (ctx.annotation) {
368
334
  return this.visit(ctx.annotation);
369
335
  }
370
336
  // public | protected | private | Synchronized | ...
371
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
372
- };
373
- ClassesPrettierVisitor.prototype.methodHeader = function (ctx) {
374
- var typeParameters = this.visit(ctx.typeParameters);
375
- var annotations = this.mapVisit(ctx.annotation);
376
- var result = this.visit(ctx.result);
377
- var declarator = this.visit(ctx.methodDeclarator);
378
- var throws = this.visit(ctx.throws);
379
- return (0, prettier_builder_1.group)((0, prettier_builder_1.concat)([
380
- (0, printer_utils_1.rejectAndJoin)(" ", [
337
+ return printTokenWithComments(this.getSingle(ctx));
338
+ }
339
+ methodHeader(ctx) {
340
+ const typeParameters = this.visit(ctx.typeParameters);
341
+ const annotations = this.mapVisit(ctx.annotation);
342
+ const result = this.visit(ctx.result);
343
+ const declarator = this.visit(ctx.methodDeclarator);
344
+ const throws = this.visit(ctx.throws);
345
+ return group(concat([
346
+ rejectAndJoin(" ", [
381
347
  typeParameters,
382
- (0, printer_utils_1.rejectAndJoin)(line, annotations),
348
+ rejectAndJoin(line, annotations),
383
349
  result,
384
350
  declarator,
385
351
  throws
386
352
  ])
387
353
  ]));
388
- };
389
- ClassesPrettierVisitor.prototype.result = function (ctx) {
354
+ }
355
+ result(ctx) {
390
356
  if (ctx.unannType) {
391
357
  return this.visit(ctx.unannType);
392
358
  }
393
359
  // void
394
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
395
- };
396
- ClassesPrettierVisitor.prototype.methodDeclarator = function (ctx) {
397
- var identifier = (0, format_comments_1.printTokenWithComments)(ctx.Identifier[0]);
398
- var formalParameterList = this.visit(ctx.formalParameterList);
399
- var dims = this.visit(ctx.dims);
400
- return (0, printer_utils_1.rejectAndConcat)([
360
+ return printTokenWithComments(this.getSingle(ctx));
361
+ }
362
+ methodDeclarator(ctx) {
363
+ var _a;
364
+ const identifier = printTokenWithComments(ctx.Identifier[0]);
365
+ const receiverParameter = this.visit(ctx.receiverParameter);
366
+ const formalParameterList = this.visit(ctx.formalParameterList);
367
+ const dims = this.visit(ctx.dims);
368
+ return rejectAndConcat([
401
369
  identifier,
402
- (0, printer_utils_1.putIntoBraces)(formalParameterList, softline, ctx.LBrace[0], ctx.RBrace[0]),
370
+ putIntoBraces(rejectAndJoin(line, [
371
+ rejectAndConcat([receiverParameter, (_a = ctx.Comma) === null || _a === void 0 ? void 0 : _a[0]]),
372
+ formalParameterList
373
+ ]), softline, ctx.LBrace[0], ctx.RBrace[0]),
403
374
  dims
404
375
  ]);
405
- };
406
- ClassesPrettierVisitor.prototype.receiverParameter = function (ctx) {
407
- var annotations = this.mapVisit(ctx.annotation);
408
- var unannType = this.visit(ctx.unannType);
409
- var identifier = ctx.Identifier
410
- ? (0, prettier_builder_1.concat)([ctx.Identifier[0], ctx.Dot[0]])
411
- : "";
412
- return (0, printer_utils_1.rejectAndJoin)("", [
413
- (0, printer_utils_1.rejectAndJoin)(" ", annotations),
376
+ }
377
+ receiverParameter(ctx) {
378
+ var _a, _b;
379
+ const annotations = this.mapVisit(ctx.annotation);
380
+ const unannType = this.visit(ctx.unannType);
381
+ return rejectAndJoin(" ", [
382
+ ...annotations,
414
383
  unannType,
415
- identifier,
416
- ctx.This[0]
384
+ rejectAndConcat([(_a = ctx.Identifier) === null || _a === void 0 ? void 0 : _a[0], (_b = ctx.Dot) === null || _b === void 0 ? void 0 : _b[0], ctx.This[0]])
417
385
  ]);
418
- };
419
- ClassesPrettierVisitor.prototype.formalParameterList = function (ctx) {
420
- var formalParameter = this.mapVisit(ctx.formalParameter);
421
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
422
- return (0, printer_utils_1.rejectAndJoinSeps)(commas, formalParameter);
423
- };
424
- ClassesPrettierVisitor.prototype.formalParameter = function (ctx) {
386
+ }
387
+ formalParameterList(ctx) {
388
+ const formalParameter = this.mapVisit(ctx.formalParameter);
389
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
390
+ return rejectAndJoinSeps(commas, formalParameter);
391
+ }
392
+ formalParameter(ctx) {
425
393
  return this.visitSingle(ctx);
426
- };
427
- ClassesPrettierVisitor.prototype.variableParaRegularParameter = function (ctx) {
428
- var variableModifier = this.mapVisit(ctx.variableModifier);
429
- var unannType = this.visit(ctx.unannType);
430
- var variableDeclaratorId = this.visit(ctx.variableDeclaratorId);
431
- return (0, printer_utils_1.rejectAndJoin)(" ", [
432
- (0, printer_utils_1.rejectAndJoin)(" ", variableModifier),
394
+ }
395
+ variableParaRegularParameter(ctx) {
396
+ const variableModifier = this.mapVisit(ctx.variableModifier);
397
+ const unannType = this.visit(ctx.unannType);
398
+ const variableDeclaratorId = this.visit(ctx.variableDeclaratorId);
399
+ return rejectAndJoin(" ", [
400
+ rejectAndJoin(" ", variableModifier),
433
401
  unannType,
434
402
  variableDeclaratorId
435
403
  ]);
436
- };
437
- ClassesPrettierVisitor.prototype.variableArityParameter = function (ctx) {
438
- var variableModifier = this.mapVisit(ctx.variableModifier);
439
- var unannType = this.visit(ctx.unannType);
440
- var annotations = this.mapVisit(ctx.annotation);
441
- var identifier = ctx.Identifier[0];
442
- var unannTypePrinted = ctx.annotation === undefined
443
- ? (0, prettier_builder_1.concat)([unannType, ctx.DotDotDot[0]])
404
+ }
405
+ variableArityParameter(ctx) {
406
+ const variableModifier = this.mapVisit(ctx.variableModifier);
407
+ const unannType = this.visit(ctx.unannType);
408
+ const annotations = this.mapVisit(ctx.annotation);
409
+ const identifier = ctx.Identifier[0];
410
+ const unannTypePrinted = ctx.annotation === undefined
411
+ ? concat([unannType, ctx.DotDotDot[0]])
444
412
  : unannType;
445
- var annotationsPrinted = ctx.annotation === undefined
413
+ const annotationsPrinted = ctx.annotation === undefined
446
414
  ? annotations
447
- : (0, prettier_builder_1.concat)([(0, printer_utils_1.rejectAndJoin)(" ", annotations), ctx.DotDotDot[0]]);
448
- return (0, printer_utils_1.rejectAndJoin)(" ", [
449
- (0, prettier_builder_1.join)(" ", variableModifier),
415
+ : concat([rejectAndJoin(" ", annotations), ctx.DotDotDot[0]]);
416
+ return rejectAndJoin(" ", [
417
+ join(" ", variableModifier),
450
418
  unannTypePrinted,
451
419
  annotationsPrinted,
452
420
  identifier
453
421
  ]);
454
- };
455
- ClassesPrettierVisitor.prototype.variableModifier = function (ctx) {
422
+ }
423
+ variableModifier(ctx) {
456
424
  if (ctx.annotation) {
457
425
  return this.visit(ctx.annotation);
458
426
  }
459
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
460
- };
461
- ClassesPrettierVisitor.prototype.throws = function (ctx) {
462
- var exceptionTypeList = this.visit(ctx.exceptionTypeList);
463
- var throwsDeclaration = (0, prettier_builder_1.join)(" ", [ctx.Throws[0], exceptionTypeList]);
464
- return (0, prettier_builder_1.group)((0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([softline, throwsDeclaration])));
465
- };
466
- ClassesPrettierVisitor.prototype.exceptionTypeList = function (ctx) {
467
- var exceptionTypes = this.mapVisit(ctx.exceptionType);
468
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, " "]); }) : [];
469
- return (0, printer_utils_1.rejectAndJoinSeps)(commas, exceptionTypes);
470
- };
471
- ClassesPrettierVisitor.prototype.exceptionType = function (ctx) {
427
+ return printTokenWithComments(this.getSingle(ctx));
428
+ }
429
+ throws(ctx) {
430
+ const exceptionTypeList = this.visit(ctx.exceptionTypeList);
431
+ const throwsDeclaration = join(" ", [ctx.Throws[0], exceptionTypeList]);
432
+ return group(indent(rejectAndConcat([softline, throwsDeclaration])));
433
+ }
434
+ exceptionTypeList(ctx) {
435
+ const exceptionTypes = this.mapVisit(ctx.exceptionType);
436
+ const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, " "])) : [];
437
+ return rejectAndJoinSeps(commas, exceptionTypes);
438
+ }
439
+ exceptionType(ctx) {
472
440
  return this.visitSingle(ctx);
473
- };
474
- ClassesPrettierVisitor.prototype.methodBody = function (ctx) {
441
+ }
442
+ methodBody(ctx) {
475
443
  if (ctx.block) {
476
444
  return this.visit(ctx.block);
477
445
  }
478
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
479
- };
480
- ClassesPrettierVisitor.prototype.instanceInitializer = function (ctx) {
446
+ return printTokenWithComments(this.getSingle(ctx));
447
+ }
448
+ instanceInitializer(ctx) {
481
449
  return this.visitSingle(ctx);
482
- };
483
- ClassesPrettierVisitor.prototype.staticInitializer = function (ctx) {
484
- var block = this.visit(ctx.block);
485
- return (0, prettier_builder_1.join)(" ", [ctx.Static[0], block]);
486
- };
487
- ClassesPrettierVisitor.prototype.constructorDeclaration = function (ctx) {
488
- var modifiers = (0, printer_utils_1.sortModifiers)(ctx.constructorModifier);
489
- var firstAnnotations = this.mapVisit(modifiers[0]);
490
- var otherModifiers = this.mapVisit(modifiers[1]);
491
- var constructorDeclarator = this.visit(ctx.constructorDeclarator);
492
- var throws = this.visit(ctx.throws);
493
- var constructorBody = this.visit(ctx.constructorBody);
494
- return (0, printer_utils_1.rejectAndJoin)(" ", [
495
- (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoin)(hardline, [
496
- (0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
497
- (0, printer_utils_1.rejectAndJoin)(" ", [
498
- (0, prettier_builder_1.join)(" ", otherModifiers),
450
+ }
451
+ staticInitializer(ctx) {
452
+ const block = this.visit(ctx.block);
453
+ return join(" ", [ctx.Static[0], block]);
454
+ }
455
+ constructorDeclaration(ctx) {
456
+ const modifiers = sortModifiers(ctx.constructorModifier);
457
+ const firstAnnotations = this.mapVisit(modifiers[0]);
458
+ const otherModifiers = this.mapVisit(modifiers[1]);
459
+ const constructorDeclarator = this.visit(ctx.constructorDeclarator);
460
+ const throws = this.visit(ctx.throws);
461
+ const constructorBody = this.visit(ctx.constructorBody);
462
+ return rejectAndJoin(" ", [
463
+ group(rejectAndJoin(hardline, [
464
+ rejectAndJoin(hardline, firstAnnotations),
465
+ rejectAndJoin(" ", [
466
+ join(" ", otherModifiers),
499
467
  constructorDeclarator,
500
468
  throws
501
469
  ])
502
470
  ])),
503
471
  constructorBody
504
472
  ]);
505
- };
506
- ClassesPrettierVisitor.prototype.constructorModifier = function (ctx) {
473
+ }
474
+ constructorModifier(ctx) {
507
475
  if (ctx.annotation) {
508
476
  return this.visit(ctx.annotation);
509
477
  }
510
478
  // public | protected | private | Synchronized | ...
511
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
512
- };
513
- ClassesPrettierVisitor.prototype.constructorDeclarator = function (ctx) {
514
- var typeParameters = this.visit(ctx.typeParameters);
515
- var simpleTypeName = this.visit(ctx.simpleTypeName);
516
- var receiverParameter = this.visit(ctx.receiverParameter);
517
- var formalParameterList = this.visit(ctx.formalParameterList);
518
- var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, " "]); }) : [];
519
- return (0, printer_utils_1.rejectAndJoin)(" ", [
479
+ return printTokenWithComments(this.getSingle(ctx));
480
+ }
481
+ constructorDeclarator(ctx) {
482
+ var _a;
483
+ const typeParameters = this.visit(ctx.typeParameters);
484
+ const simpleTypeName = this.visit(ctx.simpleTypeName);
485
+ const receiverParameter = this.visit(ctx.receiverParameter);
486
+ const formalParameterList = this.visit(ctx.formalParameterList);
487
+ return rejectAndJoin(" ", [
520
488
  typeParameters,
521
- (0, prettier_builder_1.concat)([
489
+ concat([
522
490
  simpleTypeName,
523
- (0, printer_utils_1.putIntoBraces)((0, printer_utils_1.rejectAndJoinSeps)(commas, [receiverParameter, formalParameterList]), softline, ctx.LBrace[0], ctx.RBrace[0])
491
+ putIntoBraces(rejectAndJoin(line, [
492
+ rejectAndConcat([receiverParameter, (_a = ctx.Comma) === null || _a === void 0 ? void 0 : _a[0]]),
493
+ formalParameterList
494
+ ]), softline, ctx.LBrace[0], ctx.RBrace[0])
524
495
  ])
525
496
  ]);
526
- };
527
- ClassesPrettierVisitor.prototype.simpleTypeName = function (ctx) {
528
- return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
529
- };
530
- ClassesPrettierVisitor.prototype.constructorBody = function (ctx) {
531
- var explicitConstructorInvocation = this.visit(ctx.explicitConstructorInvocation);
532
- var blockStatements = this.visit(ctx.blockStatements);
533
- return (0, printer_utils_1.putIntoBraces)((0, printer_utils_1.rejectAndJoin)(hardline, [explicitConstructorInvocation, blockStatements]), hardline, ctx.LCurly[0], ctx.RCurly[0]);
534
- };
535
- ClassesPrettierVisitor.prototype.explicitConstructorInvocation = function (ctx) {
497
+ }
498
+ simpleTypeName(ctx) {
499
+ return printTokenWithComments(this.getSingle(ctx));
500
+ }
501
+ constructorBody(ctx) {
502
+ const explicitConstructorInvocation = this.visit(ctx.explicitConstructorInvocation);
503
+ const blockStatements = this.visit(ctx.blockStatements);
504
+ return putIntoBraces(rejectAndJoin(hardline, [explicitConstructorInvocation, blockStatements]), hardline, ctx.LCurly[0], ctx.RCurly[0]);
505
+ }
506
+ explicitConstructorInvocation(ctx) {
536
507
  return this.visitSingle(ctx);
537
- };
538
- ClassesPrettierVisitor.prototype.unqualifiedExplicitConstructorInvocation = function (ctx) {
539
- var typeArguments = this.visit(ctx.typeArguments);
540
- var keyWord = ctx.This ? ctx.This[0] : ctx.Super[0];
541
- var argumentList = utils_2.printArgumentListWithBraces.call(this, ctx.argumentList, ctx.RBrace[0], ctx.LBrace[0]);
542
- return (0, printer_utils_1.rejectAndConcat)([
508
+ }
509
+ unqualifiedExplicitConstructorInvocation(ctx) {
510
+ const typeArguments = this.visit(ctx.typeArguments);
511
+ const keyWord = ctx.This ? ctx.This[0] : ctx.Super[0];
512
+ const argumentList = printArgumentListWithBraces.call(this, ctx.argumentList, ctx.RBrace[0], ctx.LBrace[0]);
513
+ return rejectAndConcat([
543
514
  typeArguments,
544
515
  keyWord,
545
- (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([argumentList, ctx.Semicolon[0]]))
516
+ group(rejectAndConcat([argumentList, ctx.Semicolon[0]]))
546
517
  ]);
547
- };
548
- ClassesPrettierVisitor.prototype.qualifiedExplicitConstructorInvocation = function (ctx) {
549
- var expressionName = this.visit(ctx.expressionName);
550
- var typeArguments = this.visit(ctx.typeArguments);
551
- var argumentList = utils_2.printArgumentListWithBraces.call(this, ctx.argumentList, ctx.RBrace[0], ctx.LBrace[0]);
552
- return (0, printer_utils_1.rejectAndConcat)([
518
+ }
519
+ qualifiedExplicitConstructorInvocation(ctx) {
520
+ const expressionName = this.visit(ctx.expressionName);
521
+ const typeArguments = this.visit(ctx.typeArguments);
522
+ const argumentList = printArgumentListWithBraces.call(this, ctx.argumentList, ctx.RBrace[0], ctx.LBrace[0]);
523
+ return rejectAndConcat([
553
524
  expressionName,
554
525
  ctx.Dot[0],
555
526
  typeArguments,
556
527
  ctx.Super[0],
557
- (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([argumentList, ctx.Semicolon[0]]))
528
+ group(rejectAndConcat([argumentList, ctx.Semicolon[0]]))
558
529
  ]);
559
- };
560
- ClassesPrettierVisitor.prototype.enumDeclaration = function (ctx) {
561
- var classModifier = this.mapVisit(ctx.classModifier);
562
- var typeIdentifier = this.visit(ctx.typeIdentifier);
563
- var superinterfaces = this.visit(ctx.superinterfaces);
564
- var enumBody = this.visit(ctx.enumBody);
565
- return (0, printer_utils_1.rejectAndJoin)(" ", [
566
- (0, prettier_builder_1.join)(" ", classModifier),
530
+ }
531
+ enumDeclaration(ctx) {
532
+ const classModifier = this.mapVisit(ctx.classModifier);
533
+ const typeIdentifier = this.visit(ctx.typeIdentifier);
534
+ const superinterfaces = this.visit(ctx.superinterfaces);
535
+ const enumBody = this.visit(ctx.enumBody);
536
+ return rejectAndJoin(" ", [
537
+ join(" ", classModifier),
567
538
  ctx.Enum[0],
568
539
  typeIdentifier,
569
540
  superinterfaces,
570
541
  enumBody
571
542
  ]);
572
- };
573
- ClassesPrettierVisitor.prototype.enumBody = function (ctx) {
574
- var enumConstantList = this.visit(ctx.enumConstantList);
575
- var enumBodyDeclarations = this.visit(ctx.enumBodyDeclarations);
576
- var hasEnumConstants = ctx.enumConstantList !== undefined;
577
- var hasNoClassBodyDeclarations = ctx.enumBodyDeclarations === undefined ||
543
+ }
544
+ enumBody(ctx) {
545
+ const enumConstantList = this.visit(ctx.enumConstantList);
546
+ const enumBodyDeclarations = this.visit(ctx.enumBodyDeclarations);
547
+ const hasEnumConstants = ctx.enumConstantList !== undefined;
548
+ const hasNoClassBodyDeclarations = ctx.enumBodyDeclarations === undefined ||
578
549
  ctx.enumBodyDeclarations[0].children.classBodyDeclaration === undefined;
579
550
  // edge case: https://github.com/jhipster/prettier-java/issues/383
580
- var handleEnumBodyDeclarationsLeadingComments = !hasNoClassBodyDeclarations &&
581
- (0, comments_utils_1.hasLeadingComments)(ctx.enumBodyDeclarations[0])
551
+ const handleEnumBodyDeclarationsLeadingComments = !hasNoClassBodyDeclarations &&
552
+ hasLeadingComments(ctx.enumBodyDeclarations[0])
582
553
  ? hardline
583
554
  : "";
584
- var optionalComma;
555
+ let optionalComma;
585
556
  if (hasEnumConstants &&
586
557
  hasNoClassBodyDeclarations &&
587
558
  this.prettierOptions.trailingComma !== "none") {
588
559
  optionalComma = ctx.Comma ? ctx.Comma[0] : ",";
589
560
  }
590
561
  else {
591
- optionalComma = ctx.Comma ? __assign(__assign({}, ctx.Comma[0]), { image: "" }) : "";
562
+ optionalComma = ctx.Comma ? Object.assign(Object.assign({}, ctx.Comma[0]), { image: "" }) : "";
592
563
  }
593
- return (0, printer_utils_1.putIntoBraces)((0, printer_utils_1.rejectAndConcat)([
564
+ return putIntoBraces(rejectAndConcat([
594
565
  enumConstantList,
595
566
  optionalComma,
596
567
  handleEnumBodyDeclarationsLeadingComments,
597
568
  enumBodyDeclarations
598
569
  ]), hardline, ctx.LCurly[0], ctx.RCurly[0]);
599
- };
600
- ClassesPrettierVisitor.prototype.enumConstantList = function (ctx) {
601
- var enumConstants = this.mapVisit(ctx.enumConstant);
602
- var blankLineSeparators = (0, printer_utils_1.getBlankLinesSeparator)(ctx.enumConstant);
603
- var commas = ctx.Comma
604
- ? ctx.Comma.map(function (elt, index) {
605
- return (0, prettier_builder_1.concat)([elt, blankLineSeparators[index]]);
606
- })
570
+ }
571
+ enumConstantList(ctx) {
572
+ const enumConstants = this.mapVisit(ctx.enumConstant);
573
+ const blankLineSeparators = getBlankLinesSeparator(ctx.enumConstant);
574
+ const commas = ctx.Comma
575
+ ? ctx.Comma.map((elt, index) => concat([elt, blankLineSeparators[index]]))
607
576
  : [];
608
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoinSeps)(commas, enumConstants));
609
- };
610
- ClassesPrettierVisitor.prototype.enumConstant = function (ctx) {
611
- var modifiers = (0, printer_utils_1.sortModifiers)(ctx.enumConstantModifier);
612
- var firstAnnotations = this.mapVisit(modifiers[0]);
613
- var otherModifiers = this.mapVisit(modifiers[1]);
614
- var identifier = ctx.Identifier[0];
615
- var classBody = this.visit(ctx.classBody);
616
- var optionalBracesAndArgumentList = ctx.LBrace
617
- ? utils_2.printArgumentListWithBraces.call(this, ctx.argumentList, ctx.RBrace[0], ctx.LBrace[0])
577
+ return group(rejectAndJoinSeps(commas, enumConstants));
578
+ }
579
+ enumConstant(ctx) {
580
+ const modifiers = sortModifiers(ctx.enumConstantModifier);
581
+ const firstAnnotations = this.mapVisit(modifiers[0]);
582
+ const otherModifiers = this.mapVisit(modifiers[1]);
583
+ const identifier = ctx.Identifier[0];
584
+ const classBody = this.visit(ctx.classBody);
585
+ const optionalBracesAndArgumentList = ctx.LBrace
586
+ ? printArgumentListWithBraces.call(this, ctx.argumentList, ctx.RBrace[0], ctx.LBrace[0])
618
587
  : "";
619
- return (0, printer_utils_1.rejectAndJoin)(hardline, [
620
- (0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
621
- (0, printer_utils_1.rejectAndJoin)(" ", [
622
- (0, printer_utils_1.rejectAndJoin)(" ", otherModifiers),
623
- (0, printer_utils_1.rejectAndConcat)([identifier, optionalBracesAndArgumentList]),
588
+ return rejectAndJoin(hardline, [
589
+ rejectAndJoin(hardline, firstAnnotations),
590
+ rejectAndJoin(" ", [
591
+ rejectAndJoin(" ", otherModifiers),
592
+ rejectAndConcat([identifier, optionalBracesAndArgumentList]),
624
593
  classBody
625
594
  ])
626
595
  ]);
627
- };
628
- ClassesPrettierVisitor.prototype.enumConstantModifier = function (ctx) {
596
+ }
597
+ enumConstantModifier(ctx) {
629
598
  return this.visitSingle(ctx);
630
- };
631
- ClassesPrettierVisitor.prototype.enumBodyDeclarations = function (ctx) {
599
+ }
600
+ enumBodyDeclarations(ctx) {
632
601
  if (ctx.classBodyDeclaration !== undefined) {
633
- var classBodyDeclaration = this.mapVisit(ctx.classBodyDeclaration);
634
- var separators = (0, printer_utils_1.getClassBodyDeclarationsSeparator)(ctx.classBodyDeclaration);
635
- return (0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), [
602
+ const classBodyDeclaration = this.mapVisit(ctx.classBodyDeclaration);
603
+ const separators = getClassBodyDeclarationsSeparator(ctx.classBodyDeclaration);
604
+ return rejectAndJoin(concat([hardline, hardline]), [
636
605
  ctx.Semicolon[0],
637
- (0, printer_utils_1.rejectAndJoinSeps)(separators, classBodyDeclaration)
606
+ rejectAndJoinSeps(separators, classBodyDeclaration)
638
607
  ]);
639
608
  }
640
- return (0, format_comments_1.printTokenWithComments)(__assign(__assign({}, ctx.Semicolon[0]), { image: "" }));
641
- };
642
- ClassesPrettierVisitor.prototype.recordDeclaration = function (ctx) {
643
- var name = this.visit(ctx.typeIdentifier);
644
- var optionalTypeParams = this.visit(ctx.typeParameters);
645
- var recordHeader = this.visit(ctx.recordHeader);
646
- var superInterfacesPart = "";
647
- var optionalSuperInterfaces = this.visit(ctx.superinterfaces);
609
+ return printTokenWithComments(Object.assign(Object.assign({}, ctx.Semicolon[0]), { image: "" }));
610
+ }
611
+ recordDeclaration(ctx) {
612
+ const name = this.visit(ctx.typeIdentifier);
613
+ const optionalTypeParams = this.visit(ctx.typeParameters);
614
+ const recordHeader = this.visit(ctx.recordHeader);
615
+ let superInterfacesPart = "";
616
+ const optionalSuperInterfaces = this.visit(ctx.superinterfaces);
648
617
  if (optionalSuperInterfaces) {
649
- superInterfacesPart = (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, optionalSuperInterfaces]));
618
+ superInterfacesPart = indent(rejectAndConcat([line, optionalSuperInterfaces]));
650
619
  }
651
- var body = this.visit(ctx.recordBody);
652
- return (0, printer_utils_1.rejectAndJoin)(" ", [
653
- (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([
654
- (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Record[0], name]),
620
+ const body = this.visit(ctx.recordBody);
621
+ return rejectAndJoin(" ", [
622
+ group(rejectAndConcat([
623
+ rejectAndJoin(" ", [ctx.Record[0], name]),
655
624
  optionalTypeParams,
656
625
  recordHeader,
657
626
  superInterfacesPart
658
627
  ])),
659
628
  body
660
629
  ]);
661
- };
662
- ClassesPrettierVisitor.prototype.recordHeader = function (ctx) {
663
- var recordComponentList = this.visit(ctx.recordComponentList);
664
- return (0, printer_utils_1.putIntoBraces)(recordComponentList, softline, ctx.LBrace[0], ctx.RBrace[0]);
665
- };
666
- ClassesPrettierVisitor.prototype.recordComponentList = function (ctx) {
667
- var recordComponents = this.mapVisit(ctx.recordComponent);
668
- var blankLineSeparators = (0, printer_utils_1.getBlankLinesSeparator)(ctx.recordComponent, line);
669
- var commas = ctx.Comma
670
- ? ctx.Comma.map(function (elt, index) {
671
- return (0, prettier_builder_1.concat)([elt, blankLineSeparators[index]]);
672
- })
630
+ }
631
+ recordHeader(ctx) {
632
+ const recordComponentList = this.visit(ctx.recordComponentList);
633
+ return putIntoBraces(recordComponentList, softline, ctx.LBrace[0], ctx.RBrace[0]);
634
+ }
635
+ recordComponentList(ctx) {
636
+ const recordComponents = this.mapVisit(ctx.recordComponent);
637
+ const blankLineSeparators = getBlankLinesSeparator(ctx.recordComponent, line);
638
+ const commas = ctx.Comma
639
+ ? ctx.Comma.map((elt, index) => concat([elt, blankLineSeparators[index]]))
673
640
  : [];
674
- return (0, printer_utils_1.rejectAndJoinSeps)(commas, recordComponents);
675
- };
676
- ClassesPrettierVisitor.prototype.recordComponent = function (ctx) {
677
- var modifiers = this.mapVisit(ctx.recordComponentModifier);
678
- var unannType = this.visit(ctx.unannType);
641
+ return rejectAndJoinSeps(commas, recordComponents);
642
+ }
643
+ recordComponent(ctx) {
644
+ const modifiers = this.mapVisit(ctx.recordComponentModifier);
645
+ const unannType = this.visit(ctx.unannType);
679
646
  if (ctx.Identifier !== undefined) {
680
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoin)(line, [
681
- (0, prettier_builder_1.join)(line, modifiers),
682
- (0, prettier_builder_1.join)(" ", [unannType, ctx.Identifier[0]])
647
+ return group(rejectAndJoin(line, [
648
+ join(line, modifiers),
649
+ join(" ", [unannType, ctx.Identifier[0]])
683
650
  ]));
684
651
  }
685
- var variableArityRecordComponent = this.visit(ctx.variableArityRecordComponent);
652
+ const variableArityRecordComponent = this.visit(ctx.variableArityRecordComponent);
686
653
  if (ctx.variableArityRecordComponent[0].children.annotation !== undefined) {
687
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoin)(line, [
688
- (0, prettier_builder_1.join)(line, modifiers),
689
- (0, prettier_builder_1.join)(" ", [unannType, variableArityRecordComponent])
654
+ return group(rejectAndJoin(line, [
655
+ join(line, modifiers),
656
+ join(" ", [unannType, variableArityRecordComponent])
690
657
  ]));
691
658
  }
692
- return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoin)(line, [
693
- (0, prettier_builder_1.join)(line, modifiers),
694
- (0, prettier_builder_1.concat)([unannType, variableArityRecordComponent])
659
+ return group(rejectAndJoin(line, [
660
+ join(line, modifiers),
661
+ concat([unannType, variableArityRecordComponent])
695
662
  ]));
696
- };
697
- ClassesPrettierVisitor.prototype.variableArityRecordComponent = function (ctx) {
698
- var annotations = this.mapVisit(ctx.annotation);
699
- var identifier = ctx.Identifier[0];
700
- return (0, printer_utils_1.rejectAndJoin)(" ", [
701
- (0, printer_utils_1.rejectAndConcat)([(0, printer_utils_1.rejectAndJoin)(" ", annotations), ctx.DotDotDot[0]]),
663
+ }
664
+ variableArityRecordComponent(ctx) {
665
+ const annotations = this.mapVisit(ctx.annotation);
666
+ const identifier = ctx.Identifier[0];
667
+ return rejectAndJoin(" ", [
668
+ rejectAndConcat([rejectAndJoin(" ", annotations), ctx.DotDotDot[0]]),
702
669
  identifier
703
670
  ]);
704
- };
705
- ClassesPrettierVisitor.prototype.recordComponentModifier = function (ctx) {
671
+ }
672
+ recordComponentModifier(ctx) {
706
673
  return this.visitSingle(ctx);
707
- };
708
- ClassesPrettierVisitor.prototype.recordBody = function (ctx) {
709
- return (0, printer_utils_1.putIntoBraces)((0, printer_utils_1.rejectAndJoinSeps)((0, printer_utils_1.getBlankLinesSeparator)(ctx.recordBodyDeclaration), this.mapVisit(ctx.recordBodyDeclaration)), hardline, ctx.LCurly[0], ctx.RCurly[0]);
710
- };
711
- ClassesPrettierVisitor.prototype.recordBodyDeclaration = function (ctx) {
674
+ }
675
+ recordBody(ctx) {
676
+ return putIntoBraces(rejectAndJoinSeps(getBlankLinesSeparator(ctx.recordBodyDeclaration), this.mapVisit(ctx.recordBodyDeclaration)), hardline, ctx.LCurly[0], ctx.RCurly[0]);
677
+ }
678
+ recordBodyDeclaration(ctx) {
712
679
  return this.visitSingle(ctx);
713
- };
714
- ClassesPrettierVisitor.prototype.compactConstructorDeclaration = function (ctx) {
715
- var modifiers = (0, printer_utils_1.sortModifiers)(ctx.constructorModifier);
716
- var firstAnnotations = this.mapVisit(modifiers[0]);
717
- var otherModifiers = this.mapVisit(modifiers[1]);
718
- var name = this.visit(ctx.simpleTypeName);
719
- var constructorBody = this.visit(ctx.constructorBody);
720
- return (0, printer_utils_1.rejectAndJoin)(" ", [
721
- (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoin)(hardline, [
722
- (0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
723
- (0, printer_utils_1.rejectAndJoin)(" ", [(0, prettier_builder_1.join)(" ", otherModifiers), name])
680
+ }
681
+ compactConstructorDeclaration(ctx) {
682
+ const modifiers = sortModifiers(ctx.constructorModifier);
683
+ const firstAnnotations = this.mapVisit(modifiers[0]);
684
+ const otherModifiers = this.mapVisit(modifiers[1]);
685
+ const name = this.visit(ctx.simpleTypeName);
686
+ const constructorBody = this.visit(ctx.constructorBody);
687
+ return rejectAndJoin(" ", [
688
+ group(rejectAndJoin(hardline, [
689
+ rejectAndJoin(hardline, firstAnnotations),
690
+ rejectAndJoin(" ", [join(" ", otherModifiers), name])
724
691
  ])),
725
692
  constructorBody
726
693
  ]);
727
- };
728
- ClassesPrettierVisitor.prototype.isClassDeclaration = function () {
729
- return "isClassDeclaration";
730
- };
731
- ClassesPrettierVisitor.prototype.identifyClassBodyDeclarationType = function () {
732
- return "identifyClassBodyDeclarationType";
733
- };
734
- ClassesPrettierVisitor.prototype.isDims = function () {
694
+ }
695
+ isDims() {
735
696
  return "isDims";
736
- };
737
- ClassesPrettierVisitor.prototype.isCompactConstructorDeclaration = function () {
738
- return "isCompactConstructorDeclaration";
739
- };
740
- return ClassesPrettierVisitor;
741
- }(base_cst_printer_1.BaseCstPrettierPrinter));
742
- exports.ClassesPrettierVisitor = ClassesPrettierVisitor;
697
+ }
698
+ }