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