prettier-plugin-java 1.2.0 → 1.5.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 (46) hide show
  1. package/dist/base-cst-printer.js +77 -0
  2. package/dist/cst-printer.js +37 -0
  3. package/dist/index.js +67 -0
  4. package/dist/options.js +256 -0
  5. package/dist/parser.js +7 -0
  6. package/dist/printer.js +28 -0
  7. package/dist/printers/arrays.js +49 -0
  8. package/dist/printers/blocks-and-statements.js +493 -0
  9. package/dist/printers/classes.js +720 -0
  10. package/dist/printers/comments/comments-utils.js +29 -0
  11. package/dist/printers/comments/format-comments.js +179 -0
  12. package/dist/printers/comments/handle-comments.js +38 -0
  13. package/dist/printers/expressions.js +549 -0
  14. package/dist/printers/interfaces.js +251 -0
  15. package/dist/printers/lexical-structure.js +43 -0
  16. package/dist/printers/names.js +53 -0
  17. package/dist/printers/packages-and-modules.js +185 -0
  18. package/dist/printers/prettier-builder.js +44 -0
  19. package/dist/printers/printer-utils.js +564 -0
  20. package/dist/printers/types-values-and-variables.js +183 -0
  21. package/dist/types/utils.js +29 -0
  22. package/dist/utils/expressions-utils.js +29 -0
  23. package/dist/utils/index.js +10 -0
  24. package/dist/utils/printArgumentListWithBraces.js +21 -0
  25. package/dist/utils/printSingleLambdaInvocation.js +20 -0
  26. package/package.json +32 -10
  27. package/src/cst-printer.js +0 -145
  28. package/src/index.js +0 -79
  29. package/src/options.js +0 -256
  30. package/src/parser.js +0 -10
  31. package/src/printer.js +0 -31
  32. package/src/printers/arrays.js +0 -38
  33. package/src/printers/blocks-and-statements.js +0 -588
  34. package/src/printers/classes.js +0 -937
  35. package/src/printers/comments/comments-utils.js +0 -38
  36. package/src/printers/comments/format-comments.js +0 -223
  37. package/src/printers/comments/handle-comments.js +0 -50
  38. package/src/printers/expressions.js +0 -703
  39. package/src/printers/interfaces.js +0 -324
  40. package/src/printers/lexical-structure.js +0 -27
  41. package/src/printers/names.js +0 -42
  42. package/src/printers/packages-and-modules.js +0 -231
  43. package/src/printers/prettier-builder.js +0 -60
  44. package/src/printers/printer-utils.js +0 -715
  45. package/src/printers/types-values-and-variables.js +0 -202
  46. package/yarn-error.log +0 -8052
