prettier-plugin-java 2.6.8 → 2.7.1
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/dist/comments.d.ts +17 -0
- package/dist/comments.js +199 -0
- package/dist/index.d.ts +543 -0
- package/dist/index.js +26 -63
- package/dist/options.d.ts +23 -0
- package/dist/options.js +247 -239
- package/dist/parser.d.ts +9 -0
- package/dist/parser.js +24 -4
- package/dist/printer.d.ts +18 -0
- package/dist/printer.js +39 -5
- package/dist/printers/arrays.d.ts +9 -0
- package/dist/printers/arrays.js +8 -24
- package/dist/printers/blocks-and-statements.d.ts +117 -0
- package/dist/printers/blocks-and-statements.js +316 -412
- package/dist/printers/classes.d.ts +157 -0
- package/dist/printers/classes.js +422 -685
- package/dist/printers/expressions.d.ts +134 -0
- package/dist/printers/expressions.js +549 -555
- package/dist/printers/helpers.d.ts +71 -0
- package/dist/printers/helpers.js +233 -0
- package/dist/printers/index.d.ts +2 -0
- package/dist/printers/index.js +13 -0
- package/dist/printers/interfaces.d.ts +62 -0
- package/dist/printers/interfaces.js +146 -211
- package/dist/printers/lexical-structure.d.ts +14 -0
- package/dist/printers/lexical-structure.js +26 -28
- package/dist/printers/names.d.ts +12 -0
- package/dist/printers/names.js +11 -29
- package/dist/printers/packages-and-modules.d.ts +46 -0
- package/dist/printers/packages-and-modules.js +157 -159
- package/dist/printers/types-values-and-variables.d.ts +46 -0
- package/dist/printers/types-values-and-variables.js +86 -149
- package/package.json +5 -8
- package/dist/base-cst-printer.js +0 -55
- package/dist/cst-printer.js +0 -29
- package/dist/printers/comments/comments-utils.js +0 -21
- package/dist/printers/comments/format-comments.js +0 -171
- package/dist/printers/comments/handle-comments.js +0 -102
- package/dist/printers/prettier-builder.js +0 -45
- package/dist/printers/printer-utils.js +0 -598
- package/dist/types/utils.js +0 -20
- package/dist/utils/index.js +0 -2
- package/dist/utils/isEmptyDoc.js +0 -4
- package/dist/utils/printArgumentListWithBraces.js +0 -37
- package/index.d.ts +0 -4
|
@@ -1,222 +1,157 @@
|
|
|
1
|
-
import { concat, group, indent } from "./prettier-builder.js";
|
|
2
|
-
import { printTokenWithComments } from "./comments/format-comments.js";
|
|
3
|
-
import { handleCommentsParameters } from "./comments/handle-comments.js";
|
|
4
|
-
import { displaySemicolon, getInterfaceBodyDeclarationsSeparator, isStatementEmptyStatement, printArrayList, putIntoBraces, rejectAndConcat, rejectAndJoin, rejectAndJoinSeps, sortModifiers } from "./printer-utils.js";
|
|
5
1
|
import { builders } from "prettier/doc";
|
|
6
|
-
import {
|
|
7
|
-
const {
|
|
8
|
-
export
|
|
9
|
-
interfaceDeclaration(
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const declaration = ctx.normalInterfaceDeclaration
|
|
14
|
-
? this.visit(ctx.normalInterfaceDeclaration)
|
|
15
|
-
: this.visit(ctx.annotationInterfaceDeclaration);
|
|
16
|
-
return rejectAndJoin(hardline, [
|
|
17
|
-
rejectAndJoin(hardline, firstAnnotations),
|
|
18
|
-
rejectAndJoin(" ", [rejectAndJoin(" ", otherModifiers), declaration])
|
|
2
|
+
import { call, each, hasDeclarationAnnotations, indentInParentheses, lineEndWithComments, lineStartWithComments, onlyDefinedKey, printArrayInitializer, printBlock, printClassPermits, printList, printSingle, printWithModifiers } from "./helpers.js";
|
|
3
|
+
const { group, hardline, indent, join, line } = builders;
|
|
4
|
+
export default {
|
|
5
|
+
interfaceDeclaration(path, print) {
|
|
6
|
+
const declarationKey = onlyDefinedKey(path.node.children, [
|
|
7
|
+
"annotationInterfaceDeclaration",
|
|
8
|
+
"normalInterfaceDeclaration"
|
|
19
9
|
]);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const typeParameters =
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
return printWithModifiers(path, print, "interfaceModifier", call(path, print, declarationKey), true);
|
|
11
|
+
},
|
|
12
|
+
normalInterfaceDeclaration(path, print) {
|
|
13
|
+
const { interfaceExtends, interfacePermits, typeParameters } = path.node.children;
|
|
14
|
+
const header = ["interface ", call(path, print, "typeIdentifier")];
|
|
15
|
+
if (typeParameters) {
|
|
16
|
+
header.push(call(path, print, "typeParameters"));
|
|
17
|
+
}
|
|
28
18
|
if (interfaceExtends) {
|
|
29
|
-
|
|
19
|
+
header.push(indent([line, call(path, print, "interfaceExtends")]));
|
|
30
20
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
interfacePermits = indent(rejectAndConcat([softline, optionalInterfacePermits]));
|
|
21
|
+
if (interfacePermits) {
|
|
22
|
+
header.push(indent([line, call(path, print, "interfacePermits")]));
|
|
34
23
|
}
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
])
|
|
42
|
-
interfaceBody
|
|
24
|
+
return [group(header), " ", call(path, print, "interfaceBody")];
|
|
25
|
+
},
|
|
26
|
+
interfaceModifier: printSingle,
|
|
27
|
+
interfaceExtends(path, print) {
|
|
28
|
+
return group([
|
|
29
|
+
"extends",
|
|
30
|
+
indent([line, call(path, print, "interfaceTypeList")])
|
|
43
31
|
]);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
interfaceMemberDeclaration(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
constantDeclaration(
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
32
|
+
},
|
|
33
|
+
interfacePermits: printClassPermits,
|
|
34
|
+
interfaceBody(path, print) {
|
|
35
|
+
const declarations = [];
|
|
36
|
+
let previousRequiresPadding = false;
|
|
37
|
+
each(path, declarationPath => {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
const declaration = print(declarationPath);
|
|
40
|
+
if (declaration === "") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { node, previous } = declarationPath;
|
|
44
|
+
const constantDeclaration = (_a = node.children.constantDeclaration) === null || _a === void 0 ? void 0 : _a[0].children;
|
|
45
|
+
const methodDeclaration = (_b = node.children.interfaceMethodDeclaration) === null || _b === void 0 ? void 0 : _b[0].children;
|
|
46
|
+
const currentRequiresPadding = (!constantDeclaration && !methodDeclaration) ||
|
|
47
|
+
(methodDeclaration === null || methodDeclaration === void 0 ? void 0 : methodDeclaration.methodBody[0].children.block) !== undefined ||
|
|
48
|
+
hasDeclarationAnnotations((_d = (_c = constantDeclaration === null || constantDeclaration === void 0 ? void 0 : constantDeclaration.constantModifier) !== null && _c !== void 0 ? _c : methodDeclaration === null || methodDeclaration === void 0 ? void 0 : methodDeclaration.interfaceMethodModifier) !== null && _d !== void 0 ? _d : []);
|
|
49
|
+
const blankLine = declarations.length > 0 &&
|
|
50
|
+
(previousRequiresPadding ||
|
|
51
|
+
currentRequiresPadding ||
|
|
52
|
+
lineStartWithComments(node) > lineEndWithComments(previous) + 1);
|
|
53
|
+
declarations.push(blankLine ? [hardline, declaration] : declaration);
|
|
54
|
+
previousRequiresPadding = currentRequiresPadding;
|
|
55
|
+
}, "interfaceMemberDeclaration");
|
|
56
|
+
return printBlock(path, declarations);
|
|
57
|
+
},
|
|
58
|
+
interfaceMemberDeclaration(path, print) {
|
|
59
|
+
const { children } = path.node;
|
|
60
|
+
return children.Semicolon
|
|
61
|
+
? ""
|
|
62
|
+
: call(path, print, onlyDefinedKey(children));
|
|
63
|
+
},
|
|
64
|
+
constantDeclaration(path, print) {
|
|
65
|
+
const declaration = [
|
|
66
|
+
call(path, print, "unannType"),
|
|
67
|
+
" ",
|
|
68
|
+
call(path, print, "variableDeclaratorList"),
|
|
69
|
+
";"
|
|
70
|
+
];
|
|
71
|
+
return printWithModifiers(path, print, "constantModifier", declaration);
|
|
72
|
+
},
|
|
73
|
+
constantModifier: printSingle,
|
|
74
|
+
interfaceMethodDeclaration(path, print) {
|
|
75
|
+
const declaration = [
|
|
76
|
+
call(path, print, "methodHeader"),
|
|
77
|
+
path.node.children.methodBody[0].children.Semicolon ? "" : " ",
|
|
78
|
+
call(path, print, "methodBody")
|
|
79
|
+
];
|
|
80
|
+
return printWithModifiers(path, print, "interfaceMethodModifier", declaration);
|
|
81
|
+
},
|
|
82
|
+
interfaceMethodModifier: printSingle,
|
|
83
|
+
annotationInterfaceDeclaration(path, print) {
|
|
84
|
+
return join(" ", [
|
|
85
|
+
"@interface",
|
|
86
|
+
call(path, print, "typeIdentifier"),
|
|
87
|
+
call(path, print, "annotationInterfaceBody")
|
|
89
88
|
]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
},
|
|
90
|
+
annotationInterfaceBody(path, print) {
|
|
91
|
+
const declarations = [];
|
|
92
|
+
each(path, declarationPath => {
|
|
93
|
+
const declaration = print(declarationPath);
|
|
94
|
+
if (declaration === "") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
declarations.push(declarationPath.isFirst ? declaration : [hardline, declaration]);
|
|
98
|
+
}, "annotationInterfaceMemberDeclaration");
|
|
99
|
+
return printBlock(path, declarations);
|
|
100
|
+
},
|
|
101
|
+
annotationInterfaceMemberDeclaration(path, print) {
|
|
102
|
+
const { children } = path.node;
|
|
103
|
+
return children.Semicolon
|
|
104
|
+
? ""
|
|
105
|
+
: call(path, print, onlyDefinedKey(children));
|
|
106
|
+
},
|
|
107
|
+
annotationInterfaceElementDeclaration(path, print) {
|
|
108
|
+
const { dims, defaultValue } = path.node.children;
|
|
109
|
+
const declaration = [
|
|
110
|
+
call(path, print, "unannType"),
|
|
111
|
+
" ",
|
|
112
|
+
call(path, print, "Identifier"),
|
|
113
|
+
"()"
|
|
114
|
+
];
|
|
115
|
+
if (dims) {
|
|
116
|
+
declaration.push(call(path, print, "dims"));
|
|
94
117
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
interfaceMethodDeclaration(ctx) {
|
|
98
|
-
const modifiers = sortModifiers(ctx.interfaceMethodModifier);
|
|
99
|
-
const firstAnnotations = this.mapVisit(modifiers[0]);
|
|
100
|
-
const otherModifiers = this.mapVisit(modifiers[1]);
|
|
101
|
-
const methodHeader = this.visit(ctx.methodHeader);
|
|
102
|
-
const methodBody = this.visit(ctx.methodBody);
|
|
103
|
-
const separator = isStatementEmptyStatement(methodBody) ? "" : " ";
|
|
104
|
-
return rejectAndJoin(hardline, [
|
|
105
|
-
rejectAndJoin(hardline, firstAnnotations),
|
|
106
|
-
rejectAndJoin(" ", [
|
|
107
|
-
rejectAndJoin(" ", otherModifiers),
|
|
108
|
-
rejectAndJoin(separator, [methodHeader, methodBody])
|
|
109
|
-
])
|
|
110
|
-
]);
|
|
111
|
-
}
|
|
112
|
-
interfaceMethodModifier(ctx) {
|
|
113
|
-
if (ctx.annotation) {
|
|
114
|
-
return this.visitSingle(ctx);
|
|
118
|
+
if (defaultValue) {
|
|
119
|
+
declaration.push(" ", call(path, print, "defaultValue"));
|
|
115
120
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
]
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
rejectAndJoin(concat([line, line]), annotationInterfaceMemberDeclaration)
|
|
133
|
-
])),
|
|
134
|
-
ctx.RCurly[0]
|
|
135
|
-
]);
|
|
136
|
-
}
|
|
137
|
-
annotationInterfaceMemberDeclaration(ctx) {
|
|
138
|
-
if (ctx.Semicolon) {
|
|
139
|
-
return printTokenWithComments(this.getSingle(ctx));
|
|
121
|
+
declaration.push(";");
|
|
122
|
+
return printWithModifiers(path, print, "annotationInterfaceElementModifier", declaration);
|
|
123
|
+
},
|
|
124
|
+
annotationInterfaceElementModifier: printSingle,
|
|
125
|
+
defaultValue(path, print) {
|
|
126
|
+
return ["default ", call(path, print, "elementValue")];
|
|
127
|
+
},
|
|
128
|
+
annotation(path, print) {
|
|
129
|
+
const { children } = path.node;
|
|
130
|
+
const annotation = ["@", call(path, print, "typeName")];
|
|
131
|
+
if (children.elementValue || children.elementValuePairList) {
|
|
132
|
+
const valuesKey = onlyDefinedKey(children, [
|
|
133
|
+
"elementValue",
|
|
134
|
+
"elementValuePairList"
|
|
135
|
+
]);
|
|
136
|
+
annotation.push(indentInParentheses(call(path, print, valuesKey)));
|
|
140
137
|
}
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
? concat([" ", this.visit(ctx.defaultValue)])
|
|
152
|
-
: "";
|
|
153
|
-
return rejectAndJoin(hardline, [
|
|
154
|
-
rejectAndJoin(hardline, firstAnnotations),
|
|
155
|
-
rejectAndJoin(" ", [
|
|
156
|
-
rejectAndJoin(" ", otherModifiers),
|
|
157
|
-
unannType,
|
|
158
|
-
rejectAndConcat([
|
|
159
|
-
identifier,
|
|
160
|
-
concat([ctx.LBrace[0], ctx.RBrace[0]]),
|
|
161
|
-
dims,
|
|
162
|
-
defaultValue,
|
|
163
|
-
ctx.Semicolon[0]
|
|
164
|
-
])
|
|
165
|
-
])
|
|
138
|
+
return annotation;
|
|
139
|
+
},
|
|
140
|
+
elementValuePairList(path, print) {
|
|
141
|
+
return printList(path, print, "elementValuePair");
|
|
142
|
+
},
|
|
143
|
+
elementValuePair(path, print) {
|
|
144
|
+
return join(" ", [
|
|
145
|
+
call(path, print, "Identifier"),
|
|
146
|
+
call(path, print, "Equals"),
|
|
147
|
+
call(path, print, "elementValue")
|
|
166
148
|
]);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return rejectAndJoin(" ", [ctx.Default[0], elementValue]);
|
|
177
|
-
}
|
|
178
|
-
annotation(ctx) {
|
|
179
|
-
var _a, _b, _c;
|
|
180
|
-
const fqn = this.visit(ctx.typeName);
|
|
181
|
-
let annoArgs = "";
|
|
182
|
-
if (ctx.LBrace) {
|
|
183
|
-
const elementValues = (_c = (_b = (_a = ctx.elementValuePairList) === null || _a === void 0 ? void 0 : _a[0].children.elementValuePair) !== null && _b !== void 0 ? _b : ctx.elementValue) !== null && _c !== void 0 ? _c : [];
|
|
184
|
-
handleCommentsParameters(ctx.LBrace[0], elementValues, ctx.RBrace[0]);
|
|
185
|
-
if (ctx.elementValuePairList) {
|
|
186
|
-
annoArgs = putIntoBraces(this.visit(ctx.elementValuePairList), softline, ctx.LBrace[0], ctx.RBrace[0]);
|
|
187
|
-
}
|
|
188
|
-
else if (ctx.elementValue) {
|
|
189
|
-
annoArgs = putIntoBraces(this.visit(ctx.elementValue), softline, ctx.LBrace[0], ctx.RBrace[0]);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return group(rejectAndConcat([ctx.At[0], fqn, annoArgs]));
|
|
193
|
-
}
|
|
194
|
-
elementValuePairList(ctx) {
|
|
195
|
-
const elementValuePairs = this.mapVisit(ctx.elementValuePair);
|
|
196
|
-
const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
|
|
197
|
-
return rejectAndJoinSeps(commas, elementValuePairs);
|
|
198
|
-
}
|
|
199
|
-
elementValuePair(ctx) {
|
|
200
|
-
const identifier = ctx.Identifier[0];
|
|
201
|
-
const elementValue = this.visit(ctx.elementValue);
|
|
202
|
-
return rejectAndJoin(" ", [identifier, ctx.Equals[0], elementValue]);
|
|
203
|
-
}
|
|
204
|
-
elementValue(ctx) {
|
|
205
|
-
return this.visitSingle(ctx);
|
|
206
|
-
}
|
|
207
|
-
elementValueArrayInitializer(ctx) {
|
|
208
|
-
const elementValueList = this.visit(ctx.elementValueList);
|
|
209
|
-
return printArrayList({
|
|
210
|
-
list: elementValueList,
|
|
211
|
-
extraComma: ctx.Comma,
|
|
212
|
-
LCurly: ctx.LCurly[0],
|
|
213
|
-
RCurly: ctx.RCurly[0],
|
|
214
|
-
trailingComma: this.prettierOptions.trailingComma
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
elementValueList(ctx) {
|
|
218
|
-
const elementValues = this.mapVisit(ctx.elementValue);
|
|
219
|
-
const commas = ctx.Comma ? ctx.Comma.map(elt => concat([elt, line])) : [];
|
|
220
|
-
return group(rejectAndConcat([rejectAndJoinSeps(commas, elementValues)]));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
149
|
+
},
|
|
150
|
+
elementValue: printSingle,
|
|
151
|
+
elementValueArrayInitializer(path, print, options) {
|
|
152
|
+
return printArrayInitializer(path, print, options, "elementValueList");
|
|
153
|
+
},
|
|
154
|
+
elementValueList(path, print) {
|
|
155
|
+
return group(printList(path, print, "elementValue"));
|
|
156
|
+
}
|
|
157
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { builders } from "prettier/doc";
|
|
2
|
+
import { printSingle } from "./helpers.js";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
literal(path: import("prettier").AstPath<import("../../../java-parser/api.js").LiteralCstNode & {
|
|
5
|
+
comments?: import("../comments.js").JavaComment[];
|
|
6
|
+
}>, print: import("./helpers.js").JavaPrintFn): builders.Doc;
|
|
7
|
+
integerLiteral: typeof printSingle;
|
|
8
|
+
floatingPointLiteral: typeof printSingle;
|
|
9
|
+
booleanLiteral: typeof printSingle;
|
|
10
|
+
shiftOperator(path: import("prettier").AstPath<import("../../../java-parser/api.js").ShiftOperatorCstNode & {
|
|
11
|
+
comments?: import("../comments.js").JavaComment[];
|
|
12
|
+
}>, print: import("./helpers.js").JavaPrintFn): builders.Doc[];
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import { printTokenWithComments } from "./comments/format-comments.js";
|
|
2
|
-
import { join } from "./prettier-builder.js";
|
|
3
|
-
import { BaseCstPrettierPrinter } from "../base-cst-printer.js";
|
|
4
1
|
import { builders } from "prettier/doc";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return join(hardline, [
|
|
13
|
-
open,
|
|
14
|
-
...lines.map(line => line.slice(baseIndent))
|
|
15
|
-
]);
|
|
2
|
+
import { findBaseIndent, map, onlyDefinedKey, printSingle } from "./helpers.js";
|
|
3
|
+
const { hardline, indent, join } = builders;
|
|
4
|
+
export default {
|
|
5
|
+
literal(path, print) {
|
|
6
|
+
const { TextBlock } = path.node.children;
|
|
7
|
+
if (!TextBlock) {
|
|
8
|
+
return printSingle(path, print);
|
|
16
9
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
const [open, ...lines] = TextBlock[0].image.split("\n");
|
|
11
|
+
const baseIndent = findBaseIndent(lines);
|
|
12
|
+
const textBlock = join(hardline, [
|
|
13
|
+
open,
|
|
14
|
+
...lines.map(line => line.slice(baseIndent))
|
|
15
|
+
]);
|
|
16
|
+
const ancestor = path.getNode(14);
|
|
17
|
+
return (ancestor === null || ancestor === void 0 ? void 0 : ancestor.name) === "variableInitializer" ||
|
|
18
|
+
((ancestor === null || ancestor === void 0 ? void 0 : ancestor.name) === "binaryExpression" &&
|
|
19
|
+
ancestor.children.AssignmentOperator)
|
|
20
|
+
? indent(textBlock)
|
|
21
|
+
: textBlock;
|
|
22
|
+
},
|
|
23
|
+
integerLiteral: printSingle,
|
|
24
|
+
floatingPointLiteral: printSingle,
|
|
25
|
+
booleanLiteral: printSingle,
|
|
26
|
+
shiftOperator(path, print) {
|
|
27
|
+
return map(path, print, onlyDefinedKey(path.node.children));
|
|
30
28
|
}
|
|
31
|
-
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { printName, printSingle } from "./helpers.js";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
typeIdentifier: typeof printSingle;
|
|
4
|
+
moduleName: typeof printName;
|
|
5
|
+
packageName: typeof printName;
|
|
6
|
+
typeName: typeof printName;
|
|
7
|
+
expressionName: typeof printName;
|
|
8
|
+
methodName: typeof printSingle;
|
|
9
|
+
packageOrTypeName: typeof printName;
|
|
10
|
+
ambiguousName: typeof printName;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
package/dist/printers/names.js
CHANGED
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return buildFqn(ctx.Identifier, ctx.Dot);
|
|
13
|
-
}
|
|
14
|
-
typeName(ctx) {
|
|
15
|
-
return buildFqn(ctx.Identifier, ctx.Dot);
|
|
16
|
-
}
|
|
17
|
-
expressionName(ctx) {
|
|
18
|
-
return buildFqn(ctx.Identifier, ctx.Dot);
|
|
19
|
-
}
|
|
20
|
-
methodName(ctx) {
|
|
21
|
-
return printTokenWithComments(ctx.Identifier[0]);
|
|
22
|
-
}
|
|
23
|
-
packageOrTypeName(ctx) {
|
|
24
|
-
return buildFqn(ctx.Identifier, ctx.Dot);
|
|
25
|
-
}
|
|
26
|
-
ambiguousName(ctx) {
|
|
27
|
-
return buildFqn(ctx.Identifier, ctx.Dot);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
import { printName, printSingle } from "./helpers.js";
|
|
2
|
+
export default {
|
|
3
|
+
typeIdentifier: printSingle,
|
|
4
|
+
moduleName: printName,
|
|
5
|
+
packageName: printName,
|
|
6
|
+
typeName: printName,
|
|
7
|
+
expressionName: printName,
|
|
8
|
+
methodName: printSingle,
|
|
9
|
+
packageOrTypeName: printName,
|
|
10
|
+
ambiguousName: printName
|
|
11
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ExportsModuleDirectiveCstNode, ImportDeclarationCstNode, OpensModuleDirectiveCstNode } from "java-parser";
|
|
2
|
+
import type { AstPath } from "prettier";
|
|
3
|
+
import { builders } from "prettier/doc";
|
|
4
|
+
import { printSingle, type JavaPrintFn } from "./helpers.js";
|
|
5
|
+
declare const _default: {
|
|
6
|
+
compilationUnit(path: AstPath<import("java-parser").CompilationUnitCstNode & {
|
|
7
|
+
comments?: import("../comments.js").JavaComment[];
|
|
8
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
9
|
+
ordinaryCompilationUnit(path: AstPath<import("java-parser").OrdinaryCompilationUnitCstNode & {
|
|
10
|
+
comments?: import("../comments.js").JavaComment[];
|
|
11
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
12
|
+
modularCompilationUnit(path: AstPath<import("java-parser").ModularCompilationUnitCstNode & {
|
|
13
|
+
comments?: import("../comments.js").JavaComment[];
|
|
14
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
15
|
+
packageDeclaration(path: AstPath<import("java-parser").PackageDeclarationCstNode & {
|
|
16
|
+
comments?: import("../comments.js").JavaComment[];
|
|
17
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
18
|
+
packageModifier: typeof printSingle;
|
|
19
|
+
importDeclaration(path: AstPath<ImportDeclarationCstNode & {
|
|
20
|
+
comments?: import("../comments.js").JavaComment[];
|
|
21
|
+
}>, print: JavaPrintFn): builders.Doc;
|
|
22
|
+
typeDeclaration(path: AstPath<import("java-parser").TypeDeclarationCstNode & {
|
|
23
|
+
comments?: import("../comments.js").JavaComment[];
|
|
24
|
+
}>, print: JavaPrintFn): builders.Doc;
|
|
25
|
+
moduleDeclaration(path: AstPath<import("java-parser").ModuleDeclarationCstNode & {
|
|
26
|
+
comments?: import("../comments.js").JavaComment[];
|
|
27
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
28
|
+
moduleDirective: typeof printSingle;
|
|
29
|
+
requiresModuleDirective(path: AstPath<import("java-parser").RequiresModuleDirectiveCstNode & {
|
|
30
|
+
comments?: import("../comments.js").JavaComment[];
|
|
31
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
32
|
+
exportsModuleDirective(path: AstPath<ExportsModuleDirectiveCstNode & {
|
|
33
|
+
comments?: import("../comments.js").JavaComment[];
|
|
34
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
35
|
+
opensModuleDirective(path: AstPath<OpensModuleDirectiveCstNode & {
|
|
36
|
+
comments?: import("../comments.js").JavaComment[];
|
|
37
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
38
|
+
usesModuleDirective(path: AstPath<import("java-parser").UsesModuleDirectiveCstNode & {
|
|
39
|
+
comments?: import("../comments.js").JavaComment[];
|
|
40
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
41
|
+
providesModuleDirective(path: AstPath<import("java-parser").ProvidesModuleDirectiveCstNode & {
|
|
42
|
+
comments?: import("../comments.js").JavaComment[];
|
|
43
|
+
}>, print: JavaPrintFn): builders.Doc[];
|
|
44
|
+
requiresModifier: typeof printSingle;
|
|
45
|
+
};
|
|
46
|
+
export default _default;
|