prettier-plugin-java 1.3.0 → 1.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 (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 +724 -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 +565 -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 -940
  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
@@ -1,202 +0,0 @@
1
- "use strict";
2
-
3
- const forEach = require("lodash/forEach");
4
-
5
- const { concat, join } = require("./prettier-builder");
6
- const { printTokenWithComments } = require("./comments/format-comments");
7
- const {
8
- rejectAndJoin,
9
- rejectAndConcat,
10
- sortClassTypeChildren,
11
- rejectAndJoinSeps
12
- } = require("./printer-utils");
13
-
14
- class TypesValuesAndVariablesPrettierVisitor {
15
- primitiveType(ctx) {
16
- const annotations = this.mapVisit(ctx.annotation);
17
- const type = ctx.numericType
18
- ? this.visit(ctx.numericType)
19
- : this.getSingle(ctx);
20
-
21
- return rejectAndJoin(" ", [join(" ", annotations), type]);
22
- }
23
-
24
- numericType(ctx) {
25
- return this.visitSingle(ctx);
26
- }
27
-
28
- integralType(ctx) {
29
- return printTokenWithComments(this.getSingle(ctx));
30
- }
31
-
32
- floatingPointType(ctx) {
33
- return printTokenWithComments(this.getSingle(ctx));
34
- }
35
-
36
- referenceType(ctx) {
37
- const annotations = this.mapVisit(ctx.annotation);
38
-
39
- const type = ctx.primitiveType
40
- ? this.visit(ctx.primitiveType)
41
- : this.visit(ctx.classOrInterfaceType);
42
-
43
- const dims = this.visit(ctx.dims);
44
-
45
- return rejectAndJoin(" ", [join(" ", annotations), concat([type, dims])]);
46
- }
47
-
48
- classOrInterfaceType(ctx) {
49
- return this.visitSingle(ctx);
50
- }
51
-
52
- classType(ctx) {
53
- const tokens = sortClassTypeChildren(
54
- ctx.annotation,
55
- ctx.typeArguments,
56
- ctx.Identifier
57
- );
58
-
59
- const segments = [];
60
- let currentSegment = [];
61
-
62
- forEach(tokens, (token, i) => {
63
- if (token.name === "typeArguments") {
64
- currentSegment.push(this.visit([token]));
65
- segments.push(rejectAndConcat(currentSegment));
66
- currentSegment = [];
67
- } else if (token.name === "annotation") {
68
- currentSegment.push(this.visit([token]));
69
- } else {
70
- currentSegment.push(token);
71
- if (
72
- (i + 1 < tokens.length && tokens[i + 1].name !== "typeArguments") ||
73
- i + 1 === tokens.length
74
- ) {
75
- segments.push(rejectAndConcat(currentSegment));
76
- currentSegment = [];
77
- }
78
- }
79
- });
80
-
81
- return rejectAndJoinSeps(ctx.Dot, segments);
82
- }
83
-
84
- interfaceType(ctx) {
85
- return this.visitSingle(ctx);
86
- }
87
-
88
- typeVariable(ctx) {
89
- const annotations = this.mapVisit(ctx.annotation);
90
- const identifier = this.getSingle(ctx);
91
-
92
- return rejectAndJoin(" ", [join(" ", annotations), identifier]);
93
- }
94
-
95
- dims(ctx) {
96
- let tokens = [...ctx.LSquare];
97
-
98
- if (ctx.annotation) {
99
- tokens = [...tokens, ...ctx.annotation];
100
- }
101
-
102
- tokens = tokens.sort((a, b) => {
103
- const startOffset1 = a.name
104
- ? a.children.At[0].startOffset
105
- : a.startOffset;
106
- const startOffset2 = b.name
107
- ? b.children.At[0].startOffset
108
- : b.startOffset;
109
- return startOffset1 - startOffset2;
110
- });
111
-
112
- const segments = [];
113
- let currentSegment = [];
114
-
115
- forEach(tokens, token => {
116
- if (token.name === "annotation") {
117
- currentSegment.push(this.visit([token]));
118
- } else {
119
- segments.push(
120
- rejectAndConcat([
121
- rejectAndJoin(" ", currentSegment),
122
- concat([ctx.LSquare[0], ctx.RSquare[0]])
123
- ])
124
- );
125
- currentSegment = [];
126
- }
127
- });
128
-
129
- return rejectAndConcat(segments);
130
- }
131
-
132
- typeParameter(ctx) {
133
- const typeParameterModifiers = this.mapVisit(ctx.typeParameterModifier);
134
-
135
- const typeIdentifier = this.visit(ctx.typeIdentifier);
136
- const typeBound = this.visit(ctx.typeBound);
137
-
138
- return rejectAndJoin(" ", [
139
- join(" ", typeParameterModifiers),
140
- typeIdentifier,
141
- typeBound
142
- ]);
143
- }
144
-
145
- typeParameterModifier(ctx) {
146
- return this.visitSingle(ctx);
147
- }
148
-
149
- typeBound(ctx) {
150
- const classOrInterfaceType = this.visit(ctx.classOrInterfaceType);
151
- const additionalBound = this.mapVisit(ctx.additionalBound);
152
-
153
- return rejectAndJoin(" ", [
154
- ctx.Extends[0],
155
- classOrInterfaceType,
156
- join(" ", additionalBound)
157
- ]);
158
- }
159
-
160
- additionalBound(ctx) {
161
- const interfaceType = this.visit(ctx.interfaceType);
162
-
163
- return join(" ", [ctx.And[0], interfaceType]);
164
- }
165
-
166
- typeArguments(ctx) {
167
- const typeArgumentList = this.visit(ctx.typeArgumentList);
168
-
169
- return rejectAndConcat([ctx.Less[0], typeArgumentList, ctx.Greater[0]]);
170
- }
171
-
172
- typeArgumentList(ctx) {
173
- const typeArguments = this.mapVisit(ctx.typeArgument);
174
- const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, " "])) : [];
175
- return rejectAndJoinSeps(commas, typeArguments);
176
- }
177
-
178
- typeArgument(ctx) {
179
- return this.visitSingle(ctx);
180
- }
181
-
182
- wildcard(ctx) {
183
- const annotations = this.mapVisit(ctx.annotation);
184
- const wildcardBounds = this.visit(ctx.wildcardBounds);
185
-
186
- return rejectAndJoin(" ", [
187
- join(" ", annotations),
188
- ctx.QuestionMark[0],
189
- wildcardBounds
190
- ]);
191
- }
192
-
193
- wildcardBounds(ctx) {
194
- const keyWord = ctx.Extends ? ctx.Extends[0] : ctx.Super[0];
195
- const referenceType = this.visit(ctx.referenceType);
196
- return join(" ", [keyWord, referenceType]);
197
- }
198
- }
199
-
200
- module.exports = {
201
- TypesValuesAndVariablesPrettierVisitor
202
- };