@openrewrite/rewrite 0.31.0 → 0.32.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/dist/src/java/tree/support_types.d.ts +201 -190
- package/dist/src/java/tree/support_types.d.ts.map +1 -1
- package/dist/src/java/tree/support_types.js +75 -65
- package/dist/src/java/tree/support_types.js.map +1 -1
- package/dist/src/java/visitor.js +67 -67
- package/dist/src/javascript/extensions.js +1 -1
- package/dist/src/javascript/index.d.ts +1 -0
- package/dist/src/javascript/index.d.ts.map +1 -1
- package/dist/src/javascript/index.js +1 -0
- package/dist/src/javascript/index.js.map +1 -1
- package/dist/src/javascript/parser.js +1 -1
- package/dist/src/javascript/parser.js.map +1 -1
- package/dist/src/javascript/printer.d.ts +136 -0
- package/dist/src/javascript/printer.d.ts.map +1 -0
- package/dist/src/javascript/printer.js +1671 -0
- package/dist/src/javascript/printer.js.map +1 -0
- package/dist/src/javascript/tree/support_types.d.ts +300 -178
- package/dist/src/javascript/tree/support_types.d.ts.map +1 -1
- package/dist/src/javascript/tree/support_types.js +314 -178
- package/dist/src/javascript/tree/support_types.js.map +1 -1
- package/dist/src/javascript/visitor.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,1671 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.JavaScriptPrinter = void 0;
|
|
37
|
+
const J = __importStar(require("../java"));
|
|
38
|
+
const java_1 = require("../java");
|
|
39
|
+
const JS = __importStar(require("."));
|
|
40
|
+
const core_1 = require("../core");
|
|
41
|
+
const _1 = require(".");
|
|
42
|
+
class JavaScriptPrinter extends _1.JavaScriptVisitor {
|
|
43
|
+
constructor(cursor) {
|
|
44
|
+
super();
|
|
45
|
+
this.JAVA_SCRIPT_MARKER_WRAPPER = (out) => `/*~~${out}${out.length === 0 ? "" : "~~"}>*/`;
|
|
46
|
+
this.cursor = cursor;
|
|
47
|
+
}
|
|
48
|
+
visit(tree, p) {
|
|
49
|
+
return super.visit(tree, p);
|
|
50
|
+
}
|
|
51
|
+
visitJsCompilationUnit(cu, p) {
|
|
52
|
+
this.beforeSyntax(cu, 34, p);
|
|
53
|
+
this.visitJsRightPaddedLocal(cu.padding.statements, _1.JsRightPadded.Location.COMPILATION_UNIT_STATEMENTS, "", p);
|
|
54
|
+
this.visitSpace(cu.eof, 33, p);
|
|
55
|
+
this.afterSyntax(cu, p);
|
|
56
|
+
return cu;
|
|
57
|
+
}
|
|
58
|
+
visitAlias(alias, p) {
|
|
59
|
+
this.beforeSyntax(alias, _1.JsSpace.Location.ALIAS_PREFIX, p);
|
|
60
|
+
this.visitJsRightPadded(alias.padding.propertyName, _1.JsRightPadded.Location.ALIAS_PROPERTY_NAME, p);
|
|
61
|
+
p.append("as");
|
|
62
|
+
this.visit(alias.alias, p);
|
|
63
|
+
this.afterSyntax(alias, p);
|
|
64
|
+
return alias;
|
|
65
|
+
}
|
|
66
|
+
visitAwait(awaitExpr, p) {
|
|
67
|
+
this.beforeSyntax(awaitExpr, _1.JsSpace.Location.AWAIT_PREFIX, p);
|
|
68
|
+
p.append("await");
|
|
69
|
+
this.visit(awaitExpr.expression, p);
|
|
70
|
+
this.afterSyntax(awaitExpr, p);
|
|
71
|
+
return awaitExpr;
|
|
72
|
+
}
|
|
73
|
+
visitBindingElement(binding, p) {
|
|
74
|
+
this.beforeSyntax(binding, _1.JsSpace.Location.BINDING_ELEMENT_PREFIX, p);
|
|
75
|
+
if (binding.propertyName) {
|
|
76
|
+
this.visitJsRightPadded(binding.padding.propertyName, _1.JsRightPadded.Location.BINDING_ELEMENT_PROPERTY_NAME, p);
|
|
77
|
+
p.append(":");
|
|
78
|
+
}
|
|
79
|
+
this.visit(binding.name, p);
|
|
80
|
+
this.visitJsLeftPaddedLocal("=", binding.padding.initializer, _1.JsLeftPadded.Location.BINDING_ELEMENT_INITIALIZER, p);
|
|
81
|
+
this.afterSyntax(binding, p);
|
|
82
|
+
return binding;
|
|
83
|
+
}
|
|
84
|
+
visitDelete(del, p) {
|
|
85
|
+
this.beforeSyntax(del, _1.JsSpace.Location.DELETE_PREFIX, p);
|
|
86
|
+
p.append("delete");
|
|
87
|
+
this.visit(del.expression, p);
|
|
88
|
+
this.afterSyntax(del, p);
|
|
89
|
+
return del;
|
|
90
|
+
}
|
|
91
|
+
visitTrailingTokenStatement(statement, p) {
|
|
92
|
+
this.beforeSyntax(statement, _1.JsSpace.Location.TRAILING_TOKEN_STATEMENT_PREFIX, p);
|
|
93
|
+
this.visitJsRightPadded(statement.padding.expression, _1.JsRightPadded.Location.TRAILING_TOKEN_STATEMENT_EXPRESSION, p);
|
|
94
|
+
this.afterSyntax(statement, p);
|
|
95
|
+
return statement;
|
|
96
|
+
}
|
|
97
|
+
visitInferType(inferType, p) {
|
|
98
|
+
this.beforeSyntax(inferType, _1.JsSpace.Location.INFER_TYPE_PREFIX, p);
|
|
99
|
+
this.visitJsLeftPaddedLocal("infer", inferType.padding.typeParameter, _1.JsLeftPadded.Location.INFER_TYPE_TYPE_PARAMETER, p);
|
|
100
|
+
this.afterSyntax(inferType, p);
|
|
101
|
+
return inferType;
|
|
102
|
+
}
|
|
103
|
+
visitJsImport(jsImport, p) {
|
|
104
|
+
this.beforeSyntax(jsImport, _1.JsSpace.Location.JS_IMPORT_PREFIX, p);
|
|
105
|
+
jsImport.modifiers.forEach(m => this.visitModifier(m, p));
|
|
106
|
+
p.append("import");
|
|
107
|
+
this.visit(jsImport.importClause, p);
|
|
108
|
+
this.visitJsLeftPaddedLocal(jsImport.importClause ? "from" : "", jsImport.padding.moduleSpecifier, _1.JsLeftPadded.Location.JS_IMPORT_MODULE_SPECIFIER, p);
|
|
109
|
+
this.visit(jsImport.attributes, p);
|
|
110
|
+
this.afterSyntax(jsImport, p);
|
|
111
|
+
return jsImport;
|
|
112
|
+
}
|
|
113
|
+
visitJsImportClause(jsImportClause, p) {
|
|
114
|
+
this.beforeSyntax(jsImportClause, _1.JsSpace.Location.JS_IMPORT_CLAUSE_PREFIX, p);
|
|
115
|
+
if (jsImportClause.typeOnly) {
|
|
116
|
+
p.append("type");
|
|
117
|
+
}
|
|
118
|
+
const name = jsImportClause.padding.name;
|
|
119
|
+
this.visitJsRightPadded(name, _1.JsRightPadded.Location.JS_IMPORT_CLAUSE_NAME, p);
|
|
120
|
+
if (name && jsImportClause.namedBindings) {
|
|
121
|
+
p.append(",");
|
|
122
|
+
}
|
|
123
|
+
this.visit(jsImportClause.namedBindings, p);
|
|
124
|
+
this.afterSyntax(jsImportClause, p);
|
|
125
|
+
return jsImportClause;
|
|
126
|
+
}
|
|
127
|
+
visitTypeTreeExpression(typeTreeExpression, p) {
|
|
128
|
+
this.beforeSyntax(typeTreeExpression, _1.JsSpace.Location.TYPE_TREE_EXPRESSION_PREFIX, p);
|
|
129
|
+
this.visit(typeTreeExpression.expression, p);
|
|
130
|
+
this.afterSyntax(typeTreeExpression, p);
|
|
131
|
+
return typeTreeExpression;
|
|
132
|
+
}
|
|
133
|
+
visitNamespaceDeclaration(namespaceDeclaration, p) {
|
|
134
|
+
this.beforeSyntax(namespaceDeclaration, _1.JsSpace.Location.NAMESPACE_DECLARATION_PREFIX, p);
|
|
135
|
+
namespaceDeclaration.modifiers.forEach(it => this.visitModifier(it, p));
|
|
136
|
+
this.visitSpace(namespaceDeclaration.padding.keywordType.before, _1.JsSpace.Location.NAMESPACE_DECLARATION_KEYWORD_TYPE_PREFIX, p);
|
|
137
|
+
switch (namespaceDeclaration.keywordType) {
|
|
138
|
+
case _1.NamespaceDeclaration.KeywordType.Namespace:
|
|
139
|
+
p.append("namespace");
|
|
140
|
+
break;
|
|
141
|
+
case _1.NamespaceDeclaration.KeywordType.Module:
|
|
142
|
+
p.append("module");
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
this.visitJsRightPadded(namespaceDeclaration.padding.name, _1.JsRightPadded.Location.NAMESPACE_DECLARATION_NAME, p);
|
|
148
|
+
if (namespaceDeclaration.body) {
|
|
149
|
+
this.visit(namespaceDeclaration.body, p);
|
|
150
|
+
}
|
|
151
|
+
this.afterSyntax(namespaceDeclaration, p);
|
|
152
|
+
return namespaceDeclaration;
|
|
153
|
+
}
|
|
154
|
+
visitSatisfiesExpression(satisfiesExpression, p) {
|
|
155
|
+
this.beforeSyntax(satisfiesExpression, _1.JsSpace.Location.SATISFIES_EXPRESSION_PREFIX, p);
|
|
156
|
+
this.visit(satisfiesExpression.expression, p);
|
|
157
|
+
this.visitJsLeftPaddedLocal("satisfies", satisfiesExpression.padding.satisfiesType, _1.JsLeftPadded.Location.SATISFIES_EXPRESSION_SATISFIES_TYPE, p);
|
|
158
|
+
this.afterSyntax(satisfiesExpression, p);
|
|
159
|
+
return satisfiesExpression;
|
|
160
|
+
}
|
|
161
|
+
visitVoid(aVoid, p) {
|
|
162
|
+
this.beforeSyntax(aVoid, _1.JsSpace.Location.VOID_PREFIX, p);
|
|
163
|
+
p.append("void");
|
|
164
|
+
this.visit(aVoid.expression, p);
|
|
165
|
+
this.afterSyntax(aVoid, p);
|
|
166
|
+
return aVoid;
|
|
167
|
+
}
|
|
168
|
+
visitJsYield(yield_, p) {
|
|
169
|
+
this.beforeSyntax(yield_, _1.JsSpace.Location.YIELD_PREFIX, p);
|
|
170
|
+
p.append("yield");
|
|
171
|
+
if (yield_.delegated) {
|
|
172
|
+
this.visitJsLeftPaddedLocal("*", yield_.padding.delegated, _1.JsLeftPadded.Location.YIELD_DELEGATED, p);
|
|
173
|
+
}
|
|
174
|
+
this.visit(yield_.expression, p);
|
|
175
|
+
this.afterSyntax(yield_, p);
|
|
176
|
+
return yield_;
|
|
177
|
+
}
|
|
178
|
+
visitTry(try_, p) {
|
|
179
|
+
this.beforeSyntax(try_, 129, p);
|
|
180
|
+
p.append("try");
|
|
181
|
+
this.visit(try_.body, p);
|
|
182
|
+
this.visitNodes(try_.catches, p);
|
|
183
|
+
this.visitJLeftPaddedLocal("finally", try_.padding.finally, java_1.JLeftPadded.Location.TRY_FINALLY, p);
|
|
184
|
+
this.afterSyntax(try_, p);
|
|
185
|
+
return try_;
|
|
186
|
+
}
|
|
187
|
+
visitCatch(catch_, p) {
|
|
188
|
+
this.beforeSyntax(catch_, 30, p);
|
|
189
|
+
p.append("catch");
|
|
190
|
+
if (catch_.parameter.tree.variables.length > 0) {
|
|
191
|
+
this.visit(catch_.parameter, p);
|
|
192
|
+
}
|
|
193
|
+
this.visit(catch_.body, p);
|
|
194
|
+
this.afterSyntax(catch_, p);
|
|
195
|
+
return catch_;
|
|
196
|
+
}
|
|
197
|
+
visitJSTry(jsTry, p) {
|
|
198
|
+
this.beforeSyntax(jsTry, _1.JsSpace.Location.JSTRY_PREFIX, p);
|
|
199
|
+
p.append("try");
|
|
200
|
+
this.visit(jsTry.body, p);
|
|
201
|
+
this.visit(jsTry.catches, p);
|
|
202
|
+
this.visitJsLeftPaddedLocal("finally", jsTry.padding.finallie, _1.JsLeftPadded.Location.JSTRY_FINALLIE, p);
|
|
203
|
+
this.afterSyntax(jsTry, p);
|
|
204
|
+
return jsTry;
|
|
205
|
+
}
|
|
206
|
+
visitJSTryJSCatch(jsCatch, p) {
|
|
207
|
+
this.beforeSyntax(jsCatch, _1.JsSpace.Location.JSTRY_JSCATCH_PREFIX, p);
|
|
208
|
+
p.append("catch");
|
|
209
|
+
this.visit(jsCatch.parameter, p);
|
|
210
|
+
this.visit(jsCatch.body, p);
|
|
211
|
+
this.afterSyntax(jsCatch, p);
|
|
212
|
+
return jsCatch;
|
|
213
|
+
}
|
|
214
|
+
visitJSVariableDeclarations(multiVariable, p) {
|
|
215
|
+
this.beforeSyntax(multiVariable, _1.JsSpace.Location.JSVARIABLE_DECLARATIONS_PREFIX, p);
|
|
216
|
+
this.visitNodes(multiVariable.leadingAnnotations, p);
|
|
217
|
+
multiVariable.modifiers.forEach(it => this.visitModifier(it, p));
|
|
218
|
+
const variables = multiVariable.padding.variables;
|
|
219
|
+
for (let i = 0; i < variables.length; i++) {
|
|
220
|
+
const variable = variables[i];
|
|
221
|
+
this.beforeSyntax(variable.element, _1.JsSpace.Location.JSVARIABLE_DECLARATIONS_JSNAMED_VARIABLE_PREFIX, p);
|
|
222
|
+
if (multiVariable.varargs) {
|
|
223
|
+
p.append("...");
|
|
224
|
+
}
|
|
225
|
+
this.visit(variable.element.name, p);
|
|
226
|
+
this.visitSpace(variable.after, _1.JsSpace.Location.JSVARIABLE_DECLARATIONS_VARIABLES_SUFFIX, p);
|
|
227
|
+
if (multiVariable.typeExpression) {
|
|
228
|
+
this.visit(multiVariable.typeExpression, p);
|
|
229
|
+
}
|
|
230
|
+
if (variable.element.initializer) {
|
|
231
|
+
this.visitJsLeftPaddedLocal("=", variable.element.padding.initializer, _1.JsLeftPadded.Location.JSVARIABLE_DECLARATIONS_JSNAMED_VARIABLE_INITIALIZER, p);
|
|
232
|
+
}
|
|
233
|
+
this.afterSyntax(variable.element, p);
|
|
234
|
+
if (i < variables.length - 1) {
|
|
235
|
+
p.append(",");
|
|
236
|
+
}
|
|
237
|
+
else if (variable.markers.findFirst(java_1.Semicolon) !== undefined) {
|
|
238
|
+
p.append(";");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
this.afterSyntax(multiVariable, p);
|
|
242
|
+
return multiVariable;
|
|
243
|
+
}
|
|
244
|
+
visitJSVariableDeclarationsJSNamedVariable(variable, p) {
|
|
245
|
+
this.beforeSyntax(variable, _1.JsSpace.Location.JSVARIABLE_DECLARATIONS_JSNAMED_VARIABLE_PREFIX, p);
|
|
246
|
+
this.visit(variable.name, p);
|
|
247
|
+
const initializer = variable.padding.initializer;
|
|
248
|
+
this.visitJsLeftPaddedLocal("=", initializer, _1.JsLeftPadded.Location.JSVARIABLE_DECLARATIONS_JSNAMED_VARIABLE_INITIALIZER, p);
|
|
249
|
+
this.afterSyntax(variable, p);
|
|
250
|
+
return variable;
|
|
251
|
+
}
|
|
252
|
+
visitArrayDimension(arrayDimension, p) {
|
|
253
|
+
this.beforeSyntax(arrayDimension, 37, p);
|
|
254
|
+
p.append("[");
|
|
255
|
+
this.visitJRightPaddedLocalSingle(arrayDimension.padding.index, java_1.JRightPadded.Location.ARRAY_INDEX, "]", p);
|
|
256
|
+
this.afterSyntax(arrayDimension, p);
|
|
257
|
+
return arrayDimension;
|
|
258
|
+
}
|
|
259
|
+
visitArrayType(arrayType, p) {
|
|
260
|
+
this.beforeSyntax(arrayType, 8, p);
|
|
261
|
+
let type = arrayType;
|
|
262
|
+
while (type instanceof J.ArrayType) {
|
|
263
|
+
type = type.elementType;
|
|
264
|
+
}
|
|
265
|
+
this.visit(type, p);
|
|
266
|
+
this.visitNodes(arrayType.annotations, p);
|
|
267
|
+
if (arrayType.dimension) {
|
|
268
|
+
this.visitSpace(arrayType.dimension.before, 37, p);
|
|
269
|
+
p.append("[");
|
|
270
|
+
this.visitSpace(arrayType.dimension.element, 38, p);
|
|
271
|
+
p.append("]");
|
|
272
|
+
if (arrayType.elementType instanceof J.ArrayType) {
|
|
273
|
+
this.printDimensions(arrayType.elementType, p);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
this.afterSyntax(arrayType, p);
|
|
277
|
+
return arrayType;
|
|
278
|
+
}
|
|
279
|
+
printDimensions(arrayType, p) {
|
|
280
|
+
var _a, _b, _c, _d;
|
|
281
|
+
this.beforeSyntax(arrayType, 8, p);
|
|
282
|
+
this.visitNodes(arrayType.annotations, p);
|
|
283
|
+
this.visitSpace((_b = (_a = arrayType.dimension) === null || _a === void 0 ? void 0 : _a.before) !== null && _b !== void 0 ? _b : java_1.Space.EMPTY, 37, p);
|
|
284
|
+
p.append("[");
|
|
285
|
+
this.visitSpace((_d = (_c = arrayType.dimension) === null || _c === void 0 ? void 0 : _c.element) !== null && _d !== void 0 ? _d : java_1.Space.EMPTY, 38, p);
|
|
286
|
+
p.append("]");
|
|
287
|
+
if (arrayType.elementType instanceof J.ArrayType) {
|
|
288
|
+
this.printDimensions(arrayType.elementType, p);
|
|
289
|
+
}
|
|
290
|
+
this.afterSyntax(arrayType, p);
|
|
291
|
+
}
|
|
292
|
+
visitTernary(ternary, p) {
|
|
293
|
+
this.beforeSyntax(ternary, 123, p);
|
|
294
|
+
this.visit(ternary.condition, p);
|
|
295
|
+
this.visitJLeftPaddedLocal("?", ternary.padding.truePart, java_1.JLeftPadded.Location.TERNARY_TRUE, p);
|
|
296
|
+
this.visitJLeftPaddedLocal(":", ternary.padding.falsePart, java_1.JLeftPadded.Location.TERNARY_FALSE, p);
|
|
297
|
+
this.afterSyntax(ternary, p);
|
|
298
|
+
return ternary;
|
|
299
|
+
}
|
|
300
|
+
visitThrow(thrown, p) {
|
|
301
|
+
this.beforeSyntax(thrown, 127, p);
|
|
302
|
+
p.append("throw");
|
|
303
|
+
this.visit(thrown.exception, p);
|
|
304
|
+
this.afterSyntax(thrown, p);
|
|
305
|
+
return thrown;
|
|
306
|
+
}
|
|
307
|
+
visitIf(iff, p) {
|
|
308
|
+
this.beforeSyntax(iff, 62, p);
|
|
309
|
+
p.append("if");
|
|
310
|
+
this.visit(iff.ifCondition, p);
|
|
311
|
+
this.visitStatementLocal(iff.padding.thenPart, java_1.JRightPadded.Location.IF_THEN, p);
|
|
312
|
+
this.visit(iff.elsePart, p);
|
|
313
|
+
this.afterSyntax(iff, p);
|
|
314
|
+
return iff;
|
|
315
|
+
}
|
|
316
|
+
visitElse(else_, p) {
|
|
317
|
+
this.beforeSyntax(else_, 41, p);
|
|
318
|
+
p.append("else");
|
|
319
|
+
this.visitStatementLocal(else_.padding.body, java_1.JRightPadded.Location.IF_ELSE, p);
|
|
320
|
+
this.afterSyntax(else_, p);
|
|
321
|
+
return else_;
|
|
322
|
+
}
|
|
323
|
+
visitDoWhileLoop(doWhileLoop, p) {
|
|
324
|
+
this.beforeSyntax(doWhileLoop, 40, p);
|
|
325
|
+
p.append("do");
|
|
326
|
+
this.visitStatementLocal(doWhileLoop.padding.body, java_1.JRightPadded.Location.WHILE_BODY, p);
|
|
327
|
+
this.visitJLeftPaddedLocal("while", doWhileLoop.padding.whileCondition, java_1.JLeftPadded.Location.WHILE_CONDITION, p);
|
|
328
|
+
this.afterSyntax(doWhileLoop, p);
|
|
329
|
+
return doWhileLoop;
|
|
330
|
+
}
|
|
331
|
+
visitWhileLoop(whileLoop, p) {
|
|
332
|
+
this.beforeSyntax(whileLoop, 149, p);
|
|
333
|
+
p.append("while");
|
|
334
|
+
this.visit(whileLoop.condition, p);
|
|
335
|
+
this.visitStatementLocal(whileLoop.padding.body, java_1.JRightPadded.Location.WHILE_BODY, p);
|
|
336
|
+
this.afterSyntax(whileLoop, p);
|
|
337
|
+
return whileLoop;
|
|
338
|
+
}
|
|
339
|
+
visitInstanceOf(instanceOf, p) {
|
|
340
|
+
this.beforeSyntax(instanceOf, 70, p);
|
|
341
|
+
this.visitJRightPaddedLocalSingle(instanceOf.padding.expression, java_1.JRightPadded.Location.INSTANCEOF, "instanceof", p);
|
|
342
|
+
this.visit(instanceOf.clazz, p);
|
|
343
|
+
this.visit(instanceOf.pattern, p);
|
|
344
|
+
this.afterSyntax(instanceOf, p);
|
|
345
|
+
return instanceOf;
|
|
346
|
+
}
|
|
347
|
+
visitLiteral(literal, p) {
|
|
348
|
+
var _a, _b, _c;
|
|
349
|
+
this.beforeSyntax(literal, 80, p);
|
|
350
|
+
const unicodeEscapes = literal.unicodeEscapes;
|
|
351
|
+
if (!unicodeEscapes) {
|
|
352
|
+
p.append(literal.valueSource);
|
|
353
|
+
}
|
|
354
|
+
else if (literal.valueSource) {
|
|
355
|
+
const surrogateIter = unicodeEscapes[Symbol.iterator]();
|
|
356
|
+
let surrogate = (_a = surrogateIter.next().value) !== null && _a !== void 0 ? _a : null;
|
|
357
|
+
let i = 0;
|
|
358
|
+
if (surrogate && surrogate.valueSourceIndex === 0) {
|
|
359
|
+
p.append("\\u").append(surrogate.codePoint);
|
|
360
|
+
surrogate = (_b = surrogateIter.next().value) !== null && _b !== void 0 ? _b : null;
|
|
361
|
+
}
|
|
362
|
+
const valueSource = literal.valueSource;
|
|
363
|
+
for (let j = 0; j < valueSource.length; j++) {
|
|
364
|
+
const c = valueSource[j];
|
|
365
|
+
p.append(c);
|
|
366
|
+
if (surrogate && surrogate.valueSourceIndex === ++i) {
|
|
367
|
+
while (surrogate && surrogate.valueSourceIndex === i) {
|
|
368
|
+
p.append("\\u").append(surrogate.codePoint);
|
|
369
|
+
surrogate = (_c = surrogateIter.next().value) !== null && _c !== void 0 ? _c : null;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
this.afterSyntax(literal, p);
|
|
375
|
+
return literal;
|
|
376
|
+
}
|
|
377
|
+
visitScopedVariableDeclarations(variableDeclarations, p) {
|
|
378
|
+
this.beforeSyntax(variableDeclarations, _1.JsSpace.Location.SCOPED_VARIABLE_DECLARATIONS_PREFIX, p);
|
|
379
|
+
variableDeclarations.modifiers.forEach(m => this.visitModifier(m, p));
|
|
380
|
+
const scope = variableDeclarations.padding.scope;
|
|
381
|
+
if (scope) {
|
|
382
|
+
this.visitSpace(scope.before, _1.JsSpace.Location.SCOPED_VARIABLE_DECLARATIONS_SCOPE_PREFIX, p);
|
|
383
|
+
switch (scope.element) {
|
|
384
|
+
case JS.ScopedVariableDeclarations.Scope.Let:
|
|
385
|
+
p.append("let");
|
|
386
|
+
break;
|
|
387
|
+
case JS.ScopedVariableDeclarations.Scope.Const:
|
|
388
|
+
p.append("const");
|
|
389
|
+
break;
|
|
390
|
+
case JS.ScopedVariableDeclarations.Scope.Var:
|
|
391
|
+
p.append("var");
|
|
392
|
+
break;
|
|
393
|
+
case JS.ScopedVariableDeclarations.Scope.Using:
|
|
394
|
+
p.append("using");
|
|
395
|
+
break;
|
|
396
|
+
case JS.ScopedVariableDeclarations.Scope.Import:
|
|
397
|
+
p.append("import");
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
this.visitJsRightPaddedLocal(variableDeclarations.padding.variables, _1.JsRightPadded.Location.SCOPED_VARIABLE_DECLARATIONS_VARIABLES, ",", p);
|
|
402
|
+
this.afterSyntax(variableDeclarations, p);
|
|
403
|
+
return variableDeclarations;
|
|
404
|
+
}
|
|
405
|
+
visitVariableDeclarations(multiVariable, p) {
|
|
406
|
+
this.beforeSyntax(multiVariable, 144, p);
|
|
407
|
+
this.visitNodes(multiVariable.leadingAnnotations, p);
|
|
408
|
+
multiVariable.modifiers.forEach(it => this.visitModifier(it, p));
|
|
409
|
+
const variables = multiVariable.padding.variables;
|
|
410
|
+
for (let i = 0; i < variables.length; i++) {
|
|
411
|
+
const variable = variables[i];
|
|
412
|
+
this.beforeSyntax(variable.element, 146, p);
|
|
413
|
+
if (multiVariable.varargs) {
|
|
414
|
+
p.append("...");
|
|
415
|
+
}
|
|
416
|
+
this.visit(variable.element.name, p);
|
|
417
|
+
this.visitSpace(variable.after, 95, p);
|
|
418
|
+
if (multiVariable.typeExpression) {
|
|
419
|
+
this.visit(multiVariable.typeExpression, p);
|
|
420
|
+
}
|
|
421
|
+
if (variable.element.initializer) {
|
|
422
|
+
this.visitJLeftPaddedLocal("=", variable.element.padding.initializer, java_1.JLeftPadded.Location.VARIABLE_INITIALIZER, p);
|
|
423
|
+
}
|
|
424
|
+
this.afterSyntax(variable.element, p);
|
|
425
|
+
if (i < variables.length - 1) {
|
|
426
|
+
p.append(",");
|
|
427
|
+
}
|
|
428
|
+
else if (variable.markers.findFirst(java_1.Semicolon)) {
|
|
429
|
+
p.append(";");
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
this.afterSyntax(multiVariable, p);
|
|
433
|
+
return multiVariable;
|
|
434
|
+
}
|
|
435
|
+
visitVariable(variable, p) {
|
|
436
|
+
this.beforeSyntax(variable, 146, p);
|
|
437
|
+
this.visit(variable.name, p);
|
|
438
|
+
const initializer = variable.padding.initializer;
|
|
439
|
+
this.visitJLeftPaddedLocal("=", initializer, java_1.JLeftPadded.Location.VARIABLE_INITIALIZER, p);
|
|
440
|
+
this.afterSyntax(variable, p);
|
|
441
|
+
return variable;
|
|
442
|
+
}
|
|
443
|
+
visitIdentifier(ident, p) {
|
|
444
|
+
this.visitSpace(java_1.Space.EMPTY, 4, p);
|
|
445
|
+
this.visitNodes(ident.annotations, p);
|
|
446
|
+
this.beforeSyntax(ident, 60, p);
|
|
447
|
+
p.append(ident.simpleName);
|
|
448
|
+
this.afterSyntax(ident, p);
|
|
449
|
+
return ident;
|
|
450
|
+
}
|
|
451
|
+
visitFunctionDeclaration(functionDeclaration, p) {
|
|
452
|
+
this.beforeSyntax(functionDeclaration, _1.JsSpace.Location.FUNCTION_DECLARATION_PREFIX, p);
|
|
453
|
+
functionDeclaration.modifiers.forEach((m) => this.visitModifier(m, p));
|
|
454
|
+
this.visitJsLeftPaddedLocal("function", functionDeclaration.padding.asteriskToken, _1.JsLeftPadded.Location.FUNCTION_DECLARATION_ASTERISK_TOKEN, p);
|
|
455
|
+
this.visitJsLeftPaddedLocal(functionDeclaration.asteriskToken ? "*" : "", functionDeclaration.padding.name, _1.JsLeftPadded.Location.FUNCTION_DECLARATION_NAME, p);
|
|
456
|
+
const typeParameters = functionDeclaration.typeParameters;
|
|
457
|
+
if (typeParameters !== null) {
|
|
458
|
+
this.visitNodes(typeParameters.annotations, p);
|
|
459
|
+
this.visitSpace(typeParameters.prefix, 136, p);
|
|
460
|
+
this.visitMarkers(typeParameters.markers, p);
|
|
461
|
+
p.append("<");
|
|
462
|
+
this.visitJRightPaddedLocal(typeParameters.padding.typeParameters, java_1.JRightPadded.Location.TYPE_PARAMETER, ",", p);
|
|
463
|
+
p.append(">");
|
|
464
|
+
}
|
|
465
|
+
this.visitJsContainerLocal("(", functionDeclaration.padding.parameters, _1.JsContainer.Location.FUNCTION_DECLARATION_PARAMETERS, ",", ")", p);
|
|
466
|
+
if (functionDeclaration.returnTypeExpression !== null) {
|
|
467
|
+
this.visit(functionDeclaration.returnTypeExpression, p);
|
|
468
|
+
}
|
|
469
|
+
if (functionDeclaration.body !== null) {
|
|
470
|
+
this.visit(functionDeclaration.body, p);
|
|
471
|
+
}
|
|
472
|
+
this.afterSyntax(functionDeclaration, p);
|
|
473
|
+
return functionDeclaration;
|
|
474
|
+
}
|
|
475
|
+
visitBlock(block, p) {
|
|
476
|
+
this.beforeSyntax(block, 19, p);
|
|
477
|
+
if (block.static) {
|
|
478
|
+
p.append("static");
|
|
479
|
+
this.visitRightPadded(block.padding.static, java_1.JRightPadded.Location.STATIC_INIT, p);
|
|
480
|
+
}
|
|
481
|
+
p.append("{");
|
|
482
|
+
this.visitStatements(block.padding.statements, java_1.JRightPadded.Location.BLOCK_STATEMENT, p);
|
|
483
|
+
this.visitSpace(block.end, 18, p);
|
|
484
|
+
p.append("}");
|
|
485
|
+
this.afterSyntax(block, p);
|
|
486
|
+
return block;
|
|
487
|
+
}
|
|
488
|
+
visitTypeInfo(typeInfo, p) {
|
|
489
|
+
this.beforeSyntax(typeInfo, _1.JsSpace.Location.TYPE_INFO_PREFIX, p);
|
|
490
|
+
p.append(":");
|
|
491
|
+
this.visit(typeInfo.typeIdentifier, p);
|
|
492
|
+
this.afterSyntax(typeInfo, p);
|
|
493
|
+
return typeInfo;
|
|
494
|
+
}
|
|
495
|
+
visitReturn(return_, p) {
|
|
496
|
+
this.beforeSyntax(return_, 115, p);
|
|
497
|
+
p.append("return");
|
|
498
|
+
this.visit(return_.expression, p);
|
|
499
|
+
this.afterSyntax(return_, p);
|
|
500
|
+
return return_;
|
|
501
|
+
}
|
|
502
|
+
visitModifier(mod, p) {
|
|
503
|
+
var _a;
|
|
504
|
+
this.visitNodes(mod.annotations, p);
|
|
505
|
+
let keyword;
|
|
506
|
+
switch (mod.type) {
|
|
507
|
+
case J.Modifier.Type.Default:
|
|
508
|
+
keyword = "default";
|
|
509
|
+
break;
|
|
510
|
+
case J.Modifier.Type.Public:
|
|
511
|
+
keyword = "public";
|
|
512
|
+
break;
|
|
513
|
+
case J.Modifier.Type.Protected:
|
|
514
|
+
keyword = "protected";
|
|
515
|
+
break;
|
|
516
|
+
case J.Modifier.Type.Private:
|
|
517
|
+
keyword = "private";
|
|
518
|
+
break;
|
|
519
|
+
case J.Modifier.Type.Abstract:
|
|
520
|
+
keyword = "abstract";
|
|
521
|
+
break;
|
|
522
|
+
case J.Modifier.Type.Async:
|
|
523
|
+
keyword = "async";
|
|
524
|
+
break;
|
|
525
|
+
case J.Modifier.Type.Static:
|
|
526
|
+
keyword = "static";
|
|
527
|
+
break;
|
|
528
|
+
case J.Modifier.Type.Final:
|
|
529
|
+
keyword = "final";
|
|
530
|
+
break;
|
|
531
|
+
case J.Modifier.Type.Native:
|
|
532
|
+
keyword = "native";
|
|
533
|
+
break;
|
|
534
|
+
case J.Modifier.Type.NonSealed:
|
|
535
|
+
keyword = "non-sealed";
|
|
536
|
+
break;
|
|
537
|
+
case J.Modifier.Type.Sealed:
|
|
538
|
+
keyword = "sealed";
|
|
539
|
+
break;
|
|
540
|
+
case J.Modifier.Type.Strictfp:
|
|
541
|
+
keyword = "strictfp";
|
|
542
|
+
break;
|
|
543
|
+
case J.Modifier.Type.Synchronized:
|
|
544
|
+
keyword = "synchronized";
|
|
545
|
+
break;
|
|
546
|
+
case J.Modifier.Type.Transient:
|
|
547
|
+
keyword = "transient";
|
|
548
|
+
break;
|
|
549
|
+
case J.Modifier.Type.Volatile:
|
|
550
|
+
keyword = "volatile";
|
|
551
|
+
break;
|
|
552
|
+
default:
|
|
553
|
+
keyword = (_a = mod.keyword) !== null && _a !== void 0 ? _a : "";
|
|
554
|
+
}
|
|
555
|
+
this.beforeSyntax(mod, 93, p);
|
|
556
|
+
p.append(keyword);
|
|
557
|
+
this.afterSyntax(mod, p);
|
|
558
|
+
return mod;
|
|
559
|
+
}
|
|
560
|
+
visitFunctionType(functionType, p) {
|
|
561
|
+
this.beforeSyntax(functionType, _1.JsSpace.Location.FUNCTION_TYPE_PREFIX, p);
|
|
562
|
+
functionType.modifiers.forEach(m => this.visitModifier(m, p));
|
|
563
|
+
if (functionType.constructorType) {
|
|
564
|
+
this.visitJsLeftPaddedLocal("new", functionType.padding.constructorType, _1.JsLeftPadded.Location.FUNCTION_TYPE_CONSTRUCTOR_TYPE, p);
|
|
565
|
+
}
|
|
566
|
+
const typeParameters = functionType.typeParameters;
|
|
567
|
+
if (typeParameters) {
|
|
568
|
+
this.visitNodes(typeParameters.annotations, p);
|
|
569
|
+
this.visitSpace(typeParameters.prefix, 136, p);
|
|
570
|
+
this.visitMarkers(typeParameters.markers, p);
|
|
571
|
+
p.append("<");
|
|
572
|
+
this.visitJRightPaddedLocal(typeParameters.padding.typeParameters, java_1.JRightPadded.Location.TYPE_PARAMETER, ",", p);
|
|
573
|
+
p.append(">");
|
|
574
|
+
}
|
|
575
|
+
this.visitJsContainerLocal("(", functionType.padding.parameters, _1.JsContainer.Location.FUNCTION_TYPE_PARAMETERS, ",", ")", p);
|
|
576
|
+
this.visitJsLeftPaddedLocal("=>", functionType.padding.returnType, _1.JsLeftPadded.Location.FUNCTION_TYPE_RETURN_TYPE, p);
|
|
577
|
+
this.afterSyntax(functionType, p);
|
|
578
|
+
return functionType;
|
|
579
|
+
}
|
|
580
|
+
visitClassDeclaration(classDecl, p) {
|
|
581
|
+
let kind = "";
|
|
582
|
+
switch (classDecl.padding.kind.type) {
|
|
583
|
+
case J.ClassDeclaration.Kind.Type.Class:
|
|
584
|
+
kind = "class";
|
|
585
|
+
break;
|
|
586
|
+
case J.ClassDeclaration.Kind.Type.Enum:
|
|
587
|
+
kind = "enum";
|
|
588
|
+
break;
|
|
589
|
+
case J.ClassDeclaration.Kind.Type.Interface:
|
|
590
|
+
kind = "interface";
|
|
591
|
+
break;
|
|
592
|
+
case J.ClassDeclaration.Kind.Type.Annotation:
|
|
593
|
+
kind = "@interface";
|
|
594
|
+
break;
|
|
595
|
+
case J.ClassDeclaration.Kind.Type.Record:
|
|
596
|
+
kind = "record";
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
this.beforeSyntax(classDecl, 31, p);
|
|
600
|
+
this.visitSpace(java_1.Space.EMPTY, 4, p);
|
|
601
|
+
this.visitNodes(classDecl.leadingAnnotations, p);
|
|
602
|
+
classDecl.modifiers.forEach(m => this.visitModifier(m, p));
|
|
603
|
+
this.visitNodes(classDecl.padding.kind.annotations, p);
|
|
604
|
+
this.visitSpace(classDecl.padding.kind.prefix, 32, p);
|
|
605
|
+
p.append(kind);
|
|
606
|
+
this.visit(classDecl.name, p);
|
|
607
|
+
this.visitJContainerLocal("<", classDecl.padding.typeParameters, java_1.JContainer.Location.TYPE_PARAMETERS, ",", ">", p);
|
|
608
|
+
this.visitJContainerLocal("(", classDecl.padding.primaryConstructor, java_1.JContainer.Location.RECORD_STATE_VECTOR, ",", ")", p);
|
|
609
|
+
this.visitJLeftPaddedLocal("extends", classDecl.padding.extends, java_1.JLeftPadded.Location.EXTENDS, p);
|
|
610
|
+
this.visitJContainerLocal(classDecl.padding.kind.type === J.ClassDeclaration.Kind.Type.Interface ? "extends" : "implements", classDecl.padding.implements, java_1.JContainer.Location.IMPLEMENTS, ",", null, p);
|
|
611
|
+
this.visit(classDecl.body, p);
|
|
612
|
+
this.afterSyntax(classDecl, p);
|
|
613
|
+
return classDecl;
|
|
614
|
+
}
|
|
615
|
+
visitMethodDeclaration(method, p) {
|
|
616
|
+
this.beforeSyntax(method, 87, p);
|
|
617
|
+
this.visitSpace(java_1.Space.EMPTY, 4, p);
|
|
618
|
+
this.visitNodes(method.leadingAnnotations, p);
|
|
619
|
+
method.modifiers.forEach(m => this.visitModifier(m, p));
|
|
620
|
+
this.visit(method.padding.name.identifier, p);
|
|
621
|
+
const typeParameters = method.annotations.typeParameters;
|
|
622
|
+
if (typeParameters) {
|
|
623
|
+
this.visitNodes(typeParameters.annotations, p);
|
|
624
|
+
this.visitSpace(typeParameters.prefix, 136, p);
|
|
625
|
+
this.visitMarkers(typeParameters.markers, p);
|
|
626
|
+
p.append("<");
|
|
627
|
+
this.visitJRightPaddedLocal(typeParameters.padding.typeParameters, java_1.JRightPadded.Location.TYPE_PARAMETER, ",", p);
|
|
628
|
+
p.append(">");
|
|
629
|
+
}
|
|
630
|
+
this.visitJContainerLocal("(", method.padding.parameters, java_1.JContainer.Location.METHOD_DECLARATION_PARAMETERS, ",", ")", p);
|
|
631
|
+
if (method.returnTypeExpression) {
|
|
632
|
+
this.visit(method.returnTypeExpression, p);
|
|
633
|
+
}
|
|
634
|
+
this.visit(method.body, p);
|
|
635
|
+
this.afterSyntax(method, p);
|
|
636
|
+
return method;
|
|
637
|
+
}
|
|
638
|
+
visitJSMethodDeclaration(method, p) {
|
|
639
|
+
this.beforeSyntax(method, _1.JsSpace.Location.JSMETHOD_DECLARATION_PREFIX, p);
|
|
640
|
+
this.visitSpace(java_1.Space.EMPTY, 4, p);
|
|
641
|
+
this.visitNodes(method.leadingAnnotations, p);
|
|
642
|
+
method.modifiers.forEach(it => this.visitModifier(it, p));
|
|
643
|
+
this.visit(method.name, p);
|
|
644
|
+
const typeParameters = method.typeParameters;
|
|
645
|
+
if (typeParameters) {
|
|
646
|
+
this.visitNodes(typeParameters.annotations, p);
|
|
647
|
+
this.visitSpace(typeParameters.prefix, 136, p);
|
|
648
|
+
this.visitMarkers(typeParameters.markers, p);
|
|
649
|
+
p.append("<");
|
|
650
|
+
this.visitJRightPaddedLocal(typeParameters.padding.typeParameters, java_1.JRightPadded.Location.TYPE_PARAMETER, ",", p);
|
|
651
|
+
p.append(">");
|
|
652
|
+
}
|
|
653
|
+
this.visitJsContainerLocal("(", method.padding.parameters, _1.JsContainer.Location.JSMETHOD_DECLARATION_PARAMETERS, ",", ")", p);
|
|
654
|
+
if (method.returnTypeExpression) {
|
|
655
|
+
this.visit(method.returnTypeExpression, p);
|
|
656
|
+
}
|
|
657
|
+
this.visit(method.body, p);
|
|
658
|
+
this.afterSyntax(method, p);
|
|
659
|
+
return method;
|
|
660
|
+
}
|
|
661
|
+
visitMethodInvocation(method, p) {
|
|
662
|
+
this.beforeSyntax(method, 91, p);
|
|
663
|
+
if (method.name.toString().length === 0) {
|
|
664
|
+
this.visitRightPadded(method.padding.select, java_1.JRightPadded.Location.METHOD_SELECT, p);
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
this.visitJRightPaddedLocalSingle(method.padding.select, java_1.JRightPadded.Location.METHOD_SELECT, "", p);
|
|
668
|
+
this.visit(method.name, p);
|
|
669
|
+
}
|
|
670
|
+
this.visitJContainerLocal("<", method.padding.typeParameters, java_1.JContainer.Location.TYPE_PARAMETERS, ",", ">", p);
|
|
671
|
+
this.visitJContainerLocal("(", method.padding.arguments, java_1.JContainer.Location.METHOD_INVOCATION_ARGUMENTS, ",", ")", p);
|
|
672
|
+
this.afterSyntax(method, p);
|
|
673
|
+
return method;
|
|
674
|
+
}
|
|
675
|
+
visitTypeParameter(typeParameter, p) {
|
|
676
|
+
this.beforeSyntax(typeParameter, 137, p);
|
|
677
|
+
this.visitNodes(typeParameter.annotations, p);
|
|
678
|
+
typeParameter.modifiers.forEach(m => this.visitModifier(m, p));
|
|
679
|
+
this.visit(typeParameter.name, p);
|
|
680
|
+
const bounds = typeParameter.padding.bounds;
|
|
681
|
+
if (bounds) {
|
|
682
|
+
this.visitSpace(bounds.before, java_1.JContainer.Location.beforeLocation(java_1.JContainer.Location.TYPE_BOUNDS), p);
|
|
683
|
+
const constraintType = bounds.padding.elements[0];
|
|
684
|
+
if (!(constraintType.element instanceof J.Empty)) {
|
|
685
|
+
p.append("extends");
|
|
686
|
+
this.visitRightPadded(constraintType, java_1.JContainer.Location.elementLocation(java_1.JContainer.Location.TYPE_BOUNDS), p);
|
|
687
|
+
}
|
|
688
|
+
const defaultType = bounds.padding.elements[1];
|
|
689
|
+
if (!(defaultType.element instanceof J.Empty)) {
|
|
690
|
+
p.append("=");
|
|
691
|
+
this.visitRightPadded(defaultType, java_1.JContainer.Location.elementLocation(java_1.JContainer.Location.TYPE_BOUNDS), p);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
this.afterSyntax(typeParameter, p);
|
|
695
|
+
return typeParameter;
|
|
696
|
+
}
|
|
697
|
+
visitArrowFunction(arrowFunction, p) {
|
|
698
|
+
this.beforeSyntax(arrowFunction, _1.JsSpace.Location.ARROW_FUNCTION_PREFIX, p);
|
|
699
|
+
this.visitNodes(arrowFunction.leadingAnnotations, p);
|
|
700
|
+
arrowFunction.modifiers.forEach(m => this.visitModifier(m, p));
|
|
701
|
+
const typeParameters = arrowFunction.typeParameters;
|
|
702
|
+
if (typeParameters) {
|
|
703
|
+
this.visitNodes(typeParameters.annotations, p);
|
|
704
|
+
this.visitSpace(typeParameters.prefix, 136, p);
|
|
705
|
+
this.visitMarkers(typeParameters.markers, p);
|
|
706
|
+
p.append("<");
|
|
707
|
+
this.visitJRightPaddedLocal(typeParameters.padding.typeParameters, java_1.JRightPadded.Location.TYPE_PARAMETER, ",", p);
|
|
708
|
+
p.append(">");
|
|
709
|
+
}
|
|
710
|
+
if (arrowFunction.parameters.parenthesized) {
|
|
711
|
+
this.visitSpace(arrowFunction.parameters.prefix, 77, p);
|
|
712
|
+
p.append("(");
|
|
713
|
+
this.visitJRightPaddedLocal(arrowFunction.parameters.padding.parameters, java_1.JRightPadded.Location.LAMBDA_PARAM, ",", p);
|
|
714
|
+
p.append(")");
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
this.visitJRightPaddedLocal(arrowFunction.parameters.padding.parameters, java_1.JRightPadded.Location.LAMBDA_PARAM, ",", p);
|
|
718
|
+
}
|
|
719
|
+
if (arrowFunction.returnTypeExpression) {
|
|
720
|
+
this.visit(arrowFunction.returnTypeExpression, p);
|
|
721
|
+
}
|
|
722
|
+
this.visitJsLeftPaddedLocal("=>", arrowFunction.padding.body, _1.JsLeftPadded.Location.ARROW_FUNCTION_BODY, p);
|
|
723
|
+
this.afterSyntax(arrowFunction, p);
|
|
724
|
+
return arrowFunction;
|
|
725
|
+
}
|
|
726
|
+
visitConditionalType(conditionalType, p) {
|
|
727
|
+
this.beforeSyntax(conditionalType, _1.JsSpace.Location.CONDITIONAL_TYPE_PREFIX, p);
|
|
728
|
+
this.visit(conditionalType.checkType, p);
|
|
729
|
+
this.visitJsContainerLocal("extends", conditionalType.padding.condition, _1.JsContainer.Location.CONDITIONAL_TYPE_CONDITION, "", "", p);
|
|
730
|
+
this.afterSyntax(conditionalType, p);
|
|
731
|
+
return conditionalType;
|
|
732
|
+
}
|
|
733
|
+
visitExpressionWithTypeArguments(type, p) {
|
|
734
|
+
this.beforeSyntax(type, _1.JsSpace.Location.EXPRESSION_WITH_TYPE_ARGUMENTS_PREFIX, p);
|
|
735
|
+
this.visit(type.clazz, p);
|
|
736
|
+
this.visitJsContainerLocal("<", type.padding.typeArguments, _1.JsContainer.Location.EXPRESSION_WITH_TYPE_ARGUMENTS_TYPE_ARGUMENTS, ",", ">", p);
|
|
737
|
+
this.afterSyntax(type, p);
|
|
738
|
+
return type;
|
|
739
|
+
}
|
|
740
|
+
visitImportType(importType, p) {
|
|
741
|
+
this.beforeSyntax(importType, _1.JsSpace.Location.IMPORT_TYPE_PREFIX, p);
|
|
742
|
+
if (importType.hasTypeof) {
|
|
743
|
+
p.append("typeof");
|
|
744
|
+
this.visitJsRightPadded(importType.padding.hasTypeof, _1.JsRightPadded.Location.IMPORT_TYPE_HAS_TYPEOF, p);
|
|
745
|
+
}
|
|
746
|
+
p.append("import");
|
|
747
|
+
this.visitJsContainerLocal("(", importType.padding.argumentAndAttributes, _1.JsContainer.Location.IMPORT_TYPE_ARGUMENT_AND_ATTRIBUTES, ",", ")", p);
|
|
748
|
+
this.visitJsLeftPaddedLocal(".", importType.padding.qualifier, _1.JsLeftPadded.Location.IMPORT_TYPE_QUALIFIER, p);
|
|
749
|
+
this.visitJsContainerLocal("<", importType.padding.typeArguments, _1.JsContainer.Location.IMPORT_TYPE_TYPE_ARGUMENTS, ",", ">", p);
|
|
750
|
+
this.afterSyntax(importType, p);
|
|
751
|
+
return importType;
|
|
752
|
+
}
|
|
753
|
+
visitTypeDeclaration(typeDeclaration, p) {
|
|
754
|
+
this.beforeSyntax(typeDeclaration, _1.JsSpace.Location.TYPE_DECLARATION_PREFIX, p);
|
|
755
|
+
typeDeclaration.modifiers.forEach(m => this.visitModifier(m, p));
|
|
756
|
+
this.visitJsLeftPaddedLocal("type", typeDeclaration.padding.name, _1.JsLeftPadded.Location.TYPE_DECLARATION_NAME, p);
|
|
757
|
+
const typeParameters = typeDeclaration.typeParameters;
|
|
758
|
+
if (typeParameters) {
|
|
759
|
+
this.visitNodes(typeParameters.annotations, p);
|
|
760
|
+
this.visitSpace(typeParameters.prefix, 136, p);
|
|
761
|
+
this.visitMarkers(typeParameters.markers, p);
|
|
762
|
+
p.append("<");
|
|
763
|
+
this.visitJRightPaddedLocal(typeParameters.padding.typeParameters, java_1.JRightPadded.Location.TYPE_PARAMETER, ",", p);
|
|
764
|
+
p.append(">");
|
|
765
|
+
}
|
|
766
|
+
this.visitJsLeftPaddedLocal("=", typeDeclaration.padding.initializer, _1.JsLeftPadded.Location.TYPE_DECLARATION_INITIALIZER, p);
|
|
767
|
+
this.afterSyntax(typeDeclaration, p);
|
|
768
|
+
return typeDeclaration;
|
|
769
|
+
}
|
|
770
|
+
visitLiteralType(literalType, p) {
|
|
771
|
+
this.beforeSyntax(literalType, _1.JsSpace.Location.LITERAL_TYPE_PREFIX, p);
|
|
772
|
+
this.visit(literalType.literal, p);
|
|
773
|
+
this.afterSyntax(literalType, p);
|
|
774
|
+
return literalType;
|
|
775
|
+
}
|
|
776
|
+
visitNamedImports(namedImports, p) {
|
|
777
|
+
this.beforeSyntax(namedImports, _1.JsSpace.Location.NAMED_IMPORTS_PREFIX, p);
|
|
778
|
+
this.visitJsContainerLocal("{", namedImports.padding.elements, _1.JsContainer.Location.NAMED_IMPORTS_ELEMENTS, ",", "}", p);
|
|
779
|
+
this.afterSyntax(namedImports, p);
|
|
780
|
+
return namedImports;
|
|
781
|
+
}
|
|
782
|
+
visitJsImportSpecifier(jis, p) {
|
|
783
|
+
this.beforeSyntax(jis, _1.JsSpace.Location.JS_IMPORT_SPECIFIER_PREFIX, p);
|
|
784
|
+
if (jis.importType) {
|
|
785
|
+
this.visitJsLeftPaddedLocal("type", jis.padding.importType, _1.JsLeftPadded.Location.JS_IMPORT_SPECIFIER_IMPORT_TYPE, p);
|
|
786
|
+
}
|
|
787
|
+
this.visit(jis.specifier, p);
|
|
788
|
+
this.afterSyntax(jis, p);
|
|
789
|
+
return jis;
|
|
790
|
+
}
|
|
791
|
+
visitExportDeclaration(ed, p) {
|
|
792
|
+
this.beforeSyntax(ed, _1.JsSpace.Location.EXPORT_DECLARATION_PREFIX, p);
|
|
793
|
+
p.append("export");
|
|
794
|
+
ed.modifiers.forEach(it => this.visitModifier(it, p));
|
|
795
|
+
if (ed.typeOnly) {
|
|
796
|
+
this.visitJsLeftPaddedLocal("type", ed.padding.typeOnly, _1.JsLeftPadded.Location.EXPORT_DECLARATION_TYPE_ONLY, p);
|
|
797
|
+
}
|
|
798
|
+
this.visit(ed.exportClause, p);
|
|
799
|
+
this.visitJsLeftPaddedLocal("from", ed.padding.moduleSpecifier, _1.JsLeftPadded.Location.EXPORT_DECLARATION_MODULE_SPECIFIER, p);
|
|
800
|
+
this.visit(ed.attributes, p);
|
|
801
|
+
this.afterSyntax(ed, p);
|
|
802
|
+
return ed;
|
|
803
|
+
}
|
|
804
|
+
visitExportAssignment(es, p) {
|
|
805
|
+
this.beforeSyntax(es, _1.JsSpace.Location.EXPORT_ASSIGNMENT_PREFIX, p);
|
|
806
|
+
p.append("export");
|
|
807
|
+
es.modifiers.forEach(it => this.visitModifier(it, p));
|
|
808
|
+
if (es.exportEquals) {
|
|
809
|
+
this.visitJsLeftPaddedLocal("=", es.padding.exportEquals, _1.JsLeftPadded.Location.EXPORT_ASSIGNMENT_EXPORT_EQUALS, p);
|
|
810
|
+
}
|
|
811
|
+
this.visit(es.expression, p);
|
|
812
|
+
this.afterSyntax(es, p);
|
|
813
|
+
return es;
|
|
814
|
+
}
|
|
815
|
+
visitIndexedAccessType(iat, p) {
|
|
816
|
+
this.beforeSyntax(iat, _1.JsSpace.Location.INDEXED_ACCESS_TYPE_PREFIX, p);
|
|
817
|
+
this.visit(iat.objectType, p);
|
|
818
|
+
this.visit(iat.indexType, p);
|
|
819
|
+
this.afterSyntax(iat, p);
|
|
820
|
+
return iat;
|
|
821
|
+
}
|
|
822
|
+
visitIndexedAccessTypeIndexType(iatit, p) {
|
|
823
|
+
this.beforeSyntax(iatit, _1.JsSpace.Location.INDEXED_ACCESS_TYPE_INDEX_TYPE_PREFIX, p);
|
|
824
|
+
p.append("[");
|
|
825
|
+
this.visitJsRightPadded(iatit.padding.element, _1.JsRightPadded.Location.INDEXED_ACCESS_TYPE_INDEX_TYPE_ELEMENT, p);
|
|
826
|
+
p.append("]");
|
|
827
|
+
this.afterSyntax(iatit, p);
|
|
828
|
+
return iatit;
|
|
829
|
+
}
|
|
830
|
+
visitWithStatement(withStatement, p) {
|
|
831
|
+
this.beforeSyntax(withStatement, _1.JsSpace.Location.WITH_STATEMENT_PREFIX, p);
|
|
832
|
+
p.append("with");
|
|
833
|
+
this.visit(withStatement.expression, p);
|
|
834
|
+
this.visitJsRightPadded(withStatement.padding.body, _1.JsRightPadded.Location.WITH_STATEMENT_BODY, p);
|
|
835
|
+
this.afterSyntax(withStatement, p);
|
|
836
|
+
return withStatement;
|
|
837
|
+
}
|
|
838
|
+
visitExportSpecifier(es, p) {
|
|
839
|
+
this.beforeSyntax(es, _1.JsSpace.Location.EXPORT_SPECIFIER_PREFIX, p);
|
|
840
|
+
if (es.typeOnly) {
|
|
841
|
+
this.visitJsLeftPaddedLocal("type", es.padding.typeOnly, _1.JsLeftPadded.Location.EXPORT_SPECIFIER_TYPE_ONLY, p);
|
|
842
|
+
}
|
|
843
|
+
this.visit(es.specifier, p);
|
|
844
|
+
this.afterSyntax(es, p);
|
|
845
|
+
return es;
|
|
846
|
+
}
|
|
847
|
+
visitNamedExports(ne, p) {
|
|
848
|
+
this.beforeSyntax(ne, _1.JsSpace.Location.NAMED_EXPORTS_PREFIX, p);
|
|
849
|
+
this.visitJsContainerLocal("{", ne.padding.elements, _1.JsContainer.Location.NAMED_EXPORTS_ELEMENTS, ",", "}", p);
|
|
850
|
+
this.afterSyntax(ne, p);
|
|
851
|
+
return ne;
|
|
852
|
+
}
|
|
853
|
+
visitImportAttributes(importAttributes, p) {
|
|
854
|
+
this.beforeSyntax(importAttributes, _1.JsSpace.Location.IMPORT_ATTRIBUTES_PREFIX, p);
|
|
855
|
+
p.append(JS.ImportAttributes.Token[importAttributes.token].toLowerCase());
|
|
856
|
+
this.visitJsContainerLocal("{", importAttributes.padding.elements, _1.JsContainer.Location.IMPORT_ATTRIBUTES_ELEMENTS, ",", "}", p);
|
|
857
|
+
this.afterSyntax(importAttributes, p);
|
|
858
|
+
return importAttributes;
|
|
859
|
+
}
|
|
860
|
+
visitImportAttribute(importAttribute, p) {
|
|
861
|
+
this.beforeSyntax(importAttribute, _1.JsSpace.Location.IMPORT_ATTRIBUTE_PREFIX, p);
|
|
862
|
+
this.visit(importAttribute.name, p);
|
|
863
|
+
this.visitJsLeftPaddedLocal(":", importAttribute.padding.value, _1.JsLeftPadded.Location.IMPORT_ATTRIBUTE_VALUE, p);
|
|
864
|
+
this.afterSyntax(importAttribute, p);
|
|
865
|
+
return importAttribute;
|
|
866
|
+
}
|
|
867
|
+
visitImportTypeAttributes(importAttributes, p) {
|
|
868
|
+
this.beforeSyntax(importAttributes, _1.JsSpace.Location.IMPORT_TYPE_ATTRIBUTES_PREFIX, p);
|
|
869
|
+
p.append("{");
|
|
870
|
+
this.visitJsRightPadded(importAttributes.padding.token, _1.JsRightPadded.Location.IMPORT_TYPE_ATTRIBUTES_TOKEN, p);
|
|
871
|
+
p.append(":");
|
|
872
|
+
this.visitJsContainerLocal("{", importAttributes.padding.elements, _1.JsContainer.Location.IMPORT_TYPE_ATTRIBUTES_ELEMENTS, ",", "}", p);
|
|
873
|
+
this.visitSpace(importAttributes.end, _1.JsSpace.Location.IMPORT_TYPE_ATTRIBUTES_END, p);
|
|
874
|
+
p.append("}");
|
|
875
|
+
this.afterSyntax(importAttributes, p);
|
|
876
|
+
return importAttributes;
|
|
877
|
+
}
|
|
878
|
+
visitArrayBindingPattern(abp, p) {
|
|
879
|
+
this.beforeSyntax(abp, _1.JsSpace.Location.ARRAY_BINDING_PATTERN_PREFIX, p);
|
|
880
|
+
this.visitJsContainerLocal("[", abp.padding.elements, _1.JsContainer.Location.ARRAY_BINDING_PATTERN_ELEMENTS, ",", "]", p);
|
|
881
|
+
this.afterSyntax(abp, p);
|
|
882
|
+
return abp;
|
|
883
|
+
}
|
|
884
|
+
visitMappedType(mappedType, p) {
|
|
885
|
+
this.beforeSyntax(mappedType, _1.JsSpace.Location.MAPPED_TYPE_PREFIX, p);
|
|
886
|
+
p.append("{");
|
|
887
|
+
if (mappedType.prefixToken != null) {
|
|
888
|
+
this.visitJsLeftPadded(mappedType.padding.prefixToken, _1.JsLeftPadded.Location.MAPPED_TYPE_PREFIX_TOKEN, p);
|
|
889
|
+
}
|
|
890
|
+
if (mappedType.hasReadonly) {
|
|
891
|
+
this.visitJsLeftPaddedLocal("readonly", mappedType.padding.hasReadonly, _1.JsLeftPadded.Location.MAPPED_TYPE_HAS_READONLY, p);
|
|
892
|
+
}
|
|
893
|
+
this.visitMappedTypeKeysRemapping(mappedType.keysRemapping, p);
|
|
894
|
+
if (mappedType.suffixToken != null) {
|
|
895
|
+
this.visitJsLeftPadded(mappedType.padding.suffixToken, _1.JsLeftPadded.Location.MAPPED_TYPE_SUFFIX_TOKEN, p);
|
|
896
|
+
}
|
|
897
|
+
if (mappedType.hasQuestionToken) {
|
|
898
|
+
this.visitJsLeftPaddedLocal("?", mappedType.padding.hasQuestionToken, _1.JsLeftPadded.Location.MAPPED_TYPE_HAS_QUESTION_TOKEN, p);
|
|
899
|
+
}
|
|
900
|
+
const colon = mappedType.valueType[0] instanceof J.Empty ? "" : ":";
|
|
901
|
+
this.visitJsContainerLocal(colon, mappedType.padding.valueType, _1.JsContainer.Location.MAPPED_TYPE_VALUE_TYPE, "", "", p);
|
|
902
|
+
p.append("}");
|
|
903
|
+
this.afterSyntax(mappedType, p);
|
|
904
|
+
return mappedType;
|
|
905
|
+
}
|
|
906
|
+
visitMappedTypeKeysRemapping(mappedTypeKeys, p) {
|
|
907
|
+
this.beforeSyntax(mappedTypeKeys, _1.JsSpace.Location.MAPPED_TYPE_KEYS_REMAPPING_PREFIX, p);
|
|
908
|
+
p.append("[");
|
|
909
|
+
this.visitJsRightPadded(mappedTypeKeys.padding.typeParameter, _1.JsRightPadded.Location.MAPPED_TYPE_KEYS_REMAPPING_TYPE_PARAMETER, p);
|
|
910
|
+
if (mappedTypeKeys.nameType != null) {
|
|
911
|
+
p.append("as");
|
|
912
|
+
this.visitJsRightPadded(mappedTypeKeys.padding.nameType, _1.JsRightPadded.Location.MAPPED_TYPE_KEYS_REMAPPING_NAME_TYPE, p);
|
|
913
|
+
}
|
|
914
|
+
p.append("]");
|
|
915
|
+
this.afterSyntax(mappedTypeKeys, p);
|
|
916
|
+
return mappedTypeKeys;
|
|
917
|
+
}
|
|
918
|
+
visitMappedTypeMappedTypeParameter(mappedTypeParameter, p) {
|
|
919
|
+
this.beforeSyntax(mappedTypeParameter, _1.JsSpace.Location.MAPPED_TYPE_MAPPED_TYPE_PARAMETER_PREFIX, p);
|
|
920
|
+
this.visit(mappedTypeParameter.name, p);
|
|
921
|
+
this.visitJsLeftPaddedLocal("in", mappedTypeParameter.padding.iterateType, _1.JsLeftPadded.Location.MAPPED_TYPE_MAPPED_TYPE_PARAMETER_ITERATE_TYPE, p);
|
|
922
|
+
this.afterSyntax(mappedTypeParameter, p);
|
|
923
|
+
return mappedTypeParameter;
|
|
924
|
+
}
|
|
925
|
+
visitObjectBindingDeclarations(objectBindingDeclarations, p) {
|
|
926
|
+
this.beforeSyntax(objectBindingDeclarations, _1.JsSpace.Location.OBJECT_BINDING_DECLARATIONS_PREFIX, p);
|
|
927
|
+
this.visitNodes(objectBindingDeclarations.leadingAnnotations, p);
|
|
928
|
+
objectBindingDeclarations.modifiers.forEach(m => this.visitModifier(m, p));
|
|
929
|
+
this.visit(objectBindingDeclarations.typeExpression, p);
|
|
930
|
+
this.visitJsContainerLocal("{", objectBindingDeclarations.padding.bindings, _1.JsContainer.Location.OBJECT_BINDING_DECLARATIONS_BINDINGS, ",", "}", p);
|
|
931
|
+
this.visitJsLeftPaddedLocal("=", objectBindingDeclarations.padding.initializer, _1.JsLeftPadded.Location.OBJECT_BINDING_DECLARATIONS_INITIALIZER, p);
|
|
932
|
+
this.afterSyntax(objectBindingDeclarations, p);
|
|
933
|
+
return objectBindingDeclarations;
|
|
934
|
+
}
|
|
935
|
+
visitTaggedTemplateExpression(taggedTemplateExpression, p) {
|
|
936
|
+
this.beforeSyntax(taggedTemplateExpression, _1.JsSpace.Location.TAGGED_TEMPLATE_EXPRESSION_PREFIX, p);
|
|
937
|
+
this.visitJsRightPadded(taggedTemplateExpression.padding.tag, _1.JsRightPadded.Location.TAGGED_TEMPLATE_EXPRESSION_TAG, p);
|
|
938
|
+
this.visitJsContainerLocal("<", taggedTemplateExpression.padding.typeArguments, _1.JsContainer.Location.TAGGED_TEMPLATE_EXPRESSION_TYPE_ARGUMENTS, ",", ">", p);
|
|
939
|
+
this.visit(taggedTemplateExpression.templateExpression, p);
|
|
940
|
+
this.afterSyntax(taggedTemplateExpression, p);
|
|
941
|
+
return taggedTemplateExpression;
|
|
942
|
+
}
|
|
943
|
+
visitTemplateExpression(templateExpression, p) {
|
|
944
|
+
this.beforeSyntax(templateExpression, _1.JsSpace.Location.TEMPLATE_EXPRESSION_PREFIX, p);
|
|
945
|
+
this.visit(templateExpression.head, p);
|
|
946
|
+
this.visitJsRightPaddedLocal(templateExpression.padding.templateSpans, _1.JsRightPadded.Location.TEMPLATE_EXPRESSION_TEMPLATE_SPANS, "", p);
|
|
947
|
+
this.afterSyntax(templateExpression, p);
|
|
948
|
+
return templateExpression;
|
|
949
|
+
}
|
|
950
|
+
visitTemplateExpressionTemplateSpan(value, p) {
|
|
951
|
+
this.beforeSyntax(value, _1.JsSpace.Location.TEMPLATE_EXPRESSION_TEMPLATE_SPAN_PREFIX, p);
|
|
952
|
+
this.visit(value.expression, p);
|
|
953
|
+
this.visit(value.tail, p);
|
|
954
|
+
this.afterSyntax(value, p);
|
|
955
|
+
return value;
|
|
956
|
+
}
|
|
957
|
+
visitTuple(tuple, p) {
|
|
958
|
+
this.beforeSyntax(tuple, _1.JsSpace.Location.TUPLE_PREFIX, p);
|
|
959
|
+
this.visitJsContainerLocal("[", tuple.padding.elements, _1.JsContainer.Location.TUPLE_ELEMENTS, ",", "]", p);
|
|
960
|
+
this.afterSyntax(tuple, p);
|
|
961
|
+
return tuple;
|
|
962
|
+
}
|
|
963
|
+
visitTypeQuery(typeQuery, p) {
|
|
964
|
+
this.beforeSyntax(typeQuery, _1.JsSpace.Location.TYPE_QUERY_PREFIX, p);
|
|
965
|
+
p.append("typeof");
|
|
966
|
+
this.visit(typeQuery.typeExpression, p);
|
|
967
|
+
this.visitJsContainerLocal("<", typeQuery.padding.typeArguments, _1.JsContainer.Location.TYPE_QUERY_TYPE_ARGUMENTS, ",", ">", p);
|
|
968
|
+
this.afterSyntax(typeQuery, p);
|
|
969
|
+
return typeQuery;
|
|
970
|
+
}
|
|
971
|
+
visitTypeOf(typeOf, p) {
|
|
972
|
+
this.beforeSyntax(typeOf, _1.JsSpace.Location.TYPE_OF_PREFIX, p);
|
|
973
|
+
p.append("typeof");
|
|
974
|
+
this.visit(typeOf.expression, p);
|
|
975
|
+
this.afterSyntax(typeOf, p);
|
|
976
|
+
return typeOf;
|
|
977
|
+
}
|
|
978
|
+
visitTypeOperator(typeOperator, p) {
|
|
979
|
+
this.beforeSyntax(typeOperator, _1.JsSpace.Location.TYPE_OPERATOR_PREFIX, p);
|
|
980
|
+
let keyword = "";
|
|
981
|
+
if (typeOperator.operator === JS.TypeOperator.Type.ReadOnly) {
|
|
982
|
+
keyword = "readonly";
|
|
983
|
+
}
|
|
984
|
+
else if (typeOperator.operator === JS.TypeOperator.Type.KeyOf) {
|
|
985
|
+
keyword = "keyof";
|
|
986
|
+
}
|
|
987
|
+
else if (typeOperator.operator === JS.TypeOperator.Type.Unique) {
|
|
988
|
+
keyword = "unique";
|
|
989
|
+
}
|
|
990
|
+
p.append(keyword);
|
|
991
|
+
this.visitJsLeftPadded(typeOperator.padding.expression, _1.JsLeftPadded.Location.TYPE_OPERATOR_EXPRESSION, p);
|
|
992
|
+
this.afterSyntax(typeOperator, p);
|
|
993
|
+
return typeOperator;
|
|
994
|
+
}
|
|
995
|
+
visitTypePredicate(typePredicate, p) {
|
|
996
|
+
this.beforeSyntax(typePredicate, _1.JsSpace.Location.TYPE_PREDICATE_PREFIX, p);
|
|
997
|
+
if (typePredicate.asserts) {
|
|
998
|
+
this.visitJsLeftPaddedLocal("asserts", typePredicate.padding.asserts, _1.JsLeftPadded.Location.TYPE_PREDICATE_ASSERTS, p);
|
|
999
|
+
}
|
|
1000
|
+
this.visit(typePredicate.parameterName, p);
|
|
1001
|
+
this.visitJsLeftPaddedLocal("is", typePredicate.padding.expression, _1.JsLeftPadded.Location.TYPE_PREDICATE_EXPRESSION, p);
|
|
1002
|
+
this.afterSyntax(typePredicate, p);
|
|
1003
|
+
return typePredicate;
|
|
1004
|
+
}
|
|
1005
|
+
visitIndexSignatureDeclaration(isd, p) {
|
|
1006
|
+
this.beforeSyntax(isd, _1.JsSpace.Location.INDEX_SIGNATURE_DECLARATION_PREFIX, p);
|
|
1007
|
+
isd.modifiers.forEach(m => this.visitModifier(m, p));
|
|
1008
|
+
this.visitJsContainerLocal("[", isd.padding.parameters, _1.JsContainer.Location.INDEX_SIGNATURE_DECLARATION_PARAMETERS, "", "]", p);
|
|
1009
|
+
this.visitJsLeftPaddedLocal(":", isd.padding.typeExpression, _1.JsLeftPadded.Location.INDEX_SIGNATURE_DECLARATION_TYPE_EXPRESSION, p);
|
|
1010
|
+
this.afterSyntax(isd, p);
|
|
1011
|
+
return isd;
|
|
1012
|
+
}
|
|
1013
|
+
visitAnnotation(annotation, p) {
|
|
1014
|
+
this.beforeSyntax(annotation, 5, p);
|
|
1015
|
+
p.append("@");
|
|
1016
|
+
this.visit(annotation.annotationType, p);
|
|
1017
|
+
this.visitJContainerLocal("(", annotation.padding.arguments, java_1.JContainer.Location.ANNOTATION_ARGUMENTS, ",", ")", p);
|
|
1018
|
+
this.afterSyntax(annotation, p);
|
|
1019
|
+
return annotation;
|
|
1020
|
+
}
|
|
1021
|
+
visitNewArray(newArray, p) {
|
|
1022
|
+
this.beforeSyntax(newArray, 98, p);
|
|
1023
|
+
this.visit(newArray.typeExpression, p);
|
|
1024
|
+
this.visitNodes(newArray.dimensions, p);
|
|
1025
|
+
this.visitJContainerLocal("[", newArray.padding.initializer, java_1.JContainer.Location.NEW_ARRAY_INITIALIZER, ",", "]", p);
|
|
1026
|
+
this.afterSyntax(newArray, p);
|
|
1027
|
+
return newArray;
|
|
1028
|
+
}
|
|
1029
|
+
visitNewClass(newClass, p) {
|
|
1030
|
+
this.beforeSyntax(newClass, 102, p);
|
|
1031
|
+
this.visitJRightPaddedLocalSingle(newClass.padding.enclosing, java_1.JRightPadded.Location.NEW_CLASS_ENCLOSING, ".", p);
|
|
1032
|
+
this.visitSpace(newClass.new, 103, p);
|
|
1033
|
+
if (newClass.clazz) {
|
|
1034
|
+
p.append("new");
|
|
1035
|
+
this.visit(newClass.clazz, p);
|
|
1036
|
+
if (!newClass.padding.arguments.markers.findFirst(J.OmitParentheses)) {
|
|
1037
|
+
this.visitJContainerLocal("(", newClass.padding.arguments, java_1.JContainer.Location.NEW_CLASS_ARGUMENTS, ",", ")", p);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
this.visit(newClass.body, p);
|
|
1041
|
+
this.afterSyntax(newClass, p);
|
|
1042
|
+
return newClass;
|
|
1043
|
+
}
|
|
1044
|
+
visitSwitch(switch_, p) {
|
|
1045
|
+
this.beforeSyntax(switch_, 119, p);
|
|
1046
|
+
p.append("switch");
|
|
1047
|
+
this.visit(switch_.selector, p);
|
|
1048
|
+
this.visit(switch_.cases, p);
|
|
1049
|
+
this.afterSyntax(switch_, p);
|
|
1050
|
+
return switch_;
|
|
1051
|
+
}
|
|
1052
|
+
visitCase(case_, p) {
|
|
1053
|
+
this.beforeSyntax(case_, 23, p);
|
|
1054
|
+
const elem = case_.caseLabels[0];
|
|
1055
|
+
if (!(elem instanceof J.Identifier) || elem.simpleName !== "default") {
|
|
1056
|
+
p.append("case");
|
|
1057
|
+
}
|
|
1058
|
+
this.visitJContainerLocal("", case_.padding.caseLabels, java_1.JContainer.Location.CASE_CASE_LABELS, ",", "", p);
|
|
1059
|
+
this.visitSpace(case_.padding.statements.before, 22, p);
|
|
1060
|
+
p.append(case_.type === J.Case.Type.Statement ? ":" : "->");
|
|
1061
|
+
this.visitStatements(case_.padding.statements.padding.elements, java_1.JRightPadded.Location.CASE, p);
|
|
1062
|
+
this.afterSyntax(case_, p);
|
|
1063
|
+
return case_;
|
|
1064
|
+
}
|
|
1065
|
+
visitLabel(label, p) {
|
|
1066
|
+
this.beforeSyntax(label, 73, p);
|
|
1067
|
+
this.visitJRightPaddedLocalSingle(label.padding.label, java_1.JRightPadded.Location.LABEL, ":", p);
|
|
1068
|
+
this.visit(label.statement, p);
|
|
1069
|
+
this.afterSyntax(label, p);
|
|
1070
|
+
return label;
|
|
1071
|
+
}
|
|
1072
|
+
visitContinue(continueStatement, p) {
|
|
1073
|
+
this.beforeSyntax(continueStatement, 35, p);
|
|
1074
|
+
p.append("continue");
|
|
1075
|
+
this.visit(continueStatement.label, p);
|
|
1076
|
+
this.afterSyntax(continueStatement, p);
|
|
1077
|
+
return continueStatement;
|
|
1078
|
+
}
|
|
1079
|
+
visitBreak(breakStatement, p) {
|
|
1080
|
+
this.beforeSyntax(breakStatement, 21, p);
|
|
1081
|
+
p.append("break");
|
|
1082
|
+
this.visit(breakStatement.label, p);
|
|
1083
|
+
this.afterSyntax(breakStatement, p);
|
|
1084
|
+
return breakStatement;
|
|
1085
|
+
}
|
|
1086
|
+
visitFieldAccess(fieldAccess, p) {
|
|
1087
|
+
this.beforeSyntax(fieldAccess, 49, p);
|
|
1088
|
+
this.visit(fieldAccess.target, p);
|
|
1089
|
+
this.visitJLeftPaddedLocal(".", fieldAccess.padding.name, java_1.JLeftPadded.Location.FIELD_ACCESS_NAME, p);
|
|
1090
|
+
this.afterSyntax(fieldAccess, p);
|
|
1091
|
+
return fieldAccess;
|
|
1092
|
+
}
|
|
1093
|
+
visitTypeLiteral(tl, p) {
|
|
1094
|
+
this.beforeSyntax(tl, _1.JsSpace.Location.TYPE_LITERAL_PREFIX, p);
|
|
1095
|
+
this.visit(tl.members, p);
|
|
1096
|
+
this.afterSyntax(tl, p);
|
|
1097
|
+
return tl;
|
|
1098
|
+
}
|
|
1099
|
+
visitParentheses(parens, p) {
|
|
1100
|
+
this.beforeSyntax(parens, 109, p);
|
|
1101
|
+
p.append('(');
|
|
1102
|
+
this.visitJRightPaddedLocalSingle(parens.padding.tree, java_1.JRightPadded.Location.PARENTHESES, ")", p);
|
|
1103
|
+
this.afterSyntax(parens, p);
|
|
1104
|
+
return parens;
|
|
1105
|
+
}
|
|
1106
|
+
visitParameterizedType(type, p) {
|
|
1107
|
+
this.beforeSyntax(type, 108, p);
|
|
1108
|
+
this.visit(type.clazz, p);
|
|
1109
|
+
this.visitJContainerLocal("<", type.padding.typeParameters, java_1.JContainer.Location.TYPE_PARAMETERS, ",", ">", p);
|
|
1110
|
+
this.afterSyntax(type, p);
|
|
1111
|
+
return type;
|
|
1112
|
+
}
|
|
1113
|
+
visitAssignment(assignment, p) {
|
|
1114
|
+
this.beforeSyntax(assignment, 15, p);
|
|
1115
|
+
this.visit(assignment.variable, p);
|
|
1116
|
+
this.visitJLeftPaddedLocal("=", assignment.padding.assignment, java_1.JLeftPadded.Location.ASSIGNMENT, p);
|
|
1117
|
+
this.afterSyntax(assignment, p);
|
|
1118
|
+
return assignment;
|
|
1119
|
+
}
|
|
1120
|
+
visitPropertyAssignment(propertyAssignment, p) {
|
|
1121
|
+
this.beforeSyntax(propertyAssignment, _1.JsSpace.Location.PROPERTY_ASSIGNMENT_PREFIX, p);
|
|
1122
|
+
this.visitJsRightPadded(propertyAssignment.padding.name, _1.JsRightPadded.Location.PROPERTY_ASSIGNMENT_NAME, p);
|
|
1123
|
+
if (propertyAssignment.initializer) {
|
|
1124
|
+
if (propertyAssignment.assigmentToken === JS.PropertyAssignment.AssigmentToken.Colon) {
|
|
1125
|
+
p.append(':');
|
|
1126
|
+
}
|
|
1127
|
+
else if (propertyAssignment.assigmentToken === JS.PropertyAssignment.AssigmentToken.Equals) {
|
|
1128
|
+
p.append('=');
|
|
1129
|
+
}
|
|
1130
|
+
this.visit(propertyAssignment.initializer, p);
|
|
1131
|
+
}
|
|
1132
|
+
this.afterSyntax(propertyAssignment, p);
|
|
1133
|
+
return propertyAssignment;
|
|
1134
|
+
}
|
|
1135
|
+
visitAssignmentOperation(assignOp, p) {
|
|
1136
|
+
let keyword = "";
|
|
1137
|
+
switch (assignOp.operator) {
|
|
1138
|
+
case J.AssignmentOperation.Type.Addition:
|
|
1139
|
+
keyword = "+=";
|
|
1140
|
+
break;
|
|
1141
|
+
case J.AssignmentOperation.Type.Subtraction:
|
|
1142
|
+
keyword = "-=";
|
|
1143
|
+
break;
|
|
1144
|
+
case J.AssignmentOperation.Type.Multiplication:
|
|
1145
|
+
keyword = "*=";
|
|
1146
|
+
break;
|
|
1147
|
+
case J.AssignmentOperation.Type.Division:
|
|
1148
|
+
keyword = "/=";
|
|
1149
|
+
break;
|
|
1150
|
+
case J.AssignmentOperation.Type.Modulo:
|
|
1151
|
+
keyword = "%=";
|
|
1152
|
+
break;
|
|
1153
|
+
case J.AssignmentOperation.Type.BitAnd:
|
|
1154
|
+
keyword = "&=";
|
|
1155
|
+
break;
|
|
1156
|
+
case J.AssignmentOperation.Type.BitOr:
|
|
1157
|
+
keyword = "|=";
|
|
1158
|
+
break;
|
|
1159
|
+
case J.AssignmentOperation.Type.BitXor:
|
|
1160
|
+
keyword = "^=";
|
|
1161
|
+
break;
|
|
1162
|
+
case J.AssignmentOperation.Type.LeftShift:
|
|
1163
|
+
keyword = "<<=";
|
|
1164
|
+
break;
|
|
1165
|
+
case J.AssignmentOperation.Type.RightShift:
|
|
1166
|
+
keyword = ">>=";
|
|
1167
|
+
break;
|
|
1168
|
+
case J.AssignmentOperation.Type.UnsignedRightShift:
|
|
1169
|
+
keyword = ">>>=";
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
this.beforeSyntax(assignOp, 13, p);
|
|
1173
|
+
this.visit(assignOp.variable, p);
|
|
1174
|
+
this.visitSpace(assignOp.padding.operator.before, 14, p);
|
|
1175
|
+
p.append(keyword);
|
|
1176
|
+
this.visit(assignOp.assignment, p);
|
|
1177
|
+
this.afterSyntax(assignOp, p);
|
|
1178
|
+
return assignOp;
|
|
1179
|
+
}
|
|
1180
|
+
visitJsAssignmentOperation(assignOp, p) {
|
|
1181
|
+
let keyword = "";
|
|
1182
|
+
switch (assignOp.operator) {
|
|
1183
|
+
case JS.JsAssignmentOperation.Type.QuestionQuestion:
|
|
1184
|
+
keyword = "??=";
|
|
1185
|
+
break;
|
|
1186
|
+
case JS.JsAssignmentOperation.Type.And:
|
|
1187
|
+
keyword = "&&=";
|
|
1188
|
+
break;
|
|
1189
|
+
case JS.JsAssignmentOperation.Type.Or:
|
|
1190
|
+
keyword = "||=";
|
|
1191
|
+
break;
|
|
1192
|
+
case JS.JsAssignmentOperation.Type.Power:
|
|
1193
|
+
keyword = "**";
|
|
1194
|
+
break;
|
|
1195
|
+
case JS.JsAssignmentOperation.Type.Exp:
|
|
1196
|
+
keyword = "**=";
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
this.beforeSyntax(assignOp, _1.JsSpace.Location.JS_ASSIGNMENT_OPERATION_PREFIX, p);
|
|
1200
|
+
this.visit(assignOp.variable, p);
|
|
1201
|
+
this.visitSpace(assignOp.padding.operator.before, _1.JsSpace.Location.JS_ASSIGNMENT_OPERATION_OPERATOR_PREFIX, p);
|
|
1202
|
+
p.append(keyword);
|
|
1203
|
+
this.visit(assignOp.assignment, p);
|
|
1204
|
+
this.afterSyntax(assignOp, p);
|
|
1205
|
+
return assignOp;
|
|
1206
|
+
}
|
|
1207
|
+
visitEnumValue(enum_, p) {
|
|
1208
|
+
this.beforeSyntax(enum_, 43, p);
|
|
1209
|
+
this.visit(enum_.name, p);
|
|
1210
|
+
const initializer = enum_.initializer;
|
|
1211
|
+
if (initializer) {
|
|
1212
|
+
this.visitSpace(initializer.prefix, 102, p);
|
|
1213
|
+
p.append("=");
|
|
1214
|
+
const expression = initializer.arguments[0];
|
|
1215
|
+
this.visit(expression, p);
|
|
1216
|
+
return enum_;
|
|
1217
|
+
}
|
|
1218
|
+
this.afterSyntax(enum_, p);
|
|
1219
|
+
return enum_;
|
|
1220
|
+
}
|
|
1221
|
+
visitEnumValueSet(enums, p) {
|
|
1222
|
+
this.beforeSyntax(enums, 44, p);
|
|
1223
|
+
this.visitJRightPaddedLocal(enums.padding.enums, java_1.JRightPadded.Location.ENUM_VALUE, ",", p);
|
|
1224
|
+
if (enums.terminatedWithSemicolon) {
|
|
1225
|
+
p.append(",");
|
|
1226
|
+
}
|
|
1227
|
+
this.afterSyntax(enums, p);
|
|
1228
|
+
return enums;
|
|
1229
|
+
}
|
|
1230
|
+
visitBinary(binary, p) {
|
|
1231
|
+
let keyword = "";
|
|
1232
|
+
switch (binary.operator) {
|
|
1233
|
+
case J.Binary.Type.Addition:
|
|
1234
|
+
keyword = "+";
|
|
1235
|
+
break;
|
|
1236
|
+
case J.Binary.Type.Subtraction:
|
|
1237
|
+
keyword = "-";
|
|
1238
|
+
break;
|
|
1239
|
+
case J.Binary.Type.Multiplication:
|
|
1240
|
+
keyword = "*";
|
|
1241
|
+
break;
|
|
1242
|
+
case J.Binary.Type.Division:
|
|
1243
|
+
keyword = "/";
|
|
1244
|
+
break;
|
|
1245
|
+
case J.Binary.Type.Modulo:
|
|
1246
|
+
keyword = "%";
|
|
1247
|
+
break;
|
|
1248
|
+
case J.Binary.Type.LessThan:
|
|
1249
|
+
keyword = "<";
|
|
1250
|
+
break;
|
|
1251
|
+
case J.Binary.Type.GreaterThan:
|
|
1252
|
+
keyword = ">";
|
|
1253
|
+
break;
|
|
1254
|
+
case J.Binary.Type.LessThanOrEqual:
|
|
1255
|
+
keyword = "<=";
|
|
1256
|
+
break;
|
|
1257
|
+
case J.Binary.Type.GreaterThanOrEqual:
|
|
1258
|
+
keyword = ">=";
|
|
1259
|
+
break;
|
|
1260
|
+
case J.Binary.Type.Equal:
|
|
1261
|
+
keyword = "==";
|
|
1262
|
+
break;
|
|
1263
|
+
case J.Binary.Type.NotEqual:
|
|
1264
|
+
keyword = "!=";
|
|
1265
|
+
break;
|
|
1266
|
+
case J.Binary.Type.BitAnd:
|
|
1267
|
+
keyword = "&";
|
|
1268
|
+
break;
|
|
1269
|
+
case J.Binary.Type.BitOr:
|
|
1270
|
+
keyword = "|";
|
|
1271
|
+
break;
|
|
1272
|
+
case J.Binary.Type.BitXor:
|
|
1273
|
+
keyword = "^";
|
|
1274
|
+
break;
|
|
1275
|
+
case J.Binary.Type.LeftShift:
|
|
1276
|
+
keyword = "<<";
|
|
1277
|
+
break;
|
|
1278
|
+
case J.Binary.Type.RightShift:
|
|
1279
|
+
keyword = ">>";
|
|
1280
|
+
break;
|
|
1281
|
+
case J.Binary.Type.UnsignedRightShift:
|
|
1282
|
+
keyword = ">>>";
|
|
1283
|
+
break;
|
|
1284
|
+
case J.Binary.Type.Or:
|
|
1285
|
+
keyword = "||";
|
|
1286
|
+
break;
|
|
1287
|
+
case J.Binary.Type.And:
|
|
1288
|
+
keyword = "&&";
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
this.beforeSyntax(binary, 17, p);
|
|
1292
|
+
this.visit(binary.left, p);
|
|
1293
|
+
this.visitSpace(binary.padding.operator.before, 16, p);
|
|
1294
|
+
p.append(keyword);
|
|
1295
|
+
this.visit(binary.right, p);
|
|
1296
|
+
this.afterSyntax(binary, p);
|
|
1297
|
+
return binary;
|
|
1298
|
+
}
|
|
1299
|
+
visitJsBinary(binary, p) {
|
|
1300
|
+
this.beforeSyntax(binary, _1.JsSpace.Location.JS_BINARY_PREFIX, p);
|
|
1301
|
+
this.visit(binary.left, p);
|
|
1302
|
+
let keyword = "";
|
|
1303
|
+
switch (binary.operator) {
|
|
1304
|
+
case JS.JsBinary.Type.As:
|
|
1305
|
+
keyword = "as";
|
|
1306
|
+
break;
|
|
1307
|
+
case JS.JsBinary.Type.IdentityEquals:
|
|
1308
|
+
keyword = "===";
|
|
1309
|
+
break;
|
|
1310
|
+
case JS.JsBinary.Type.IdentityNotEquals:
|
|
1311
|
+
keyword = "!==";
|
|
1312
|
+
break;
|
|
1313
|
+
case JS.JsBinary.Type.In:
|
|
1314
|
+
keyword = "in";
|
|
1315
|
+
break;
|
|
1316
|
+
case JS.JsBinary.Type.QuestionQuestion:
|
|
1317
|
+
keyword = "??";
|
|
1318
|
+
break;
|
|
1319
|
+
case JS.JsBinary.Type.Comma:
|
|
1320
|
+
keyword = ",";
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
this.visitSpace(binary.padding.operator.before, _1.JsSpace.Location.JS_BINARY_OPERATOR, p);
|
|
1324
|
+
p.append(keyword);
|
|
1325
|
+
this.visit(binary.right, p);
|
|
1326
|
+
this.afterSyntax(binary, p);
|
|
1327
|
+
return binary;
|
|
1328
|
+
}
|
|
1329
|
+
visitUnary(unary, p) {
|
|
1330
|
+
this.beforeSyntax(unary, 140, p);
|
|
1331
|
+
switch (unary.operator) {
|
|
1332
|
+
case J.Unary.Type.PreIncrement:
|
|
1333
|
+
p.append("++");
|
|
1334
|
+
this.visit(unary.expression, p);
|
|
1335
|
+
break;
|
|
1336
|
+
case J.Unary.Type.PreDecrement:
|
|
1337
|
+
p.append("--");
|
|
1338
|
+
this.visit(unary.expression, p);
|
|
1339
|
+
break;
|
|
1340
|
+
case J.Unary.Type.PostIncrement:
|
|
1341
|
+
this.visit(unary.expression, p);
|
|
1342
|
+
this.visitSpace(unary.padding.operator.before, 139, p);
|
|
1343
|
+
p.append("++");
|
|
1344
|
+
break;
|
|
1345
|
+
case J.Unary.Type.PostDecrement:
|
|
1346
|
+
this.visit(unary.expression, p);
|
|
1347
|
+
this.visitSpace(unary.padding.operator.before, 139, p);
|
|
1348
|
+
p.append("--");
|
|
1349
|
+
break;
|
|
1350
|
+
case J.Unary.Type.Positive:
|
|
1351
|
+
p.append('+');
|
|
1352
|
+
this.visit(unary.expression, p);
|
|
1353
|
+
break;
|
|
1354
|
+
case J.Unary.Type.Negative:
|
|
1355
|
+
p.append('-');
|
|
1356
|
+
this.visit(unary.expression, p);
|
|
1357
|
+
break;
|
|
1358
|
+
case J.Unary.Type.Complement:
|
|
1359
|
+
p.append('~');
|
|
1360
|
+
this.visit(unary.expression, p);
|
|
1361
|
+
break;
|
|
1362
|
+
case J.Unary.Type.Not:
|
|
1363
|
+
default:
|
|
1364
|
+
p.append('!');
|
|
1365
|
+
this.visit(unary.expression, p);
|
|
1366
|
+
}
|
|
1367
|
+
this.afterSyntax(unary, p);
|
|
1368
|
+
return unary;
|
|
1369
|
+
}
|
|
1370
|
+
visitJsUnary(unary, p) {
|
|
1371
|
+
this.beforeSyntax(unary, _1.JsSpace.Location.UNARY_PREFIX, p);
|
|
1372
|
+
switch (unary.operator) {
|
|
1373
|
+
case JS.Unary.Type.Spread:
|
|
1374
|
+
this.visitSpace(unary.padding.operator.before, _1.JsSpace.Location.UNARY_OPERATOR, p);
|
|
1375
|
+
p.append("...");
|
|
1376
|
+
this.visit(unary.expression, p);
|
|
1377
|
+
break;
|
|
1378
|
+
case JS.Unary.Type.Optional:
|
|
1379
|
+
this.visit(unary.expression, p);
|
|
1380
|
+
this.visitSpace(unary.padding.operator.before, _1.JsSpace.Location.UNARY_OPERATOR, p);
|
|
1381
|
+
p.append("?");
|
|
1382
|
+
break;
|
|
1383
|
+
case JS.Unary.Type.Exclamation:
|
|
1384
|
+
this.visit(unary.expression, p);
|
|
1385
|
+
this.visitSpace(unary.padding.operator.before, _1.JsSpace.Location.UNARY_OPERATOR, p);
|
|
1386
|
+
p.append("!");
|
|
1387
|
+
break;
|
|
1388
|
+
case JS.Unary.Type.QuestionDot:
|
|
1389
|
+
this.visit(unary.expression, p);
|
|
1390
|
+
this.visitSpace(unary.padding.operator.before, _1.JsSpace.Location.UNARY_OPERATOR, p);
|
|
1391
|
+
p.append("?");
|
|
1392
|
+
break;
|
|
1393
|
+
case JS.Unary.Type.QuestionDotWithDot:
|
|
1394
|
+
this.visit(unary.expression, p);
|
|
1395
|
+
this.visitSpace(unary.padding.operator.before, _1.JsSpace.Location.UNARY_OPERATOR, p);
|
|
1396
|
+
p.append("?.");
|
|
1397
|
+
break;
|
|
1398
|
+
case JS.Unary.Type.Asterisk:
|
|
1399
|
+
p.append("*");
|
|
1400
|
+
this.visitSpace(unary.padding.operator.before, _1.JsSpace.Location.UNARY_OPERATOR, p);
|
|
1401
|
+
this.visit(unary.expression, p);
|
|
1402
|
+
break;
|
|
1403
|
+
default:
|
|
1404
|
+
break;
|
|
1405
|
+
}
|
|
1406
|
+
this.afterSyntax(unary, p);
|
|
1407
|
+
return unary;
|
|
1408
|
+
}
|
|
1409
|
+
visitUnion(union, p) {
|
|
1410
|
+
this.beforeSyntax(union, _1.JsSpace.Location.UNION_PREFIX, p);
|
|
1411
|
+
this.visitJsRightPaddedLocal(union.padding.types, _1.JsRightPadded.Location.UNION_TYPES, "|", p);
|
|
1412
|
+
this.afterSyntax(union, p);
|
|
1413
|
+
return union;
|
|
1414
|
+
}
|
|
1415
|
+
visitIntersection(intersection, p) {
|
|
1416
|
+
this.beforeSyntax(intersection, _1.JsSpace.Location.INTERSECTION_PREFIX, p);
|
|
1417
|
+
this.visitJsRightPaddedLocal(intersection.padding.types, _1.JsRightPadded.Location.INTERSECTION_TYPES, "&", p);
|
|
1418
|
+
this.afterSyntax(intersection, p);
|
|
1419
|
+
return intersection;
|
|
1420
|
+
}
|
|
1421
|
+
visitForLoop(forLoop, p) {
|
|
1422
|
+
this.beforeSyntax(forLoop, 58, p);
|
|
1423
|
+
p.append("for");
|
|
1424
|
+
const ctrl = forLoop.control;
|
|
1425
|
+
this.visitSpace(ctrl.prefix, 54, p);
|
|
1426
|
+
p.append('(');
|
|
1427
|
+
this.visitJRightPaddedLocal(ctrl.padding.init, java_1.JRightPadded.Location.FOR_INIT, ",", p);
|
|
1428
|
+
p.append(';');
|
|
1429
|
+
this.visitJRightPaddedLocalSingle(ctrl.padding.condition, java_1.JRightPadded.Location.FOR_CONDITION, ";", p);
|
|
1430
|
+
this.visitJRightPaddedLocal(ctrl.padding.update, java_1.JRightPadded.Location.FOR_UPDATE, ",", p);
|
|
1431
|
+
p.append(')');
|
|
1432
|
+
this.visitStatementLocal(forLoop.padding.body, java_1.JRightPadded.Location.FOR_BODY, p);
|
|
1433
|
+
this.afterSyntax(forLoop, p);
|
|
1434
|
+
return forLoop;
|
|
1435
|
+
}
|
|
1436
|
+
visitJSForOfLoop(loop, p) {
|
|
1437
|
+
this.beforeSyntax(loop, _1.JsSpace.Location.JSFOR_OF_LOOP_PREFIX, p);
|
|
1438
|
+
p.append("for");
|
|
1439
|
+
if (loop.await) {
|
|
1440
|
+
this.visitJsLeftPaddedLocal("await", loop.padding.await, _1.JsLeftPadded.Location.JSFOR_OF_LOOP_AWAIT, p);
|
|
1441
|
+
}
|
|
1442
|
+
const control = loop.control;
|
|
1443
|
+
this.visitSpace(control.prefix, _1.JsSpace.Location.JSFOR_IN_OF_LOOP_CONTROL_PREFIX, p);
|
|
1444
|
+
p.append('(');
|
|
1445
|
+
this.visitJsRightPadded(control.padding.variable, _1.JsRightPadded.Location.JSFOR_IN_OF_LOOP_CONTROL_VARIABLE, p);
|
|
1446
|
+
p.append("of");
|
|
1447
|
+
this.visitJsRightPadded(control.padding.iterable, _1.JsRightPadded.Location.JSFOR_IN_OF_LOOP_CONTROL_ITERABLE, p);
|
|
1448
|
+
p.append(')');
|
|
1449
|
+
this.visitJsRightPadded(loop.padding.body, _1.JsRightPadded.Location.JSFOR_OF_LOOP_BODY, p);
|
|
1450
|
+
this.afterSyntax(loop, p);
|
|
1451
|
+
return loop;
|
|
1452
|
+
}
|
|
1453
|
+
visitJSForInLoop(loop, p) {
|
|
1454
|
+
this.beforeSyntax(loop, _1.JsSpace.Location.JSFOR_IN_LOOP_PREFIX, p);
|
|
1455
|
+
p.append("for");
|
|
1456
|
+
const control = loop.control;
|
|
1457
|
+
this.visitSpace(control.prefix, _1.JsSpace.Location.JSFOR_IN_OF_LOOP_CONTROL_PREFIX, p);
|
|
1458
|
+
p.append('(');
|
|
1459
|
+
this.visitJsRightPadded(control.padding.variable, _1.JsRightPadded.Location.JSFOR_IN_OF_LOOP_CONTROL_VARIABLE, p);
|
|
1460
|
+
p.append("in");
|
|
1461
|
+
this.visitJsRightPadded(control.padding.iterable, _1.JsRightPadded.Location.JSFOR_IN_OF_LOOP_CONTROL_ITERABLE, p);
|
|
1462
|
+
p.append(')');
|
|
1463
|
+
this.visitJsRightPadded(loop.padding.body, _1.JsRightPadded.Location.JSFOR_IN_LOOP_BODY, p);
|
|
1464
|
+
this.afterSyntax(loop, p);
|
|
1465
|
+
return loop;
|
|
1466
|
+
}
|
|
1467
|
+
visitStatements(statements, location, p) {
|
|
1468
|
+
var _a, _b;
|
|
1469
|
+
const objectLiteral = ((_a = this.getParentCursor(0)) === null || _a === void 0 ? void 0 : _a.value()) instanceof J.Block &&
|
|
1470
|
+
((_b = this.getParentCursor(1)) === null || _b === void 0 ? void 0 : _b.value()) instanceof J.NewClass;
|
|
1471
|
+
for (let i = 0; i < statements.length; i++) {
|
|
1472
|
+
const paddedStat = statements[i];
|
|
1473
|
+
this.visitStatementLocal(paddedStat, location, p);
|
|
1474
|
+
if (i < statements.length - 1 && objectLiteral) {
|
|
1475
|
+
p.append(",");
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
visitStatementLocal(paddedStat, location, p) {
|
|
1480
|
+
if (paddedStat !== null) {
|
|
1481
|
+
this.visit(paddedStat.element, p);
|
|
1482
|
+
this.visitSpace(paddedStat.after, java_1.JRightPadded.Location.afterLocation(location), p);
|
|
1483
|
+
this.visitMarkers(paddedStat.markers, p);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
getParentCursor(levels) {
|
|
1487
|
+
let cursor = this.cursor;
|
|
1488
|
+
for (let i = 0; i < levels && cursor !== null; i++) {
|
|
1489
|
+
cursor = cursor.parent;
|
|
1490
|
+
}
|
|
1491
|
+
return cursor;
|
|
1492
|
+
}
|
|
1493
|
+
afterSyntax(j, p) {
|
|
1494
|
+
this.afterSyntaxMarkers(j.markers, p);
|
|
1495
|
+
}
|
|
1496
|
+
afterSyntaxMarkers(markers, p) {
|
|
1497
|
+
for (const marker of markers.markers) {
|
|
1498
|
+
p.out.concat(p.markerPrinter.afterSyntax(marker, new core_1.Cursor(this.cursor, marker), this.JAVA_SCRIPT_MARKER_WRAPPER));
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
beforeSyntax(j, loc, p) {
|
|
1502
|
+
this.beforeSyntaxExt(j.prefix, j.markers, loc, p);
|
|
1503
|
+
}
|
|
1504
|
+
beforeSyntaxExt(prefix, markers, loc, p) {
|
|
1505
|
+
for (const marker of markers.markers) {
|
|
1506
|
+
p.out.concat(p.markerPrinter.beforePrefix(marker, new core_1.Cursor(this.cursor, marker), this.JAVA_SCRIPT_MARKER_WRAPPER));
|
|
1507
|
+
}
|
|
1508
|
+
if (loc !== null) {
|
|
1509
|
+
this.visitSpace(prefix, loc, p);
|
|
1510
|
+
}
|
|
1511
|
+
this.visitMarkers(markers, p);
|
|
1512
|
+
for (const marker of markers.markers) {
|
|
1513
|
+
p.out.concat(p.markerPrinter.beforeSyntax(marker, new core_1.Cursor(this.cursor, marker), this.JAVA_SCRIPT_MARKER_WRAPPER));
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
visitSpace(space, loc, p) {
|
|
1517
|
+
p.append(space.whitespace);
|
|
1518
|
+
const comments = space.comments;
|
|
1519
|
+
for (let i = 0; i < comments.length; i++) {
|
|
1520
|
+
const comment = comments[i];
|
|
1521
|
+
this.visitMarkers(comment.markers, p);
|
|
1522
|
+
this.printComment(comment, this.cursor, p);
|
|
1523
|
+
p.append(comment.suffix);
|
|
1524
|
+
}
|
|
1525
|
+
return space;
|
|
1526
|
+
}
|
|
1527
|
+
visitJRightPaddedLocal(nodes, location, suffixBetween, p) {
|
|
1528
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1529
|
+
const node = nodes[i];
|
|
1530
|
+
this.visit(node.element, p);
|
|
1531
|
+
if (location) {
|
|
1532
|
+
const loc = java_1.JRightPadded.Location.afterLocation(location);
|
|
1533
|
+
this.visitSpace(node.after, loc, p);
|
|
1534
|
+
}
|
|
1535
|
+
this.visitMarkers(node.markers, p);
|
|
1536
|
+
if (i < nodes.length - 1) {
|
|
1537
|
+
p.append(suffixBetween);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
visitJRightPaddedLocalSingle(node, location, suffix, p) {
|
|
1542
|
+
if (node) {
|
|
1543
|
+
this.visit(node.element, p);
|
|
1544
|
+
if (location) {
|
|
1545
|
+
const loc = java_1.JRightPadded.Location.afterLocation(location);
|
|
1546
|
+
this.visitSpace(node.after, loc, p);
|
|
1547
|
+
}
|
|
1548
|
+
this.visitMarkers(node.markers, p);
|
|
1549
|
+
p.append(suffix);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
visitJsRightPaddedLocal(nodes, location, suffixBetween, p) {
|
|
1553
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1554
|
+
const node = nodes[i];
|
|
1555
|
+
this.visit(node.element, p);
|
|
1556
|
+
if (location) {
|
|
1557
|
+
const loc = _1.JsRightPadded.Location.afterLocation(location);
|
|
1558
|
+
this.visitSpace(node.after, loc, p);
|
|
1559
|
+
}
|
|
1560
|
+
this.visitMarkers(node.markers, p);
|
|
1561
|
+
if (i < nodes.length - 1) {
|
|
1562
|
+
p.append(suffixBetween);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
visitJsRightPaddedLocalSingle(node, location, suffix, p) {
|
|
1567
|
+
if (node) {
|
|
1568
|
+
this.visit(node.element, p);
|
|
1569
|
+
if (location) {
|
|
1570
|
+
const loc = _1.JsRightPadded.Location.afterLocation(location);
|
|
1571
|
+
this.visitSpace(node.after, loc, p);
|
|
1572
|
+
}
|
|
1573
|
+
this.visitMarkers(node.markers, p);
|
|
1574
|
+
p.append(suffix);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
visitJLeftPaddedLocal(prefix, leftPadded, location, p) {
|
|
1578
|
+
if (leftPadded) {
|
|
1579
|
+
const loc = java_1.JLeftPadded.Location.beforeLocation(location);
|
|
1580
|
+
this.beforeSyntaxExt(leftPadded.before, leftPadded.markers, loc, p);
|
|
1581
|
+
if (prefix) {
|
|
1582
|
+
p.append(prefix);
|
|
1583
|
+
}
|
|
1584
|
+
if (typeof leftPadded.element !== 'boolean') {
|
|
1585
|
+
this.visit(leftPadded.element, p);
|
|
1586
|
+
}
|
|
1587
|
+
this.afterSyntaxMarkers(leftPadded.markers, p);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
visitJsLeftPaddedLocal(prefix, leftPadded, location, p) {
|
|
1591
|
+
if (leftPadded) {
|
|
1592
|
+
const loc = _1.JsLeftPadded.Location.beforeLocation(location);
|
|
1593
|
+
this.beforeSyntaxExt(leftPadded.before, leftPadded.markers, loc, p);
|
|
1594
|
+
if (prefix) {
|
|
1595
|
+
p.append(prefix);
|
|
1596
|
+
}
|
|
1597
|
+
if (typeof leftPadded.element !== 'boolean') {
|
|
1598
|
+
this.visit(leftPadded.element, p);
|
|
1599
|
+
}
|
|
1600
|
+
this.afterSyntaxMarkers(leftPadded.markers, p);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
visitJContainerLocal(before, container, location, suffixBetween, after, p) {
|
|
1604
|
+
if (container === null) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
const beforeLocation = java_1.JContainer.Location.beforeLocation(location);
|
|
1608
|
+
const elementLocation = java_1.JContainer.Location.elementLocation(location);
|
|
1609
|
+
this.beforeSyntaxExt(container.before, container.markers, beforeLocation, p);
|
|
1610
|
+
p.append(before);
|
|
1611
|
+
this.visitJRightPaddedLocal(container.padding.elements, elementLocation, suffixBetween, p);
|
|
1612
|
+
this.afterSyntaxMarkers(container.markers, p);
|
|
1613
|
+
p.append(after === null ? "" : after);
|
|
1614
|
+
}
|
|
1615
|
+
visitJsContainerLocal(before, container, location, suffixBetween, after, p) {
|
|
1616
|
+
if (container === null) {
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
const beforeLocation = _1.JsContainer.Location.beforeLocation(location);
|
|
1620
|
+
const elementLocation = _1.JsContainer.Location.elementLocation(location);
|
|
1621
|
+
this.beforeSyntaxExt(container.before, container.markers, beforeLocation, p);
|
|
1622
|
+
p.append(before);
|
|
1623
|
+
this.visitJsRightPaddedLocal(container.padding.elements, elementLocation, suffixBetween, p);
|
|
1624
|
+
this.afterSyntaxMarkers(container.markers, p);
|
|
1625
|
+
p.append(after === null ? "" : after);
|
|
1626
|
+
}
|
|
1627
|
+
visitMarker(marker, p) {
|
|
1628
|
+
if (marker instanceof java_1.Semicolon) {
|
|
1629
|
+
p.append(';');
|
|
1630
|
+
}
|
|
1631
|
+
if (marker instanceof java_1.TrailingComma) {
|
|
1632
|
+
p.append(',');
|
|
1633
|
+
this.visitSpace(marker.suffix, 155, p);
|
|
1634
|
+
}
|
|
1635
|
+
return marker;
|
|
1636
|
+
}
|
|
1637
|
+
printComment(comment, cursor, p) {
|
|
1638
|
+
for (const marker of comment.markers.markers) {
|
|
1639
|
+
p.append(p.markerPrinter.beforeSyntax(marker, new core_1.Cursor(cursor, this), this.JAVA_SCRIPT_MARKER_WRAPPER));
|
|
1640
|
+
}
|
|
1641
|
+
if (comment instanceof J.TextComment) {
|
|
1642
|
+
p.append(comment.multiline ? `/*${comment.text}*/` : `//${comment.text}`);
|
|
1643
|
+
}
|
|
1644
|
+
for (const marker of comment.markers.markers) {
|
|
1645
|
+
p.append(p.markerPrinter.afterSyntax(marker, new core_1.Cursor(cursor, this), this.JAVA_SCRIPT_MARKER_WRAPPER));
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
visitNodes(nodes, p) {
|
|
1649
|
+
if (nodes) {
|
|
1650
|
+
for (const node of nodes) {
|
|
1651
|
+
this.visit(node, p);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
visitControlParentheses(controlParens, p) {
|
|
1656
|
+
var _a;
|
|
1657
|
+
this.beforeSyntax(controlParens, 36, p);
|
|
1658
|
+
if (((_a = this.getParentCursor(1)) === null || _a === void 0 ? void 0 : _a.value()) instanceof J.TypeCast) {
|
|
1659
|
+
p.append('<');
|
|
1660
|
+
this.visitJRightPaddedLocalSingle(controlParens.padding.tree, java_1.JRightPadded.Location.PARENTHESES, ">", p);
|
|
1661
|
+
}
|
|
1662
|
+
else {
|
|
1663
|
+
p.append('(');
|
|
1664
|
+
this.visitJRightPaddedLocalSingle(controlParens.padding.tree, java_1.JRightPadded.Location.PARENTHESES, ")", p);
|
|
1665
|
+
}
|
|
1666
|
+
this.afterSyntax(controlParens, p);
|
|
1667
|
+
return controlParens;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
exports.JavaScriptPrinter = JavaScriptPrinter;
|
|
1671
|
+
//# sourceMappingURL=printer.js.map
|