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
|
@@ -28,15 +28,15 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
28
28
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
29
29
|
}
|
|
30
30
|
InterfacesPrettierVisitor.prototype.interfaceDeclaration = function (ctx) {
|
|
31
|
-
var modifiers = printer_utils_1.sortModifiers(ctx.interfaceModifier);
|
|
31
|
+
var modifiers = (0, printer_utils_1.sortModifiers)(ctx.interfaceModifier);
|
|
32
32
|
var firstAnnotations = this.mapVisit(modifiers[0]);
|
|
33
33
|
var otherModifiers = this.mapVisit(modifiers[1]);
|
|
34
34
|
var declaration = ctx.normalInterfaceDeclaration
|
|
35
35
|
? this.visit(ctx.normalInterfaceDeclaration)
|
|
36
36
|
: this.visit(ctx.annotationTypeDeclaration);
|
|
37
|
-
return printer_utils_1.rejectAndJoin(hardline, [
|
|
38
|
-
printer_utils_1.rejectAndJoin(hardline, firstAnnotations),
|
|
39
|
-
printer_utils_1.rejectAndJoin(" ", [printer_utils_1.rejectAndJoin(" ", otherModifiers), declaration])
|
|
37
|
+
return (0, printer_utils_1.rejectAndJoin)(hardline, [
|
|
38
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
|
|
39
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [(0, printer_utils_1.rejectAndJoin)(" ", otherModifiers), declaration])
|
|
40
40
|
]);
|
|
41
41
|
};
|
|
42
42
|
InterfacesPrettierVisitor.prototype.normalInterfaceDeclaration = function (ctx) {
|
|
@@ -47,16 +47,16 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
47
47
|
var interfaceBody = this.visit(ctx.interfaceBody);
|
|
48
48
|
var extendsInterfacesPart = "";
|
|
49
49
|
if (extendsInterfaces) {
|
|
50
|
-
extendsInterfacesPart = prettier_builder_1.indent(printer_utils_1.rejectAndConcat([softline, extendsInterfaces]));
|
|
50
|
+
extendsInterfacesPart = (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([softline, extendsInterfaces]));
|
|
51
51
|
}
|
|
52
52
|
var interfacePermits = "";
|
|
53
53
|
if (optionalInterfacePermits) {
|
|
54
|
-
interfacePermits = prettier_builder_1.indent(printer_utils_1.rejectAndConcat([softline, optionalInterfacePermits]));
|
|
54
|
+
interfacePermits = (0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([softline, optionalInterfacePermits]));
|
|
55
55
|
}
|
|
56
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
57
|
-
prettier_builder_1.group(printer_utils_1.rejectAndJoin(" ", [
|
|
56
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
57
|
+
(0, prettier_builder_1.group)((0, printer_utils_1.rejectAndJoin)(" ", [
|
|
58
58
|
ctx.Interface[0],
|
|
59
|
-
prettier_builder_1.concat([typeIdentifier, typeParameters]),
|
|
59
|
+
(0, prettier_builder_1.concat)([typeIdentifier, typeParameters]),
|
|
60
60
|
extendsInterfacesPart,
|
|
61
61
|
interfacePermits
|
|
62
62
|
])),
|
|
@@ -67,13 +67,13 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
67
67
|
if (ctx.annotation) {
|
|
68
68
|
return this.visitSingle(ctx);
|
|
69
69
|
}
|
|
70
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
70
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
71
71
|
};
|
|
72
72
|
InterfacesPrettierVisitor.prototype.extendsInterfaces = function (ctx) {
|
|
73
73
|
var interfaceTypeList = this.visit(ctx.interfaceTypeList);
|
|
74
|
-
return prettier_builder_1.group(printer_utils_1.rejectAndConcat([
|
|
74
|
+
return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([
|
|
75
75
|
ctx.Extends[0],
|
|
76
|
-
prettier_builder_1.indent(printer_utils_1.rejectAndConcat([line, interfaceTypeList]))
|
|
76
|
+
(0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndConcat)([line, interfaceTypeList]))
|
|
77
77
|
]));
|
|
78
78
|
};
|
|
79
79
|
InterfacesPrettierVisitor.prototype.interfacePermits = function (ctx) {
|
|
@@ -83,29 +83,29 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
83
83
|
var joinedInterfaceMemberDeclaration = "";
|
|
84
84
|
if (ctx.interfaceMemberDeclaration !== undefined) {
|
|
85
85
|
var interfaceMemberDeclaration = this.mapVisit(ctx.interfaceMemberDeclaration);
|
|
86
|
-
var separators = printer_utils_1.getInterfaceBodyDeclarationsSeparator(ctx.interfaceMemberDeclaration);
|
|
87
|
-
joinedInterfaceMemberDeclaration = printer_utils_1.rejectAndJoinSeps(separators, interfaceMemberDeclaration);
|
|
86
|
+
var separators = (0, printer_utils_1.getInterfaceBodyDeclarationsSeparator)(ctx.interfaceMemberDeclaration);
|
|
87
|
+
joinedInterfaceMemberDeclaration = (0, printer_utils_1.rejectAndJoinSeps)(separators, interfaceMemberDeclaration);
|
|
88
88
|
}
|
|
89
|
-
return printer_utils_1.putIntoBraces(joinedInterfaceMemberDeclaration, hardline, ctx.LCurly[0], ctx.RCurly[0]);
|
|
89
|
+
return (0, printer_utils_1.putIntoBraces)(joinedInterfaceMemberDeclaration, hardline, ctx.LCurly[0], ctx.RCurly[0]);
|
|
90
90
|
};
|
|
91
91
|
InterfacesPrettierVisitor.prototype.interfaceMemberDeclaration = function (ctx) {
|
|
92
92
|
if (ctx.Semicolon) {
|
|
93
|
-
return printer_utils_1.displaySemicolon(ctx.Semicolon[0]);
|
|
93
|
+
return (0, printer_utils_1.displaySemicolon)(ctx.Semicolon[0]);
|
|
94
94
|
}
|
|
95
95
|
return this.visitSingle(ctx);
|
|
96
96
|
};
|
|
97
97
|
InterfacesPrettierVisitor.prototype.constantDeclaration = function (ctx) {
|
|
98
|
-
var modifiers = printer_utils_1.sortModifiers(ctx.constantModifier);
|
|
98
|
+
var modifiers = (0, printer_utils_1.sortModifiers)(ctx.constantModifier);
|
|
99
99
|
var firstAnnotations = this.mapVisit(modifiers[0]);
|
|
100
100
|
var otherModifiers = this.mapVisit(modifiers[1]);
|
|
101
101
|
var unannType = this.visit(ctx.unannType);
|
|
102
102
|
var variableDeclaratorList = this.visit(ctx.variableDeclaratorList);
|
|
103
|
-
return printer_utils_1.rejectAndJoin(hardline, [
|
|
104
|
-
printer_utils_1.rejectAndJoin(hardline, firstAnnotations),
|
|
105
|
-
printer_utils_1.rejectAndJoin(" ", [
|
|
106
|
-
printer_utils_1.rejectAndJoin(" ", otherModifiers),
|
|
103
|
+
return (0, printer_utils_1.rejectAndJoin)(hardline, [
|
|
104
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
|
|
105
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [
|
|
106
|
+
(0, printer_utils_1.rejectAndJoin)(" ", otherModifiers),
|
|
107
107
|
unannType,
|
|
108
|
-
printer_utils_1.rejectAndConcat([variableDeclaratorList, ctx.Semicolon[0]])
|
|
108
|
+
(0, printer_utils_1.rejectAndConcat)([variableDeclaratorList, ctx.Semicolon[0]])
|
|
109
109
|
])
|
|
110
110
|
]);
|
|
111
111
|
};
|
|
@@ -113,20 +113,20 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
113
113
|
if (ctx.annotation) {
|
|
114
114
|
return this.visitSingle(ctx);
|
|
115
115
|
}
|
|
116
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
116
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
117
117
|
};
|
|
118
118
|
InterfacesPrettierVisitor.prototype.interfaceMethodDeclaration = function (ctx) {
|
|
119
|
-
var modifiers = printer_utils_1.sortModifiers(ctx.interfaceMethodModifier);
|
|
119
|
+
var modifiers = (0, printer_utils_1.sortModifiers)(ctx.interfaceMethodModifier);
|
|
120
120
|
var firstAnnotations = this.mapVisit(modifiers[0]);
|
|
121
121
|
var otherModifiers = this.mapVisit(modifiers[1]);
|
|
122
122
|
var methodHeader = this.visit(ctx.methodHeader);
|
|
123
123
|
var methodBody = this.visit(ctx.methodBody);
|
|
124
|
-
var separator = printer_utils_1.isStatementEmptyStatement(methodBody) ? "" : " ";
|
|
125
|
-
return printer_utils_1.rejectAndJoin(hardline, [
|
|
126
|
-
printer_utils_1.rejectAndJoin(hardline, firstAnnotations),
|
|
127
|
-
printer_utils_1.rejectAndJoin(" ", [
|
|
128
|
-
printer_utils_1.rejectAndJoin(" ", otherModifiers),
|
|
129
|
-
printer_utils_1.rejectAndJoin(separator, [methodHeader, methodBody])
|
|
124
|
+
var separator = (0, printer_utils_1.isStatementEmptyStatement)(methodBody) ? "" : " ";
|
|
125
|
+
return (0, printer_utils_1.rejectAndJoin)(hardline, [
|
|
126
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
|
|
127
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [
|
|
128
|
+
(0, printer_utils_1.rejectAndJoin)(" ", otherModifiers),
|
|
129
|
+
(0, printer_utils_1.rejectAndJoin)(separator, [methodHeader, methodBody])
|
|
130
130
|
])
|
|
131
131
|
]);
|
|
132
132
|
};
|
|
@@ -134,51 +134,51 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
134
134
|
if (ctx.annotation) {
|
|
135
135
|
return this.visitSingle(ctx);
|
|
136
136
|
}
|
|
137
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
137
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
138
138
|
};
|
|
139
139
|
InterfacesPrettierVisitor.prototype.annotationTypeDeclaration = function (ctx) {
|
|
140
140
|
var typeIdentifier = this.visit(ctx.typeIdentifier);
|
|
141
141
|
var annotationTypeBody = this.visit(ctx.annotationTypeBody);
|
|
142
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
143
|
-
prettier_builder_1.concat([ctx.At[0], ctx.Interface[0]]),
|
|
142
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
143
|
+
(0, prettier_builder_1.concat)([ctx.At[0], ctx.Interface[0]]),
|
|
144
144
|
typeIdentifier,
|
|
145
145
|
annotationTypeBody
|
|
146
146
|
]);
|
|
147
147
|
};
|
|
148
148
|
InterfacesPrettierVisitor.prototype.annotationTypeBody = function (ctx) {
|
|
149
149
|
var annotationTypeMemberDeclaration = this.mapVisit(ctx.annotationTypeMemberDeclaration);
|
|
150
|
-
return printer_utils_1.rejectAndJoin(line, [
|
|
151
|
-
prettier_builder_1.indent(printer_utils_1.rejectAndJoin(line, [
|
|
150
|
+
return (0, printer_utils_1.rejectAndJoin)(line, [
|
|
151
|
+
(0, prettier_builder_1.indent)((0, printer_utils_1.rejectAndJoin)(line, [
|
|
152
152
|
ctx.LCurly[0],
|
|
153
|
-
printer_utils_1.rejectAndJoin(prettier_builder_1.concat([line, line]), annotationTypeMemberDeclaration)
|
|
153
|
+
(0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([line, line]), annotationTypeMemberDeclaration)
|
|
154
154
|
])),
|
|
155
155
|
ctx.RCurly[0]
|
|
156
156
|
]);
|
|
157
157
|
};
|
|
158
158
|
InterfacesPrettierVisitor.prototype.annotationTypeMemberDeclaration = function (ctx) {
|
|
159
159
|
if (ctx.Semicolon) {
|
|
160
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
160
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
161
161
|
}
|
|
162
162
|
return this.visitSingle(ctx);
|
|
163
163
|
};
|
|
164
164
|
InterfacesPrettierVisitor.prototype.annotationTypeElementDeclaration = function (ctx) {
|
|
165
|
-
var modifiers = printer_utils_1.sortModifiers(ctx.annotationTypeElementModifier);
|
|
165
|
+
var modifiers = (0, printer_utils_1.sortModifiers)(ctx.annotationTypeElementModifier);
|
|
166
166
|
var firstAnnotations = this.mapVisit(modifiers[0]);
|
|
167
167
|
var otherModifiers = this.mapVisit(modifiers[1]);
|
|
168
168
|
var unannType = this.visit(ctx.unannType);
|
|
169
169
|
var identifier = ctx.Identifier[0];
|
|
170
170
|
var dims = this.visit(ctx.dims);
|
|
171
171
|
var defaultValue = ctx.defaultValue
|
|
172
|
-
? prettier_builder_1.concat([" ", this.visit(ctx.defaultValue)])
|
|
172
|
+
? (0, prettier_builder_1.concat)([" ", this.visit(ctx.defaultValue)])
|
|
173
173
|
: "";
|
|
174
|
-
return printer_utils_1.rejectAndJoin(hardline, [
|
|
175
|
-
printer_utils_1.rejectAndJoin(hardline, firstAnnotations),
|
|
176
|
-
printer_utils_1.rejectAndJoin(" ", [
|
|
177
|
-
printer_utils_1.rejectAndJoin(" ", otherModifiers),
|
|
174
|
+
return (0, printer_utils_1.rejectAndJoin)(hardline, [
|
|
175
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, firstAnnotations),
|
|
176
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [
|
|
177
|
+
(0, printer_utils_1.rejectAndJoin)(" ", otherModifiers),
|
|
178
178
|
unannType,
|
|
179
|
-
printer_utils_1.rejectAndConcat([
|
|
179
|
+
(0, printer_utils_1.rejectAndConcat)([
|
|
180
180
|
identifier,
|
|
181
|
-
prettier_builder_1.concat([ctx.LBrace[0], ctx.RBrace[0]]),
|
|
181
|
+
(0, prettier_builder_1.concat)([ctx.LBrace[0], ctx.RBrace[0]]),
|
|
182
182
|
dims,
|
|
183
183
|
defaultValue,
|
|
184
184
|
ctx.Semicolon[0]
|
|
@@ -190,41 +190,41 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
190
190
|
if (ctx.annotation) {
|
|
191
191
|
return this.visitSingle(ctx);
|
|
192
192
|
}
|
|
193
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
193
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
194
194
|
};
|
|
195
195
|
InterfacesPrettierVisitor.prototype.defaultValue = function (ctx) {
|
|
196
196
|
var elementValue = this.visit(ctx.elementValue);
|
|
197
|
-
return printer_utils_1.rejectAndJoin(" ", [ctx.Default[0], elementValue]);
|
|
197
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [ctx.Default[0], elementValue]);
|
|
198
198
|
};
|
|
199
199
|
InterfacesPrettierVisitor.prototype.annotation = function (ctx) {
|
|
200
200
|
var fqn = this.visit(ctx.typeName);
|
|
201
201
|
var annoArgs = "";
|
|
202
202
|
if (ctx.LBrace) {
|
|
203
203
|
if (ctx.elementValuePairList) {
|
|
204
|
-
annoArgs = printer_utils_1.putIntoBraces(this.visit(ctx.elementValuePairList), softline, ctx.LBrace[0], ctx.RBrace[0]);
|
|
204
|
+
annoArgs = (0, printer_utils_1.putIntoBraces)(this.visit(ctx.elementValuePairList), softline, ctx.LBrace[0], ctx.RBrace[0]);
|
|
205
205
|
}
|
|
206
206
|
else if (ctx.elementValue) {
|
|
207
|
-
annoArgs = printer_utils_1.putIntoBraces(this.visit(ctx.elementValue), softline, ctx.LBrace[0], ctx.RBrace[0]);
|
|
207
|
+
annoArgs = (0, printer_utils_1.putIntoBraces)(this.visit(ctx.elementValue), softline, ctx.LBrace[0], ctx.RBrace[0]);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
return prettier_builder_1.group(printer_utils_1.rejectAndConcat([ctx.At[0], fqn, annoArgs]));
|
|
210
|
+
return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([ctx.At[0], fqn, annoArgs]));
|
|
211
211
|
};
|
|
212
212
|
InterfacesPrettierVisitor.prototype.elementValuePairList = function (ctx) {
|
|
213
213
|
var elementValuePairs = this.mapVisit(ctx.elementValuePair);
|
|
214
|
-
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return prettier_builder_1.concat([elt, line]); }) : [];
|
|
215
|
-
return printer_utils_1.rejectAndJoinSeps(commas, elementValuePairs);
|
|
214
|
+
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
|
|
215
|
+
return (0, printer_utils_1.rejectAndJoinSeps)(commas, elementValuePairs);
|
|
216
216
|
};
|
|
217
217
|
InterfacesPrettierVisitor.prototype.elementValuePair = function (ctx) {
|
|
218
218
|
var identifier = ctx.Identifier[0];
|
|
219
219
|
var elementValue = this.visit(ctx.elementValue);
|
|
220
|
-
return printer_utils_1.rejectAndJoin(" ", [identifier, ctx.Equals[0], elementValue]);
|
|
220
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [identifier, ctx.Equals[0], elementValue]);
|
|
221
221
|
};
|
|
222
222
|
InterfacesPrettierVisitor.prototype.elementValue = function (ctx) {
|
|
223
223
|
return this.visitSingle(ctx);
|
|
224
224
|
};
|
|
225
225
|
InterfacesPrettierVisitor.prototype.elementValueArrayInitializer = function (ctx) {
|
|
226
226
|
var elementValueList = this.visit(ctx.elementValueList);
|
|
227
|
-
return printer_utils_1.printArrayList({
|
|
227
|
+
return (0, printer_utils_1.printArrayList)({
|
|
228
228
|
list: elementValueList,
|
|
229
229
|
extraComma: ctx.Comma,
|
|
230
230
|
LCurly: ctx.LCurly[0],
|
|
@@ -234,8 +234,8 @@ var InterfacesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
234
234
|
};
|
|
235
235
|
InterfacesPrettierVisitor.prototype.elementValueList = function (ctx) {
|
|
236
236
|
var elementValues = this.mapVisit(ctx.elementValue);
|
|
237
|
-
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return prettier_builder_1.concat([elt, line]); }) : [];
|
|
238
|
-
return prettier_builder_1.group(printer_utils_1.rejectAndConcat([printer_utils_1.rejectAndJoinSeps(commas, elementValues)]));
|
|
237
|
+
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
|
|
238
|
+
return (0, prettier_builder_1.group)((0, printer_utils_1.rejectAndConcat)([(0, printer_utils_1.rejectAndJoinSeps)(commas, elementValues)]));
|
|
239
239
|
};
|
|
240
240
|
InterfacesPrettierVisitor.prototype.identifyInterfaceBodyDeclarationType = function () {
|
|
241
241
|
return "identifyInterfaceBodyDeclarationType";
|
|
@@ -25,18 +25,18 @@ var LexicalStructurePrettierVisitor = /** @class */ (function (_super) {
|
|
|
25
25
|
}
|
|
26
26
|
LexicalStructurePrettierVisitor.prototype.literal = function (ctx) {
|
|
27
27
|
if (ctx.CharLiteral || ctx.TextBlock || ctx.StringLiteral || ctx.Null) {
|
|
28
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
28
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
29
29
|
}
|
|
30
30
|
return this.visitSingle(ctx);
|
|
31
31
|
};
|
|
32
32
|
LexicalStructurePrettierVisitor.prototype.integerLiteral = function (ctx) {
|
|
33
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
33
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
34
34
|
};
|
|
35
35
|
LexicalStructurePrettierVisitor.prototype.floatingPointLiteral = function (ctx) {
|
|
36
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
36
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
37
37
|
};
|
|
38
38
|
LexicalStructurePrettierVisitor.prototype.booleanLiteral = function (ctx) {
|
|
39
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
39
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
40
40
|
};
|
|
41
41
|
return LexicalStructurePrettierVisitor;
|
|
42
42
|
}(base_cst_printer_1.BaseCstPrettierPrinter));
|
package/dist/printers/names.js
CHANGED
|
@@ -25,28 +25,28 @@ var NamesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
25
25
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
26
|
}
|
|
27
27
|
NamesPrettierVisitor.prototype.typeIdentifier = function (ctx) {
|
|
28
|
-
return format_comments_1.printTokenWithComments(ctx.Identifier[0]);
|
|
28
|
+
return (0, format_comments_1.printTokenWithComments)(ctx.Identifier[0]);
|
|
29
29
|
};
|
|
30
30
|
NamesPrettierVisitor.prototype.moduleName = function (ctx) {
|
|
31
|
-
return printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
31
|
+
return (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
32
32
|
};
|
|
33
33
|
NamesPrettierVisitor.prototype.packageName = function (ctx) {
|
|
34
|
-
return printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
34
|
+
return (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
35
35
|
};
|
|
36
36
|
NamesPrettierVisitor.prototype.typeName = function (ctx) {
|
|
37
|
-
return printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
37
|
+
return (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
38
38
|
};
|
|
39
39
|
NamesPrettierVisitor.prototype.expressionName = function (ctx) {
|
|
40
|
-
return printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
40
|
+
return (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
41
41
|
};
|
|
42
42
|
NamesPrettierVisitor.prototype.methodName = function (ctx) {
|
|
43
|
-
return format_comments_1.printTokenWithComments(ctx.Identifier[0]);
|
|
43
|
+
return (0, format_comments_1.printTokenWithComments)(ctx.Identifier[0]);
|
|
44
44
|
};
|
|
45
45
|
NamesPrettierVisitor.prototype.packageOrTypeName = function (ctx) {
|
|
46
|
-
return printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
46
|
+
return (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
47
47
|
};
|
|
48
48
|
NamesPrettierVisitor.prototype.ambiguousName = function (ctx) {
|
|
49
|
-
return printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
49
|
+
return (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
50
50
|
};
|
|
51
51
|
return NamesPrettierVisitor;
|
|
52
52
|
}(base_cst_printer_1.BaseCstPrettierPrinter));
|
|
@@ -29,46 +29,46 @@ var PackagesAndModulesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
29
29
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
30
30
|
}
|
|
31
31
|
PackagesAndModulesPrettierVisitor.prototype.compilationUnit = function (ctx) {
|
|
32
|
-
var compilationUnit = utils_1.isOrdinaryCompilationUnitCtx(ctx)
|
|
32
|
+
var compilationUnit = (0, utils_1.isOrdinaryCompilationUnitCtx)(ctx)
|
|
33
33
|
? ctx.ordinaryCompilationUnit
|
|
34
34
|
: ctx.modularCompilationUnit;
|
|
35
|
-
return prettier_builder_1.concat([this.visit(compilationUnit[0]), line]);
|
|
35
|
+
return (0, prettier_builder_1.concat)([this.visit(compilationUnit[0]), line]);
|
|
36
36
|
};
|
|
37
37
|
PackagesAndModulesPrettierVisitor.prototype.ordinaryCompilationUnit = function (ctx) {
|
|
38
38
|
var packageDecl = this.visit(ctx.packageDeclaration);
|
|
39
|
-
var sortedImportsDecl = printer_utils_1.sortImports(ctx.importDeclaration);
|
|
39
|
+
var sortedImportsDecl = (0, printer_utils_1.sortImports)(ctx.importDeclaration);
|
|
40
40
|
var nonStaticImports = this.mapVisit(sortedImportsDecl.nonStaticImports);
|
|
41
41
|
var staticImports = this.mapVisit(sortedImportsDecl.staticImports);
|
|
42
42
|
var typesDecl = this.mapVisit(ctx.typeDeclaration);
|
|
43
43
|
// TODO: utility to add item+line (or multiple lines) but only if an item exists
|
|
44
|
-
return printer_utils_1.rejectAndConcat([
|
|
45
|
-
printer_utils_1.rejectAndJoin(prettier_builder_1.concat([hardline, hardline]), [
|
|
44
|
+
return (0, printer_utils_1.rejectAndConcat)([
|
|
45
|
+
(0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), [
|
|
46
46
|
packageDecl,
|
|
47
|
-
printer_utils_1.rejectAndJoin(hardline, staticImports),
|
|
48
|
-
printer_utils_1.rejectAndJoin(hardline, nonStaticImports),
|
|
49
|
-
printer_utils_1.rejectAndJoin(prettier_builder_1.concat([hardline, hardline]), typesDecl)
|
|
47
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, staticImports),
|
|
48
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, nonStaticImports),
|
|
49
|
+
(0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), typesDecl)
|
|
50
50
|
])
|
|
51
51
|
]);
|
|
52
52
|
};
|
|
53
53
|
PackagesAndModulesPrettierVisitor.prototype.modularCompilationUnit = function (ctx) {
|
|
54
|
-
var sortedImportsDecl = printer_utils_1.sortImports(ctx.importDeclaration);
|
|
54
|
+
var sortedImportsDecl = (0, printer_utils_1.sortImports)(ctx.importDeclaration);
|
|
55
55
|
var nonStaticImports = this.mapVisit(sortedImportsDecl.nonStaticImports);
|
|
56
56
|
var staticImports = this.mapVisit(sortedImportsDecl.staticImports);
|
|
57
57
|
var moduleDeclaration = this.visit(ctx.moduleDeclaration);
|
|
58
|
-
return printer_utils_1.rejectAndConcat([
|
|
59
|
-
printer_utils_1.rejectAndJoin(prettier_builder_1.concat([hardline, hardline]), [
|
|
60
|
-
printer_utils_1.rejectAndJoin(hardline, staticImports),
|
|
61
|
-
printer_utils_1.rejectAndJoin(hardline, nonStaticImports),
|
|
58
|
+
return (0, printer_utils_1.rejectAndConcat)([
|
|
59
|
+
(0, printer_utils_1.rejectAndJoin)((0, prettier_builder_1.concat)([hardline, hardline]), [
|
|
60
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, staticImports),
|
|
61
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, nonStaticImports),
|
|
62
62
|
moduleDeclaration
|
|
63
63
|
])
|
|
64
64
|
]);
|
|
65
65
|
};
|
|
66
66
|
PackagesAndModulesPrettierVisitor.prototype.packageDeclaration = function (ctx) {
|
|
67
67
|
var modifiers = this.mapVisit(ctx.packageModifier);
|
|
68
|
-
var name = printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
69
|
-
return printer_utils_1.rejectAndJoin(hardline, [
|
|
70
|
-
printer_utils_1.rejectAndJoin(hardline, modifiers),
|
|
71
|
-
prettier_builder_1.concat([ctx.Package[0], " ", name, ctx.Semicolon[0]])
|
|
68
|
+
var name = (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
69
|
+
return (0, printer_utils_1.rejectAndJoin)(hardline, [
|
|
70
|
+
(0, printer_utils_1.rejectAndJoin)(hardline, modifiers),
|
|
71
|
+
(0, prettier_builder_1.concat)([ctx.Package[0], " ", name, ctx.Semicolon[0]])
|
|
72
72
|
]);
|
|
73
73
|
};
|
|
74
74
|
PackagesAndModulesPrettierVisitor.prototype.packageModifier = function (ctx) {
|
|
@@ -80,31 +80,31 @@ var PackagesAndModulesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
80
80
|
}
|
|
81
81
|
var optionalStatic = ctx.Static ? ctx.Static[0] : "";
|
|
82
82
|
var packageOrTypeName = this.visit(ctx.packageOrTypeName);
|
|
83
|
-
var optionalDotStar = ctx.Dot ? prettier_builder_1.concat([ctx.Dot[0], ctx.Star[0]]) : "";
|
|
84
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
83
|
+
var optionalDotStar = ctx.Dot ? (0, prettier_builder_1.concat)([ctx.Dot[0], ctx.Star[0]]) : "";
|
|
84
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
85
85
|
ctx.Import[0],
|
|
86
86
|
optionalStatic,
|
|
87
|
-
printer_utils_1.rejectAndConcat([packageOrTypeName, optionalDotStar, ctx.Semicolon[0]])
|
|
87
|
+
(0, printer_utils_1.rejectAndConcat)([packageOrTypeName, optionalDotStar, ctx.Semicolon[0]])
|
|
88
88
|
]);
|
|
89
89
|
};
|
|
90
90
|
PackagesAndModulesPrettierVisitor.prototype.typeDeclaration = function (ctx) {
|
|
91
91
|
if (ctx.Semicolon) {
|
|
92
|
-
return printer_utils_1.displaySemicolon(ctx.Semicolon[0]);
|
|
92
|
+
return (0, printer_utils_1.displaySemicolon)(ctx.Semicolon[0]);
|
|
93
93
|
}
|
|
94
94
|
return this.visitSingle(ctx);
|
|
95
95
|
};
|
|
96
96
|
PackagesAndModulesPrettierVisitor.prototype.moduleDeclaration = function (ctx) {
|
|
97
97
|
var annotations = this.mapVisit(ctx.annotation);
|
|
98
98
|
var optionalOpen = ctx.Open ? ctx.Open[0] : "";
|
|
99
|
-
var name = printer_utils_1.buildFqn(ctx.Identifier, ctx.Dot);
|
|
99
|
+
var name = (0, printer_utils_1.buildFqn)(ctx.Identifier, ctx.Dot);
|
|
100
100
|
var moduleDirectives = this.mapVisit(ctx.moduleDirective);
|
|
101
|
-
var content = printer_utils_1.rejectAndJoinSeps(printer_utils_1.getBlankLinesSeparator(ctx.moduleDirective), moduleDirectives);
|
|
102
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
103
|
-
prettier_builder_1.join(" ", annotations),
|
|
101
|
+
var content = (0, printer_utils_1.rejectAndJoinSeps)((0, printer_utils_1.getBlankLinesSeparator)(ctx.moduleDirective), moduleDirectives);
|
|
102
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
103
|
+
(0, prettier_builder_1.join)(" ", annotations),
|
|
104
104
|
optionalOpen,
|
|
105
105
|
ctx.Module[0],
|
|
106
106
|
name,
|
|
107
|
-
printer_utils_1.putIntoBraces(content, hardline, ctx.LCurly[0], ctx.RCurly[0])
|
|
107
|
+
(0, printer_utils_1.putIntoBraces)(content, hardline, ctx.LCurly[0], ctx.RCurly[0])
|
|
108
108
|
]);
|
|
109
109
|
};
|
|
110
110
|
PackagesAndModulesPrettierVisitor.prototype.moduleDirective = function (ctx) {
|
|
@@ -113,48 +113,61 @@ var PackagesAndModulesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
113
113
|
PackagesAndModulesPrettierVisitor.prototype.requiresModuleDirective = function (ctx) {
|
|
114
114
|
var modifiers = this.mapVisit(ctx.requiresModifier);
|
|
115
115
|
var moduleName = this.visit(ctx.moduleName);
|
|
116
|
-
return printer_utils_1.rejectAndJoin(" ", [
|
|
116
|
+
return (0, printer_utils_1.rejectAndJoin)(" ", [
|
|
117
117
|
ctx.Requires[0],
|
|
118
|
-
prettier_builder_1.join(" ", modifiers),
|
|
119
|
-
prettier_builder_1.concat([moduleName, ctx.Semicolon[0]])
|
|
118
|
+
(0, prettier_builder_1.join)(" ", modifiers),
|
|
119
|
+
(0, prettier_builder_1.concat)([moduleName, ctx.Semicolon[0]])
|
|
120
120
|
]);
|
|
121
121
|
};
|
|
122
122
|
PackagesAndModulesPrettierVisitor.prototype.exportsModuleDirective = function (ctx) {
|
|
123
123
|
var packageName = this.visit(ctx.packageName);
|
|
124
|
-
var to = ctx.To ? ctx.To[0] : "";
|
|
125
124
|
var moduleNames = this.mapVisit(ctx.moduleName);
|
|
126
|
-
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return prettier_builder_1.concat([elt, line]); }) : [];
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
printer_utils_1.rejectAndJoin(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
125
|
+
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
|
|
126
|
+
if (ctx.To) {
|
|
127
|
+
return group((0, printer_utils_1.rejectAndConcat)([
|
|
128
|
+
indent((0, printer_utils_1.rejectAndJoin)(line, [
|
|
129
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [ctx.Exports[0], packageName]),
|
|
130
|
+
group(indent((0, printer_utils_1.rejectAndJoin)(line, [
|
|
131
|
+
ctx.To[0],
|
|
132
|
+
(0, printer_utils_1.rejectAndJoinSeps)(commas, moduleNames)
|
|
133
|
+
])))
|
|
134
|
+
])),
|
|
135
|
+
ctx.Semicolon[0]
|
|
136
|
+
]));
|
|
137
|
+
}
|
|
138
|
+
return (0, printer_utils_1.rejectAndConcat)([
|
|
139
|
+
(0, prettier_builder_1.concat)([ctx.Exports[0], " "]),
|
|
140
|
+
packageName,
|
|
135
141
|
ctx.Semicolon[0]
|
|
136
|
-
])
|
|
142
|
+
]);
|
|
137
143
|
};
|
|
138
144
|
PackagesAndModulesPrettierVisitor.prototype.opensModuleDirective = function (ctx) {
|
|
139
145
|
var packageName = this.visit(ctx.packageName);
|
|
140
146
|
var to = ctx.To ? ctx.To[0] : "";
|
|
141
147
|
var moduleNames = this.mapVisit(ctx.moduleName);
|
|
142
|
-
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return prettier_builder_1.concat([elt, line]); }) : [];
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
printer_utils_1.rejectAndJoin(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
|
|
149
|
+
if (ctx.To) {
|
|
150
|
+
return group((0, printer_utils_1.rejectAndConcat)([
|
|
151
|
+
indent((0, printer_utils_1.rejectAndJoin)(line, [
|
|
152
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [ctx.Opens[0], packageName]),
|
|
153
|
+
group(indent((0, printer_utils_1.rejectAndJoin)(line, [
|
|
154
|
+
ctx.To[0],
|
|
155
|
+
(0, printer_utils_1.rejectAndJoinSeps)(commas, moduleNames)
|
|
156
|
+
])))
|
|
157
|
+
])),
|
|
158
|
+
ctx.Semicolon[0]
|
|
159
|
+
]));
|
|
160
|
+
}
|
|
161
|
+
return (0, printer_utils_1.rejectAndConcat)([
|
|
162
|
+
(0, prettier_builder_1.concat)([ctx.Opens[0], " "]),
|
|
163
|
+
packageName,
|
|
151
164
|
ctx.Semicolon[0]
|
|
152
|
-
])
|
|
165
|
+
]);
|
|
153
166
|
};
|
|
154
167
|
PackagesAndModulesPrettierVisitor.prototype.usesModuleDirective = function (ctx) {
|
|
155
168
|
var typeName = this.visit(ctx.typeName);
|
|
156
|
-
return printer_utils_1.rejectAndConcat([
|
|
157
|
-
prettier_builder_1.concat([ctx.Uses[0], " "]),
|
|
169
|
+
return (0, printer_utils_1.rejectAndConcat)([
|
|
170
|
+
(0, prettier_builder_1.concat)([ctx.Uses[0], " "]),
|
|
158
171
|
typeName,
|
|
159
172
|
ctx.Semicolon[0]
|
|
160
173
|
]);
|
|
@@ -162,20 +175,20 @@ var PackagesAndModulesPrettierVisitor = /** @class */ (function (_super) {
|
|
|
162
175
|
PackagesAndModulesPrettierVisitor.prototype.providesModuleDirective = function (ctx) {
|
|
163
176
|
var firstTypeName = this.visit(ctx.typeName[0]);
|
|
164
177
|
var otherTypeNames = this.mapVisit(ctx.typeName.slice(1));
|
|
165
|
-
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return prettier_builder_1.concat([elt, line]); }) : [];
|
|
166
|
-
return group(printer_utils_1.rejectAndConcat([
|
|
167
|
-
indent(printer_utils_1.rejectAndJoin(line, [
|
|
168
|
-
printer_utils_1.rejectAndJoin(" ", [ctx.Provides[0], firstTypeName]),
|
|
169
|
-
group(indent(printer_utils_1.rejectAndJoin(line, [
|
|
178
|
+
var commas = ctx.Comma ? ctx.Comma.map(function (elt) { return (0, prettier_builder_1.concat)([elt, line]); }) : [];
|
|
179
|
+
return group((0, printer_utils_1.rejectAndConcat)([
|
|
180
|
+
indent((0, printer_utils_1.rejectAndJoin)(line, [
|
|
181
|
+
(0, printer_utils_1.rejectAndJoin)(" ", [ctx.Provides[0], firstTypeName]),
|
|
182
|
+
group(indent((0, printer_utils_1.rejectAndJoin)(line, [
|
|
170
183
|
ctx.With[0],
|
|
171
|
-
printer_utils_1.rejectAndJoinSeps(commas, otherTypeNames)
|
|
184
|
+
(0, printer_utils_1.rejectAndJoinSeps)(commas, otherTypeNames)
|
|
172
185
|
])))
|
|
173
186
|
])),
|
|
174
187
|
ctx.Semicolon[0]
|
|
175
188
|
]));
|
|
176
189
|
};
|
|
177
190
|
PackagesAndModulesPrettierVisitor.prototype.requiresModifier = function (ctx) {
|
|
178
|
-
return format_comments_1.printTokenWithComments(this.getSingle(ctx));
|
|
191
|
+
return (0, format_comments_1.printTokenWithComments)(this.getSingle(ctx));
|
|
179
192
|
};
|
|
180
193
|
PackagesAndModulesPrettierVisitor.prototype.isModuleCompilationUnit = function () {
|
|
181
194
|
return "isModuleCompilationUnit";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.indentIfBreak = exports.ifBreak = exports.dedent = exports.indent = exports.fill = exports.group = exports.join = exports.concat = void 0;
|
|
2
4
|
var prettier = require("prettier").doc.builders;
|
|
3
5
|
var processComments = require("./comments/format-comments").processComments;
|
|
4
6
|
/*
|
|
@@ -7,38 +9,48 @@ var processComments = require("./comments/format-comments").processComments;
|
|
|
7
9
|
* ------------------------------------------------------------------
|
|
8
10
|
*/
|
|
9
11
|
function concat(docs) {
|
|
10
|
-
var concatenation =
|
|
11
|
-
|
|
12
|
+
var concatenation = processComments(docs);
|
|
13
|
+
if (!Array.isArray(docs)) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
return concatenation;
|
|
12
17
|
}
|
|
18
|
+
exports.concat = concat;
|
|
13
19
|
function join(sep, docs) {
|
|
14
20
|
var concatenation = prettier.join(processComments(sep), processComments(docs));
|
|
15
|
-
return concatenation
|
|
21
|
+
return processEmptyDocs(concatenation);
|
|
16
22
|
}
|
|
23
|
+
exports.join = join;
|
|
17
24
|
function group(doc, opts) {
|
|
18
25
|
var group = prettier.group(processComments(doc), opts);
|
|
19
26
|
return group.contents === undefined ? "" : group;
|
|
20
27
|
}
|
|
28
|
+
exports.group = group;
|
|
21
29
|
function fill(docs) {
|
|
22
30
|
var fill = prettier.fill(processComments(docs));
|
|
23
|
-
return fill
|
|
31
|
+
return processEmptyDocs(fill);
|
|
24
32
|
}
|
|
33
|
+
exports.fill = fill;
|
|
25
34
|
function indent(doc) {
|
|
26
35
|
var indentedDoc = prettier.indent(processComments(doc));
|
|
27
36
|
return indentedDoc.contents.length === 0 ? "" : indentedDoc;
|
|
28
37
|
}
|
|
38
|
+
exports.indent = indent;
|
|
29
39
|
function dedent(doc) {
|
|
30
40
|
var indentedDoc = prettier.dedent(processComments(doc));
|
|
31
41
|
return indentedDoc.contents.length === 0 ? "" : indentedDoc;
|
|
32
42
|
}
|
|
43
|
+
exports.dedent = dedent;
|
|
33
44
|
function ifBreak(breakContents, flatContents) {
|
|
34
45
|
return prettier.ifBreak(processComments(breakContents), processComments(flatContents));
|
|
35
46
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
exports.ifBreak = ifBreak;
|
|
48
|
+
function indentIfBreak(contents, opts) {
|
|
49
|
+
return prettier.indentIfBreak(processComments(contents), opts);
|
|
50
|
+
}
|
|
51
|
+
exports.indentIfBreak = indentIfBreak;
|
|
52
|
+
// TODO: remove this once prettier 3.0 is released
|
|
53
|
+
var processEmptyDocs = function (doc) {
|
|
54
|
+
var _a;
|
|
55
|
+
return ((_a = doc.parts) === null || _a === void 0 ? void 0 : _a.length) === 0 ? "" : doc;
|
|
44
56
|
};
|