prettier-plugin-java 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/LICENSE +1 -1
  2. package/dist/base-cst-printer.js +22 -44
  3. package/dist/cst-printer.js +19 -27
  4. package/dist/index.js +19 -20
  5. package/dist/options.js +16 -21
  6. package/dist/parser.js +2 -4
  7. package/dist/printer.js +3 -5
  8. package/dist/printers/arrays.js +17 -41
  9. package/dist/printers/blocks-and-statements.js +289 -356
  10. package/dist/printers/classes.js +451 -495
  11. package/dist/printers/comments/comments-utils.js +5 -13
  12. package/dist/printers/comments/format-comments.js +34 -50
  13. package/dist/printers/comments/handle-comments.js +17 -23
  14. package/dist/printers/expressions.js +378 -386
  15. package/dist/printers/interfaces.js +148 -181
  16. package/dist/printers/lexical-structure.js +26 -58
  17. package/dist/printers/names.js +29 -53
  18. package/dist/printers/packages-and-modules.js +116 -143
  19. package/dist/printers/prettier-builder.js +21 -31
  20. package/dist/printers/printer-utils.js +173 -221
  21. package/dist/printers/types-values-and-variables.js +111 -149
  22. package/dist/types/utils.js +6 -15
  23. package/dist/utils/expressions-utils.js +7 -11
  24. package/dist/utils/index.js +2 -12
  25. package/dist/utils/isEmptyDoc.js +2 -4
  26. package/dist/utils/printArgumentListWithBraces.js +29 -19
  27. package/dist/utils/printSingleLambdaInvocation.js +15 -17
  28. package/package.json +10 -13
  29. package/dist/src/base-cst-printer.js +0 -77
  30. package/dist/src/cst-printer.js +0 -37
  31. package/dist/src/index.js +0 -67
  32. package/dist/src/options.js +0 -256
  33. package/dist/src/parser.js +0 -7
  34. package/dist/src/printer.js +0 -28
  35. package/dist/src/printers/arrays.js +0 -49
  36. package/dist/src/printers/blocks-and-statements.js +0 -493
  37. package/dist/src/printers/classes.js +0 -724
  38. package/dist/src/printers/comments/comments-utils.js +0 -29
  39. package/dist/src/printers/comments/format-comments.js +0 -187
  40. package/dist/src/printers/comments/handle-comments.js +0 -38
  41. package/dist/src/printers/expressions.js +0 -549
  42. package/dist/src/printers/interfaces.js +0 -251
  43. package/dist/src/printers/lexical-structure.js +0 -43
  44. package/dist/src/printers/names.js +0 -53
  45. package/dist/src/printers/packages-and-modules.js +0 -185
  46. package/dist/src/printers/prettier-builder.js +0 -47
  47. package/dist/src/printers/printer-utils.js +0 -577
  48. package/dist/src/printers/types-values-and-variables.js +0 -183
  49. package/dist/src/types/utils.js +0 -29
  50. package/dist/src/utils/expressions-utils.js +0 -29
  51. package/dist/src/utils/index.js +0 -10
  52. package/dist/src/utils/printArgumentListWithBraces.js +0 -21
  53. package/dist/src/utils/printSingleLambdaInvocation.js +0 -20
  54. package/dist/test/babel-register.js +0 -3
  55. package/dist/test/repository-test/core-test.js +0 -12
  56. package/dist/test/repository-test/jhipster-1-test.js +0 -17
  57. package/dist/test/repository-test/jhipster-2-test.js +0 -16
  58. package/dist/test/test-utils.js +0 -215
  59. package/dist/test/unit-test/annotation_type_declaration/annotation_type_declaration-spec.js +0 -6
  60. package/dist/test/unit-test/args/args-spec.js +0 -6
  61. package/dist/test/unit-test/assert/assert-spec.js +0 -6
  62. package/dist/test/unit-test/binary_expressions/binary_expressions-spec.js +0 -6
  63. package/dist/test/unit-test/blank_lines/blank_lines-spec.js +0 -6
  64. package/dist/test/unit-test/bug-fixes/bug-fixes-spec.js +0 -6
  65. package/dist/test/unit-test/cast/cast-spec.js +0 -6
  66. package/dist/test/unit-test/char_literal/char_literal-spec.js +0 -6
  67. package/dist/test/unit-test/classes/multiple_classes-spec.js +0 -6
  68. package/dist/test/unit-test/comments/comments-spec.js +0 -14
  69. package/dist/test/unit-test/complex_generic_class/complex_generic_class-spec.js +0 -6
  70. package/dist/test/unit-test/constructors/constructors-spec.js +0 -6
  71. package/dist/test/unit-test/empty_statement/empty_statement-spec.js +0 -6
  72. package/dist/test/unit-test/enum/enum-spec.js +0 -6
  73. package/dist/test/unit-test/expressions/expressions-spec.js +0 -6
  74. package/dist/test/unit-test/extends_abstract_class/extends_abstract_class-spec.js +0 -6
  75. package/dist/test/unit-test/extends_abstract_class_and_implements_interfaces/extends_abstract_class_and_implements_interfaces-spec.js +0 -6
  76. package/dist/test/unit-test/for/for-spec.js +0 -6
  77. package/dist/test/unit-test/generic_class/generic_class-spec.js +0 -6
  78. package/dist/test/unit-test/generic_questionmark/generic_questionmark-spec.js +0 -6
  79. package/dist/test/unit-test/hello-world/hello-word-spec.js +0 -6
  80. package/dist/test/unit-test/if/if-spec.js +0 -6
  81. package/dist/test/unit-test/indent/indent-spec.js +0 -6
  82. package/dist/test/unit-test/instantiation/instantiation-spec.js +0 -6
  83. package/dist/test/unit-test/interface/interface-spec.js +0 -6
  84. package/dist/test/unit-test/lambda/lambda-spec.js +0 -6
  85. package/dist/test/unit-test/marker_annotations/marker_annotations-spec.js +0 -6
  86. package/dist/test/unit-test/member_chain/member_chain-spec.js +0 -6
  87. package/dist/test/unit-test/method_reference/method_reference-spec.js +0 -6
  88. package/dist/test/unit-test/modifiers/modifiers-spec.js +0 -6
  89. package/dist/test/unit-test/modules/modules-spec.js +0 -6
  90. package/dist/test/unit-test/package_and_imports/package_and_imports-spec.js +0 -34
  91. package/dist/test/unit-test/pattern-matching/pattern-matching-spec.js +0 -6
  92. package/dist/test/unit-test/prettier-ignore/prettier-ignore-spec.js +0 -28
  93. package/dist/test/unit-test/records/records-spec.js +0 -6
  94. package/dist/test/unit-test/return/return-spec.js +0 -6
  95. package/dist/test/unit-test/sealed/sealed-spec.js +0 -6
  96. package/dist/test/unit-test/snippets/arrays/array-initializer.spec.js +0 -94
  97. package/dist/test/unit-test/snippets/arrays/variable-initializer-list.spec.js +0 -19
  98. package/dist/test/unit-test/snippets/blocks-and-statements/switch.spec.js +0 -26
  99. package/dist/test/unit-test/snippets/classes/class-body.spec.js +0 -181
  100. package/dist/test/unit-test/snippets/classes/enum-body.spec.js +0 -87
  101. package/dist/test/unit-test/snippets/classes/variableDeclarator/test.spec.js +0 -186
  102. package/dist/test/unit-test/snippets/interfaces/element-value-array-initializer.spec.js +0 -85
  103. package/dist/test/unit-test/snippets/names/ambiguousName/test.spec.js +0 -19
  104. package/dist/test/unit-test/snippets/names/expressionName/test.spec.js +0 -19
  105. package/dist/test/unit-test/snippets/names/methodName/test.spec.js +0 -12
  106. package/dist/test/unit-test/snippets/names/packageOrTypeName/test.spec.js +0 -19
  107. package/dist/test/unit-test/snippets/types-values-and-variables/floatingPointType/test.spec.js +0 -19
  108. package/dist/test/unit-test/snippets/types-values-and-variables/integralType/test.spec.js +0 -40
  109. package/dist/test/unit-test/snippets/types-values-and-variables/numericType/test.spec.js +0 -88
  110. package/dist/test/unit-test/snippets/types-values-and-variables/wildcard/test.spec.js +0 -112
  111. package/dist/test/unit-test/snippets/types-values-and-variables/wildcardBounds/test.spec.js +0 -81
  112. package/dist/test/unit-test/switch/switch-spec.js +0 -6
  113. package/dist/test/unit-test/synchronized/synchronized-spec.js +0 -6
  114. package/dist/test/unit-test/text-blocks/text-block-spec.js +0 -6
  115. package/dist/test/unit-test/throws/throws-spec.js +0 -6
  116. package/dist/test/unit-test/try_catch/try_catch-spec.js +0 -6
  117. package/dist/test/unit-test/types/types-spec.js +0 -6
  118. package/dist/test/unit-test/variables/variables-spec.js +0 -6
  119. package/dist/test/unit-test/while/while-spec.js +0 -6
  120. package/dist/test/unit-test/yield-statement/yield-statement-spec.js +0 -6
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPrettierDoc = void 0;
4
- var base_cst_printer_1 = require("./base-cst-printer");
5
- var arrays_1 = require("./printers/arrays");
6
- var blocks_and_statements_1 = require("./printers/blocks-and-statements");
7
- var classes_1 = require("./printers/classes");
8
- var expressions_1 = require("./printers/expressions");
9
- var interfaces_1 = require("./printers/interfaces");
10
- var lexical_structure_1 = require("./printers/lexical-structure");
11
- var names_1 = require("./printers/names");
12
- var types_values_and_variables_1 = require("./printers/types-values-and-variables");
13
- var packages_and_modules_1 = require("./printers/packages-and-modules");
14
- // Mixins for the win
15
- mixInMethods(arrays_1.ArraysPrettierVisitor, blocks_and_statements_1.BlocksAndStatementPrettierVisitor, classes_1.ClassesPrettierVisitor, expressions_1.ExpressionsPrettierVisitor, interfaces_1.InterfacesPrettierVisitor, lexical_structure_1.LexicalStructurePrettierVisitor, names_1.NamesPrettierVisitor, types_values_and_variables_1.TypesValuesAndVariablesPrettierVisitor, packages_and_modules_1.PackagesAndModulesPrettierVisitor);
16
- function mixInMethods() {
17
- var classesToMix = [];
18
- for (var _i = 0; _i < arguments.length; _i++) {
19
- classesToMix[_i] = arguments[_i];
20
- }
21
- classesToMix.forEach(function (from) {
22
- var fromMethodsNames = Object.getOwnPropertyNames(from.prototype);
23
- var fromPureMethodsName = fromMethodsNames.filter(function (methodName) { return methodName !== "constructor"; });
24
- fromPureMethodsName.forEach(function (methodName) {
25
- // @ts-ignore
26
- base_cst_printer_1.BaseCstPrettierPrinter.prototype[methodName] = from.prototype[methodName];
27
- });
28
- });
29
- }
30
- var prettyPrinter = new base_cst_printer_1.BaseCstPrettierPrinter();
31
- // TODO: do we need the "path" and "print" arguments passed by prettier
32
- // see https://github.com/prettier/prettier/issues/5747
33
- function createPrettierDoc(cstNode, options) {
34
- prettyPrinter.prettierOptions = options;
35
- return prettyPrinter.visit(cstNode);
36
- }
37
- exports.createPrettierDoc = createPrettierDoc;
package/dist/src/index.js DELETED
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var parse = require("./parser");
3
- var print = require("./printer");
4
- var options = require("./options");
5
- var languages = [
6
- {
7
- name: "Java",
8
- parsers: ["java"],
9
- group: "Java",
10
- tmScope: "text.html.vue",
11
- aceMode: "html",
12
- codemirrorMode: "clike",
13
- codemirrorMimeType: "text/x-java",
14
- extensions: [".java"],
15
- linguistLanguageId: 181,
16
- vscodeLanguageIds: ["java"]
17
- }
18
- ];
19
- function locStart( /* node */) {
20
- return -1;
21
- }
22
- function locEnd( /* node */) {
23
- return -1;
24
- }
25
- function hasPragma( /* text */) {
26
- return false;
27
- }
28
- var parsers = {
29
- java: {
30
- parse: parse,
31
- astFormat: "java",
32
- locStart: locStart,
33
- locEnd: locEnd,
34
- hasPragma: hasPragma
35
- }
36
- };
37
- function canAttachComment(node) {
38
- return node.ast_type && node.ast_type !== "comment";
39
- }
40
- function printComment(commentPath) {
41
- var comment = commentPath.getValue();
42
- switch (comment.ast_type) {
43
- case "comment":
44
- return comment.value;
45
- default:
46
- throw new Error("Not a comment: " + JSON.stringify(comment));
47
- }
48
- }
49
- function clean(ast, newObj) {
50
- delete newObj.lineno;
51
- delete newObj.col_offset;
52
- }
53
- var printers = {
54
- java: {
55
- print: print,
56
- // hasPrettierIgnore,
57
- printComment: printComment,
58
- canAttachComment: canAttachComment,
59
- massageAstNode: clean
60
- }
61
- };
62
- module.exports = {
63
- languages: languages,
64
- printers: printers,
65
- parsers: parsers,
66
- options: options
67
- };
@@ -1,256 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- entrypoint: {
4
- type: "choice",
5
- category: "Global",
6
- default: "compilationUnit",
7
- // sed -nr 's/.*\.RULE\(([^,]+),.*/\1/p' $(ls path/to/java-parser/rules/folder/*)
8
- choices: [
9
- { value: "arrayInitializer" },
10
- { value: "variableInitializerList" },
11
- { value: "block" },
12
- { value: "blockStatements" },
13
- { value: "blockStatement" },
14
- { value: "localVariableDeclarationStatement" },
15
- { value: "localVariableDeclaration" },
16
- { value: "localVariableType" },
17
- { value: "statement" },
18
- { value: "statementWithoutTrailingSubstatement" },
19
- { value: "emptyStatement" },
20
- { value: "labeledStatement" },
21
- { value: "expressionStatement" },
22
- { value: "statementExpression" },
23
- { value: "ifStatement" },
24
- { value: "assertStatement" },
25
- { value: "switchStatement" },
26
- { value: "switchBlock" },
27
- { value: "switchBlockStatementGroup" },
28
- { value: "switchLabel" },
29
- { value: "caseOrDefaultLabel" },
30
- { value: "caseLabelElement" },
31
- { value: "switchRule" },
32
- { value: "caseConstant" },
33
- { value: "whileStatement" },
34
- { value: "doStatement" },
35
- { value: "forStatement" },
36
- { value: "basicForStatement" },
37
- { value: "forInit" },
38
- { value: "forUpdate" },
39
- { value: "statementExpressionList" },
40
- { value: "enhancedForStatement" },
41
- { value: "breakStatement" },
42
- { value: "continueStatement" },
43
- { value: "returnStatement" },
44
- { value: "throwStatement" },
45
- { value: "synchronizedStatement" },
46
- { value: "tryStatement" },
47
- { value: "catches" },
48
- { value: "catchClause" },
49
- { value: "catchFormalParameter" },
50
- { value: "catchType" },
51
- { value: "finally" },
52
- { value: "tryWithResourcesStatement" },
53
- { value: "resourceSpecification" },
54
- { value: "resourceList" },
55
- { value: "resource" },
56
- { value: "resourceInit" },
57
- { value: "yieldStatement" },
58
- { value: "variableAccess" },
59
- { value: "isBasicForStatement" },
60
- { value: "isLocalVariableDeclaration" },
61
- { value: "isClassicSwitchLabel" },
62
- { value: "classDeclaration" },
63
- { value: "normalClassDeclaration" },
64
- { value: "classModifier" },
65
- { value: "typeParameters" },
66
- { value: "typeParameterList" },
67
- { value: "superclass" },
68
- { value: "superinterfaces" },
69
- { value: "interfaceTypeList" },
70
- { value: "classPermits" },
71
- { value: "classBody" },
72
- { value: "classBodyDeclaration" },
73
- { value: "classMemberDeclaration" },
74
- { value: "fieldDeclaration" },
75
- { value: "fieldModifier" },
76
- { value: "variableDeclaratorList" },
77
- { value: "variableDeclarator" },
78
- { value: "variableDeclaratorId" },
79
- { value: "variableInitializer" },
80
- { value: "unannType" },
81
- { value: "unannPrimitiveTypeWithOptionalDimsSuffix" },
82
- { value: "unannPrimitiveType" },
83
- { value: "unannReferenceType" },
84
- { value: "unannClassOrInterfaceType" },
85
- { value: "unannClassType" },
86
- { value: "unannInterfaceType" },
87
- { value: "unannTypeVariable" },
88
- { value: "methodDeclaration" },
89
- { value: "methodModifier" },
90
- { value: "methodHeader" },
91
- { value: "result" },
92
- { value: "methodDeclarator" },
93
- { value: "receiverParameter" },
94
- { value: "formalParameterList" },
95
- { value: "formalParameter" },
96
- { value: "variableParaRegularParameter" },
97
- { value: "variableArityParameter" },
98
- { value: "variableModifier" },
99
- { value: "throws" },
100
- { value: "exceptionTypeList" },
101
- { value: "exceptionType" },
102
- { value: "methodBody" },
103
- { value: "instanceInitializer" },
104
- { value: "staticInitializer" },
105
- { value: "constructorDeclaration" },
106
- { value: "constructorModifier" },
107
- { value: "constructorDeclarator" },
108
- { value: "simpleTypeName" },
109
- { value: "constructorBody" },
110
- { value: "explicitConstructorInvocation" },
111
- { value: "unqualifiedExplicitConstructorInvocation" },
112
- { value: "qualifiedExplicitConstructorInvocation" },
113
- { value: "enumDeclaration" },
114
- { value: "enumBody" },
115
- { value: "enumConstantList" },
116
- { value: "enumConstant" },
117
- { value: "enumConstantModifier" },
118
- { value: "enumBodyDeclarations" },
119
- { value: "recordDeclaration" },
120
- { value: "recordHeader" },
121
- { value: "recordComponentList" },
122
- { value: "recordComponent" },
123
- { value: "variableArityRecordComponent" },
124
- { value: "recordComponentModifier" },
125
- { value: "recordBody" },
126
- { value: "recordBodyDeclaration" },
127
- { value: "compactConstructorDeclaration" },
128
- { value: "isClassDeclaration" },
129
- { value: "identifyClassBodyDeclarationType" },
130
- { value: "isDims" },
131
- { value: "isCompactConstructorDeclaration" },
132
- { value: "expression" },
133
- { value: "lambdaExpression" },
134
- { value: "lambdaParameters" },
135
- { value: "lambdaParametersWithBraces" },
136
- { value: "lambdaParameterList" },
137
- { value: "inferredLambdaParameterList" },
138
- { value: "explicitLambdaParameterList" },
139
- { value: "lambdaParameter" },
140
- { value: "regularLambdaParameter" },
141
- { value: "lambdaParameterType" },
142
- { value: "lambdaBody" },
143
- { value: "ternaryExpression" },
144
- { value: "binaryExpression" },
145
- { value: "unaryExpression" },
146
- { value: "unaryExpressionNotPlusMinus" },
147
- { value: "primary" },
148
- { value: "primaryPrefix" },
149
- { value: "primarySuffix" },
150
- { value: "fqnOrRefType" },
151
- { value: "fqnOrRefTypePartRest" },
152
- { value: "fqnOrRefTypePartCommon" },
153
- { value: "fqnOrRefTypePartFirst" },
154
- { value: "parenthesisExpression" },
155
- { value: "castExpression" },
156
- { value: "primitiveCastExpression" },
157
- { value: "referenceTypeCastExpression" },
158
- { value: "newExpression" },
159
- { value: "unqualifiedClassInstanceCreationExpression" },
160
- { value: "classOrInterfaceTypeToInstantiate" },
161
- { value: "typeArgumentsOrDiamond" },
162
- { value: "diamond" },
163
- { value: "methodInvocationSuffix" },
164
- { value: "argumentList" },
165
- { value: "arrayCreationExpression" },
166
- { value: "arrayCreationDefaultInitSuffix" },
167
- { value: "arrayCreationExplicitInitSuffix" },
168
- { value: "dimExprs" },
169
- { value: "dimExpr" },
170
- { value: "classLiteralSuffix" },
171
- { value: "arrayAccessSuffix" },
172
- { value: "methodReferenceSuffix" },
173
- { value: "pattern" },
174
- { value: "typePattern" },
175
- { value: "identifyNewExpressionType" },
176
- { value: "isLambdaExpression" },
177
- { value: "isCastExpression" },
178
- { value: "isPrimitiveCastExpression" },
179
- { value: "isReferenceTypeCastExpression" },
180
- { value: "isRefTypeInMethodRef" },
181
- { value: "interfaceDeclaration" },
182
- { value: "normalInterfaceDeclaration" },
183
- { value: "interfaceModifier" },
184
- { value: "extendsInterfaces" },
185
- { value: "interfacePermits" },
186
- { value: "interfaceBody" },
187
- { value: "interfaceMemberDeclaration" },
188
- { value: "constantDeclaration" },
189
- { value: "constantModifier" },
190
- { value: "interfaceMethodDeclaration" },
191
- { value: "interfaceMethodModifier" },
192
- { value: "annotationTypeDeclaration" },
193
- { value: "annotationTypeBody" },
194
- { value: "annotationTypeMemberDeclaration" },
195
- { value: "annotationTypeElementDeclaration" },
196
- { value: "annotationTypeElementModifier" },
197
- { value: "defaultValue" },
198
- { value: "annotation" },
199
- { value: "elementValuePairList" },
200
- { value: "elementValuePair" },
201
- { value: "elementValue" },
202
- { value: "elementValueArrayInitializer" },
203
- { value: "elementValueList" },
204
- { value: "identifyInterfaceBodyDeclarationType" },
205
- { value: "identifyAnnotationBodyDeclarationType" },
206
- { value: "isSimpleElementValueAnnotation" },
207
- { value: "literal" },
208
- { value: "integerLiteral" },
209
- { value: "floatingPointLiteral" },
210
- { value: "booleanLiteral" },
211
- { value: "moduleName" },
212
- { value: "packageName" },
213
- { value: "typeName" },
214
- { value: "expressionName" },
215
- { value: "methodName" },
216
- { value: "packageOrTypeName" },
217
- { value: "ambiguousName" },
218
- { value: "compilationUnit" },
219
- { value: "ordinaryCompilationUnit" },
220
- { value: "modularCompilationUnit" },
221
- { value: "packageDeclaration" },
222
- { value: "packageModifier" },
223
- { value: "importDeclaration" },
224
- { value: "typeDeclaration" },
225
- { value: "moduleDeclaration" },
226
- { value: "moduleDirective" },
227
- { value: "requiresModuleDirective" },
228
- { value: "exportsModuleDirective" },
229
- { value: "opensModuleDirective" },
230
- { value: "usesModuleDirective" },
231
- { value: "providesModuleDirective" },
232
- { value: "requiresModifier" },
233
- { value: "isModuleCompilationUnit" },
234
- { value: "primitiveType" },
235
- { value: "numericType" },
236
- { value: "integralType" },
237
- { value: "floatingPointType" },
238
- { value: "referenceType" },
239
- { value: "classOrInterfaceType" },
240
- { value: "classType" },
241
- { value: "interfaceType" },
242
- { value: "typeVariable" },
243
- { value: "dims" },
244
- { value: "typeParameter" },
245
- { value: "typeParameterModifier" },
246
- { value: "typeBound" },
247
- { value: "additionalBound" },
248
- { value: "typeArguments" },
249
- { value: "typeArgumentList" },
250
- { value: "typeArgument" },
251
- { value: "wildcard" },
252
- { value: "wildcardBounds" }
253
- ],
254
- description: "Prettify from the entrypoint, allowing to use prettier on snippet."
255
- }
256
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var javaParser = require("java-parser");
3
- function parse(text, parsers, opts) {
4
- var cst = javaParser.parse(text, opts.entrypoint);
5
- return cst;
6
- }
7
- module.exports = parse;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var createPrettierDoc = require("./cst-printer").createPrettierDoc;
3
- // eslint-disable-next-line no-unused-vars
4
- function genericPrint(path, options, print) {
5
- var node = path.getValue();
6
- // console.log(node);
7
- // if (node.comments) {
8
- // console.log(node.type, node.comments);
9
- // }
10
- // node["comments"] = [
11
- // {
12
- // ast_type: "comment",
13
- // value: "// a",
14
- // leading: false,
15
- // trailing: true,
16
- // printed: false
17
- // },
18
- // {
19
- // ast_type: "comment",
20
- // value: "// b",
21
- // leading: true,
22
- // trailing: false,
23
- // printed: false
24
- // }
25
- // ];
26
- return createPrettierDoc(node, options);
27
- }
28
- module.exports = genericPrint;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ArraysPrettierVisitor = void 0;
19
- var printer_utils_1 = require("./printer-utils");
20
- var doc_1 = require("prettier/doc");
21
- var base_cst_printer_1 = require("../base-cst-printer");
22
- var line = doc_1.builders.line;
23
- var ArraysPrettierVisitor = /** @class */ (function (_super) {
24
- __extends(ArraysPrettierVisitor, _super);
25
- function ArraysPrettierVisitor() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- ArraysPrettierVisitor.prototype.arrayInitializer = function (ctx) {
29
- var optionalVariableInitializerList = this.visit(ctx.variableInitializerList);
30
- return printer_utils_1.printArrayList({
31
- list: optionalVariableInitializerList,
32
- extraComma: ctx.Comma,
33
- LCurly: ctx.LCurly[0],
34
- RCurly: ctx.RCurly[0],
35
- trailingComma: this.prettierOptions.trailingComma
36
- });
37
- };
38
- ArraysPrettierVisitor.prototype.variableInitializerList = function (ctx) {
39
- var variableInitializers = this.mapVisit(ctx.variableInitializer);
40
- var commas = ctx.Comma
41
- ? ctx.Comma.map(function (comma) {
42
- return printer_utils_1.rejectAndConcat([comma, line]);
43
- })
44
- : [];
45
- return printer_utils_1.rejectAndJoinSeps(commas, variableInitializers);
46
- };
47
- return ArraysPrettierVisitor;
48
- }(base_cst_printer_1.BaseCstPrettierPrinter));
49
- exports.ArraysPrettierVisitor = ArraysPrettierVisitor;