package/src/options.js DELETED
@@ -1,256 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- entrypoint: {
5
- type: "choice",
6
- category: "Global",
7
- default: "compilationUnit",
8
- // sed -nr 's/.*\.RULE\(([^,]+),.*/\1/p' $(ls path/to/java-parser/rules/folder/*)
9
- choices: [
10
- { value: "arrayInitializer" },
11
- { value: "variableInitializerList" },
12
- { value: "block" },
13
- { value: "blockStatements" },
14
- { value: "blockStatement" },
15
- { value: "localVariableDeclarationStatement" },
16
- { value: "localVariableDeclaration" },
17
- { value: "localVariableType" },
18
- { value: "statement" },
19
- { value: "statementWithoutTrailingSubstatement" },
20
- { value: "emptyStatement" },
21
- { value: "labeledStatement" },
22
- { value: "expressionStatement" },
23
- { value: "statementExpression" },
24
- { value: "ifStatement" },
25
- { value: "assertStatement" },
26
- { value: "switchStatement" },
27
- { value: "switchBlock" },
28
- { value: "switchBlockStatementGroup" },
29
- { value: "switchLabel" },
30
- { value: "switchRule" },
31
- { value: "caseConstant" },
32
- { value: "whileStatement" },
33
- { value: "doStatement" },
34
- { value: "forStatement" },
35
- { value: "basicForStatement" },
36
- { value: "forInit" },
37
- { value: "forUpdate" },
38
- { value: "statementExpressionList" },
39
- { value: "enhancedForStatement" },
40
- { value: "breakStatement" },
41
- { value: "continueStatement" },
42
- { value: "returnStatement" },
43
- { value: "throwStatement" },
44
- { value: "synchronizedStatement" },
45
- { value: "tryStatement" },
46
- { value: "catches" },
47
- { value: "catchClause" },
48
- { value: "catchFormalParameter" },
49
- { value: "catchType" },
50
- { value: "finally" },
51
- { value: "tryWithResourcesStatement" },
52
- { value: "resourceSpecification" },
53
- { value: "resourceList" },
54
- { value: "resource" },
55
- { value: "resourceInit" },
56
- { value: "yieldStatement" },
57
- { value: "variableAccess" },
58
- { value: "isBasicForStatement" },
59
- { value: "isLocalVariableDeclaration" },
60
- { value: "isClassicSwitchLabel" },
61
- { value: "classDeclaration" },
62
- { value: "normalClassDeclaration" },
63
- { value: "classModifier" },
64
- { value: "typeParameters" },
65
- { value: "typeParameterList" },
66
- { value: "superclass" },
67
- { value: "superinterfaces" },
68
- { value: "interfaceTypeList" },
69
- { value: "classPermits" },
70
- { value: "classBody" },
71
- { value: "classBodyDeclaration" },
72
- { value: "classMemberDeclaration" },
73
- { value: "fieldDeclaration" },
74
- { value: "fieldModifier" },
75
- { value: "variableDeclaratorList" },
76
- { value: "variableDeclarator" },
77
- { value: "variableDeclaratorId" },
78
- { value: "variableInitializer" },
79
- { value: "unannType" },
80
- { value: "unannPrimitiveTypeWithOptionalDimsSuffix" },
81
- { value: "unannPrimitiveType" },
82
- { value: "unannReferenceType" },
83
- { value: "unannClassOrInterfaceType" },
84
- { value: "unannClassType" },
85
- { value: "unannInterfaceType" },
86
- { value: "unannTypeVariable" },
87
- { value: "methodDeclaration" },
88
- { value: "methodModifier" },
89
- { value: "methodHeader" },
90
- { value: "result" },
91
- { value: "methodDeclarator" },
92
- { value: "receiverParameter" },
93
- { value: "formalParameterList" },
94
- { value: "formalParameter" },
95
- { value: "variableParaRegularParameter" },
96
- { value: "variableArityParameter" },
97
- { value: "variableModifier" },
98
- { value: "throws" },
99
- { value: "exceptionTypeList" },
100
- { value: "exceptionType" },
101
- { value: "methodBody" },
102
- { value: "instanceInitializer" },
103
- { value: "staticInitializer" },
104
- { value: "constructorDeclaration" },
105
- { value: "constructorModifier" },
106
- { value: "constructorDeclarator" },
107
- { value: "simpleTypeName" },
108
- { value: "constructorBody" },
109
- { value: "explicitConstructorInvocation" },
110
- { value: "unqualifiedExplicitConstructorInvocation" },
111
- { value: "qualifiedExplicitConstructorInvocation" },
112
- { value: "enumDeclaration" },
113
- { value: "enumBody" },
114
- { value: "enumConstantList" },
115
- { value: "enumConstant" },
116
- { value: "enumConstantModifier" },
117
- { value: "enumBodyDeclarations" },
118
- { value: "recordDeclaration" },
119
- { value: "recordHeader" },
120
- { value: "recordComponentList" },
121
- { value: "recordComponent" },
122
- { value: "variableArityRecordComponent" },
123
- { value: "recordComponentModifier" },
124
- { value: "recordBody" },
125
- { value: "recordBodyDeclaration" },
126
- { value: "compactConstructorDeclaration" },
127
- { value: "isClassDeclaration" },
128
- { value: "identifyClassBodyDeclarationType" },
129
- { value: "isDims" },
130
- { value: "isCompactConstructorDeclaration" },
131
- { value: "expression" },
132
- { value: "lambdaExpression" },
133
- { value: "lambdaParameters" },
134
- { value: "lambdaParametersWithBraces" },
135
- { value: "lambdaParameterList" },
136
- { value: "inferredLambdaParameterList" },
137
- { value: "explicitLambdaParameterList" },
138
- { value: "lambdaParameter" },
139
- { value: "regularLambdaParameter" },
140
- { value: "lambdaParameterType" },
141
- { value: "lambdaBody" },
142
- { value: "ternaryExpression" },
143
- { value: "binaryExpression" },
144
- { value: "unaryExpression" },
145
- { value: "unaryExpressionNotPlusMinus" },
146
- { value: "primary" },
147
- { value: "primaryPrefix" },
148
- { value: "primarySuffix" },
149
- { value: "fqnOrRefType" },
150
- { value: "fqnOrRefTypePartRest" },
151
- { value: "fqnOrRefTypePartCommon" },
152
- { value: "fqnOrRefTypePartFirst" },
153
- { value: "parenthesisExpression" },
154
- { value: "castExpression" },
155
- { value: "primitiveCastExpression" },
156
- { value: "referenceTypeCastExpression" },
157
- { value: "newExpression" },
158
- { value: "unqualifiedClassInstanceCreationExpression" },
159
- { value: "classOrInterfaceTypeToInstantiate" },
160
- { value: "typeArgumentsOrDiamond" },
161
- { value: "diamond" },
162
- { value: "methodInvocationSuffix" },
163
- { value: "argumentList" },
164
- { value: "arrayCreationExpression" },
165
- { value: "arrayCreationDefaultInitSuffix" },
166
- { value: "arrayCreationExplicitInitSuffix" },
167
- { value: "dimExprs" },
168
- { value: "dimExpr" },
169
- { value: "classLiteralSuffix" },
170
- { value: "arrayAccessSuffix" },
171
- { value: "methodReferenceSuffix" },
172
- { value: "pattern" },
173
- { value: "typePattern" },
174
- { value: "identifyNewExpressionType" },
175
- { value: "isLambdaExpression" },
176
- { value: "isCastExpression" },
177
- { value: "isPrimitiveCastExpression" },
178
- { value: "isReferenceTypeCastExpression" },
179
- { value: "isRefTypeInMethodRef" },
180
- { value: "interfaceDeclaration" },
181
- { value: "normalInterfaceDeclaration" },
182
- { value: "interfaceModifier" },
183
- { value: "extendsInterfaces" },
184
- { value: "interfacePermits" },
185
- { value: "interfaceBody" },
186
- { value: "interfaceMemberDeclaration" },
187
- { value: "constantDeclaration" },
188
- { value: "constantModifier" },
189
- { value: "interfaceMethodDeclaration" },
190
- { value: "interfaceMethodModifier" },
191
- { value: "annotationTypeDeclaration" },
192
- { value: "annotationTypeBody" },
193
- { value: "annotationTypeMemberDeclaration" },
194
- { value: "annotationTypeElementDeclaration" },
195
- { value: "annotationTypeElementModifier" },
196
- { value: "defaultValue" },
197
- { value: "annotation" },
198
- { value: "elementValuePairList" },
199
- { value: "elementValuePair" },
200
- { value: "elementValue" },
201
- { value: "elementValueArrayInitializer" },
202
- { value: "elementValueList" },
203
- { value: "identifyInterfaceBodyDeclarationType" },
204
- { value: "identifyAnnotationBodyDeclarationType" },
205
- { value: "isSimpleElementValueAnnotation" },
206
- { value: "literal" },
207
- { value: "integerLiteral" },
208
- { value: "floatingPointLiteral" },
209
- { value: "booleanLiteral" },
210
- { value: "moduleName" },
211
- { value: "packageName" },
212
- { value: "typeName" },
213
- { value: "expressionName" },
214
- { value: "methodName" },
215
- { value: "packageOrTypeName" },
216
- { value: "ambiguousName" },
217
- { value: "compilationUnit" },
218
- { value: "ordinaryCompilationUnit" },
219
- { value: "modularCompilationUnit" },
220
- { value: "packageDeclaration" },
221
- { value: "packageModifier" },
222
- { value: "importDeclaration" },
223
- { value: "typeDeclaration" },
224
- { value: "moduleDeclaration" },
225
- { value: "moduleDirective" },
226
- { value: "requiresModuleDirective" },
227
- { value: "exportsModuleDirective" },
228
- { value: "opensModuleDirective" },
229
- { value: "usesModuleDirective" },
230
- { value: "providesModuleDirective" },
231
- { value: "requiresModifier" },
232
- { value: "isModuleCompilationUnit" },
233
- { value: "primitiveType" },
234
- { value: "numericType" },
235
- { value: "integralType" },
236
- { value: "floatingPointType" },
237
- { value: "referenceType" },
238
- { value: "classOrInterfaceType" },
239
- { value: "classType" },
240
- { value: "interfaceType" },
241
- { value: "typeVariable" },
242
- { value: "dims" },
243
- { value: "typeParameter" },
244
- { value: "typeParameterModifier" },
245
- { value: "typeBound" },
246
- { value: "additionalBound" },
247
- { value: "typeArguments" },
248
- { value: "typeArgumentList" },
249
- { value: "typeArgument" },
250
- { value: "wildcard" },
251
- { value: "wildcardBounds" }
252
- ],
253
- description:
254
- "Prettify from the entrypoint, allowing to use prettier on snippet."
255
- }
256
- };
package/src/parser.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- const javaParser = require("java-parser");
4
-
5
- function parse(text, parsers, opts) {
6
- const cst = javaParser.parse(text, opts.entrypoint);
7
- return cst;
8
- }
9
-
10
- module.exports = parse;
package/src/printer.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
- const { createPrettierDoc } = require("./cst-printer");
3
-
4
- // eslint-disable-next-line no-unused-vars
5
- function genericPrint(path, options, print) {
6
- const node = path.getValue();
7
- // console.log(node);
8
- // if (node.comments) {
9
- // console.log(node.type, node.comments);
10
- // }
11
-
12
- // node["comments"] = [
13
- // {
14
- // ast_type: "comment",
15
- // value: "// a",
16
- // leading: false,
17
- // trailing: true,
18
- // printed: false
19
- // },
20
- // {
21
- // ast_type: "comment",
22
- // value: "// b",
23
- // leading: true,
24
- // trailing: false,
25
- // printed: false
26
- // }
27
- // ];
28
- return createPrettierDoc(node, options);
29
- }
30
-
31
- module.exports = genericPrint;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- const { line } = require("prettier").doc.builders;
3
- const {
4
- rejectAndConcat,
5
- rejectAndJoinSeps,
6
- printArrayList
7
- } = require("./printer-utils");
8
-
9
- class ArraysPrettierVisitor {
10
- arrayInitializer(ctx) {
11
- const optionalVariableInitializerList = this.visit(
12
- ctx.variableInitializerList
13
- );
14
-
15
- return printArrayList({
16
- list: optionalVariableInitializerList,
17
- extraComma: ctx.Comma,
18
- LCurly: ctx.LCurly[0],
19
- RCurly: ctx.RCurly[0],
20
- trailingComma: this.prettierOptions.trailingComma
21
- });
22
- }
23
-
24
- variableInitializerList(ctx) {
25
- const variableInitializers = this.mapVisit(ctx.variableInitializer);
26
- const commas = ctx.Comma
27
- ? ctx.Comma.map(comma => {
28
- return rejectAndConcat([comma, line]);
29
- })
30
- : [];
31
-
32
- return rejectAndJoinSeps(commas, variableInitializers);
33
- }
34
- }
35
-
36
- module.exports = {
37
- ArraysPrettierVisitor
38
- };