@openrewrite/rewrite 8.66.0-SNAPSHOT → 8.67.0-20251103-160333
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/javascript/comparator.d.ts +24 -1
- package/dist/javascript/comparator.d.ts.map +1 -1
- package/dist/javascript/comparator.js +532 -673
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +4 -5
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/print.d.ts +2 -2
- package/dist/javascript/print.d.ts.map +1 -1
- package/dist/javascript/print.js +4 -4
- package/dist/javascript/print.js.map +1 -1
- package/dist/javascript/templating.d.ts.map +1 -1
- package/dist/javascript/templating.js +111 -153
- package/dist/javascript/templating.js.map +1 -1
- package/dist/test/rewrite-test.d.ts.map +1 -1
- package/dist/test/rewrite-test.js +65 -9
- package/dist/test/rewrite-test.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +1 -2
- package/src/javascript/comparator.ts +553 -670
- package/src/javascript/parser.ts +4 -5
- package/src/javascript/print.ts +6 -6
- package/src/javascript/templating.ts +110 -161
- package/src/test/rewrite-test.ts +65 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import {JavaScriptVisitor} from './visitor';
|
|
17
|
-
import {J} from '../java';
|
|
17
|
+
import {J, Type} from '../java';
|
|
18
18
|
import {JS, JSX} from './tree';
|
|
19
19
|
import {Cursor, Tree} from "../tree";
|
|
20
20
|
|
|
@@ -63,8 +63,9 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
63
63
|
/**
|
|
64
64
|
* Aborts the visit operation by setting the match flag to false.
|
|
65
65
|
*/
|
|
66
|
-
protected abort():
|
|
66
|
+
protected abort<T>(t: T): T {
|
|
67
67
|
this.match = false;
|
|
68
|
+
return t;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
override async visit<R extends J>(j: Tree, p: J, parent?: Cursor): Promise<R | undefined> {
|
|
@@ -75,8 +76,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
75
76
|
|
|
76
77
|
// Check if the nodes have the same kind
|
|
77
78
|
if (!this.hasSameKind(j as J, p)) {
|
|
78
|
-
this.abort();
|
|
79
|
-
return j as R;
|
|
79
|
+
return this.abort(j) as R;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Continue with normal visitation, passing the other node as context
|
|
@@ -92,19 +92,17 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
92
92
|
*/
|
|
93
93
|
override async visitBinary(binary: J.Binary, other: J): Promise<J | undefined> {
|
|
94
94
|
if (!this.match || other.kind !== J.Kind.Binary) {
|
|
95
|
-
this.abort();
|
|
96
|
-
return binary;
|
|
95
|
+
return this.abort(binary);
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
const otherBinary = other as J.Binary;
|
|
100
99
|
if (binary.operator.element !== otherBinary.operator.element) {
|
|
101
|
-
this.abort();
|
|
102
|
-
return binary;
|
|
100
|
+
return this.abort(binary);
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
// Visit left and right operands in lock step
|
|
106
104
|
await this.visit(binary.left, otherBinary.left);
|
|
107
|
-
if (!this.match) return binary;
|
|
105
|
+
if (!this.match) return this.abort(binary);
|
|
108
106
|
|
|
109
107
|
await this.visit(binary.right, otherBinary.right);
|
|
110
108
|
return binary;
|
|
@@ -119,13 +117,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
119
117
|
*/
|
|
120
118
|
override async visitIdentifier(identifier: J.Identifier, other: J): Promise<J | undefined> {
|
|
121
119
|
if (!this.match || other.kind !== J.Kind.Identifier) {
|
|
122
|
-
this.abort();
|
|
123
|
-
return identifier;
|
|
120
|
+
return this.abort(identifier);
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
const otherIdentifier = other as J.Identifier;
|
|
127
124
|
if (identifier.simpleName !== otherIdentifier.simpleName) {
|
|
128
|
-
this.abort();
|
|
125
|
+
return this.abort(identifier);
|
|
129
126
|
}
|
|
130
127
|
|
|
131
128
|
return identifier;
|
|
@@ -140,13 +137,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
140
137
|
*/
|
|
141
138
|
override async visitLiteral(literal: J.Literal, other: J): Promise<J | undefined> {
|
|
142
139
|
if (!this.match || other.kind !== J.Kind.Literal) {
|
|
143
|
-
this.abort();
|
|
144
|
-
return literal;
|
|
140
|
+
return this.abort(literal);
|
|
145
141
|
}
|
|
146
142
|
|
|
147
143
|
const otherLiteral = other as J.Literal;
|
|
148
144
|
if (literal.valueSource !== otherLiteral.valueSource) {
|
|
149
|
-
this.abort();
|
|
145
|
+
return this.abort(literal);
|
|
150
146
|
}
|
|
151
147
|
|
|
152
148
|
return literal;
|
|
@@ -161,20 +157,20 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
161
157
|
*/
|
|
162
158
|
override async visitBlock(block: J.Block, other: J): Promise<J | undefined> {
|
|
163
159
|
if (!this.match || other.kind !== J.Kind.Block) {
|
|
164
|
-
this.abort();
|
|
165
|
-
return block;
|
|
160
|
+
return this.abort(block);
|
|
166
161
|
}
|
|
167
162
|
|
|
168
163
|
const otherBlock = other as J.Block;
|
|
169
164
|
if (block.statements.length !== otherBlock.statements.length) {
|
|
170
|
-
this.abort();
|
|
171
|
-
return block;
|
|
165
|
+
return this.abort(block);
|
|
172
166
|
}
|
|
173
167
|
|
|
174
168
|
// Visit each statement in lock step
|
|
175
169
|
for (let i = 0; i < block.statements.length; i++) {
|
|
176
170
|
await this.visit(block.statements[i].element, otherBlock.statements[i].element);
|
|
177
|
-
if (!this.match)
|
|
171
|
+
if (!this.match) {
|
|
172
|
+
return this.abort(block);
|
|
173
|
+
}
|
|
178
174
|
}
|
|
179
175
|
|
|
180
176
|
return block;
|
|
@@ -189,20 +185,20 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
189
185
|
*/
|
|
190
186
|
override async visitJsCompilationUnit(compilationUnit: JS.CompilationUnit, other: J): Promise<J | undefined> {
|
|
191
187
|
if (!this.match || other.kind !== JS.Kind.CompilationUnit) {
|
|
192
|
-
this.abort();
|
|
193
|
-
return compilationUnit;
|
|
188
|
+
return this.abort(compilationUnit);
|
|
194
189
|
}
|
|
195
190
|
|
|
196
191
|
const otherCompilationUnit = other as JS.CompilationUnit;
|
|
197
192
|
if (compilationUnit.statements.length !== otherCompilationUnit.statements.length) {
|
|
198
|
-
this.abort();
|
|
199
|
-
return compilationUnit;
|
|
193
|
+
return this.abort(compilationUnit);
|
|
200
194
|
}
|
|
201
195
|
|
|
202
196
|
// Visit each statement in lock step
|
|
203
197
|
for (let i = 0; i < compilationUnit.statements.length; i++) {
|
|
204
198
|
await this.visit(compilationUnit.statements[i].element, otherCompilationUnit.statements[i].element);
|
|
205
|
-
if (!this.match)
|
|
199
|
+
if (!this.match) {
|
|
200
|
+
return this.abort(compilationUnit);
|
|
201
|
+
}
|
|
206
202
|
}
|
|
207
203
|
|
|
208
204
|
return compilationUnit;
|
|
@@ -217,15 +213,16 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
217
213
|
*/
|
|
218
214
|
override async visitAlias(alias: JS.Alias, other: J): Promise<J | undefined> {
|
|
219
215
|
if (!this.match || other.kind !== JS.Kind.Alias) {
|
|
220
|
-
this.abort();
|
|
221
|
-
return alias;
|
|
216
|
+
return this.abort(alias);
|
|
222
217
|
}
|
|
223
218
|
|
|
224
219
|
const otherAlias = other as JS.Alias;
|
|
225
220
|
|
|
226
221
|
// Visit property name and alias in lock step
|
|
227
222
|
await this.visit(alias.propertyName.element, otherAlias.propertyName.element);
|
|
228
|
-
if (!this.match)
|
|
223
|
+
if (!this.match) {
|
|
224
|
+
return this.abort(alias);
|
|
225
|
+
}
|
|
229
226
|
|
|
230
227
|
await this.visit(alias.alias, otherAlias.alias);
|
|
231
228
|
return alias;
|
|
@@ -240,16 +237,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
240
237
|
*/
|
|
241
238
|
override async visitArrowFunction(arrowFunction: JS.ArrowFunction, other: J): Promise<J | undefined> {
|
|
242
239
|
if (!this.match || other.kind !== JS.Kind.ArrowFunction) {
|
|
243
|
-
this.abort();
|
|
244
|
-
return arrowFunction;
|
|
240
|
+
return this.abort(arrowFunction);
|
|
245
241
|
}
|
|
246
242
|
|
|
247
243
|
const otherArrowFunction = other as JS.ArrowFunction;
|
|
248
244
|
|
|
249
245
|
// Compare modifiers
|
|
250
246
|
if (arrowFunction.modifiers.length !== otherArrowFunction.modifiers.length) {
|
|
251
|
-
this.abort();
|
|
252
|
-
return arrowFunction;
|
|
247
|
+
return this.abort(arrowFunction);
|
|
253
248
|
}
|
|
254
249
|
|
|
255
250
|
// Visit modifiers in lock step
|
|
@@ -260,8 +255,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
260
255
|
|
|
261
256
|
// Visit type parameters if present
|
|
262
257
|
if (!!arrowFunction.typeParameters !== !!otherArrowFunction.typeParameters) {
|
|
263
|
-
this.abort();
|
|
264
|
-
return arrowFunction;
|
|
258
|
+
return this.abort(arrowFunction);
|
|
265
259
|
}
|
|
266
260
|
|
|
267
261
|
if (arrowFunction.typeParameters) {
|
|
@@ -275,8 +269,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
275
269
|
|
|
276
270
|
// Visit return type expression if present
|
|
277
271
|
if (!!arrowFunction.returnTypeExpression !== !!otherArrowFunction.returnTypeExpression) {
|
|
278
|
-
this.abort();
|
|
279
|
-
return arrowFunction;
|
|
272
|
+
return this.abort(arrowFunction);
|
|
280
273
|
}
|
|
281
274
|
|
|
282
275
|
if (arrowFunction.returnTypeExpression) {
|
|
@@ -295,8 +288,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
295
288
|
*/
|
|
296
289
|
override async visitAwait(await_: JS.Await, other: J): Promise<J | undefined> {
|
|
297
290
|
if (!this.match || other.kind !== JS.Kind.Await) {
|
|
298
|
-
this.abort();
|
|
299
|
-
return await_;
|
|
291
|
+
return this.abort(await_);
|
|
300
292
|
}
|
|
301
293
|
|
|
302
294
|
const otherAwait = other as JS.Await;
|
|
@@ -316,8 +308,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
316
308
|
*/
|
|
317
309
|
override async visitJsxTag(element: JSX.Tag, other: J): Promise<J | undefined> {
|
|
318
310
|
if (!this.match || other.kind !== JS.Kind.JsxTag) {
|
|
319
|
-
this.abort();
|
|
320
|
-
return element;
|
|
311
|
+
return this.abort(element);
|
|
321
312
|
}
|
|
322
313
|
|
|
323
314
|
const otherElement = other as JSX.Tag;
|
|
@@ -328,8 +319,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
328
319
|
|
|
329
320
|
// Compare attributes
|
|
330
321
|
if (element.attributes.length !== otherElement.attributes.length) {
|
|
331
|
-
this.abort();
|
|
332
|
-
return element;
|
|
322
|
+
return this.abort(element);
|
|
333
323
|
}
|
|
334
324
|
|
|
335
325
|
// Visit attributes in lock step
|
|
@@ -340,20 +330,17 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
340
330
|
|
|
341
331
|
// Compare self-closing
|
|
342
332
|
if (!!element.selfClosing !== !!otherElement.selfClosing) {
|
|
343
|
-
this.abort();
|
|
344
|
-
return element;
|
|
333
|
+
return this.abort(element);
|
|
345
334
|
}
|
|
346
335
|
|
|
347
336
|
// Compare children
|
|
348
337
|
if (!!element.children !== !!otherElement.children) {
|
|
349
|
-
this.abort();
|
|
350
|
-
return element;
|
|
338
|
+
return this.abort(element);
|
|
351
339
|
}
|
|
352
340
|
|
|
353
341
|
if (element.children) {
|
|
354
342
|
if (element.children.length !== otherElement.children!.length) {
|
|
355
|
-
this.abort();
|
|
356
|
-
return element;
|
|
343
|
+
return this.abort(element);
|
|
357
344
|
}
|
|
358
345
|
|
|
359
346
|
// Visit children in lock step
|
|
@@ -365,8 +352,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
365
352
|
|
|
366
353
|
// Compare closing name
|
|
367
354
|
if (!!element.closingName !== !!otherElement.closingName) {
|
|
368
|
-
this.abort();
|
|
369
|
-
return element;
|
|
355
|
+
return this.abort(element);
|
|
370
356
|
}
|
|
371
357
|
|
|
372
358
|
if (element.closingName) {
|
|
@@ -385,8 +371,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
385
371
|
*/
|
|
386
372
|
override async visitJsxAttribute(attribute: JSX.Attribute, other: J): Promise<J | undefined> {
|
|
387
373
|
if (!this.match || other.kind !== JS.Kind.JsxAttribute) {
|
|
388
|
-
this.abort();
|
|
389
|
-
return attribute;
|
|
374
|
+
return this.abort(attribute);
|
|
390
375
|
}
|
|
391
376
|
|
|
392
377
|
const otherAttribute = other as JSX.Attribute;
|
|
@@ -397,8 +382,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
397
382
|
|
|
398
383
|
// Compare value
|
|
399
384
|
if (!!attribute.value !== !!otherAttribute.value) {
|
|
400
|
-
this.abort();
|
|
401
|
-
return attribute;
|
|
385
|
+
return this.abort(attribute);
|
|
402
386
|
}
|
|
403
387
|
|
|
404
388
|
if (attribute.value) {
|
|
@@ -417,8 +401,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
417
401
|
*/
|
|
418
402
|
override async visitJsxSpreadAttribute(spread: JSX.SpreadAttribute, other: J): Promise<J | undefined> {
|
|
419
403
|
if (!this.match || other.kind !== JS.Kind.JsxSpreadAttribute) {
|
|
420
|
-
this.abort();
|
|
421
|
-
return spread;
|
|
404
|
+
return this.abort(spread);
|
|
422
405
|
}
|
|
423
406
|
|
|
424
407
|
const otherSpread = other as JSX.SpreadAttribute;
|
|
@@ -438,8 +421,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
438
421
|
*/
|
|
439
422
|
override async visitJsxEmbeddedExpression(expr: JSX.EmbeddedExpression, other: J): Promise<J | undefined> {
|
|
440
423
|
if (!this.match || other.kind !== JS.Kind.JsxEmbeddedExpression) {
|
|
441
|
-
this.abort();
|
|
442
|
-
return expr;
|
|
424
|
+
return this.abort(expr);
|
|
443
425
|
}
|
|
444
426
|
|
|
445
427
|
const otherExpr = other as JSX.EmbeddedExpression;
|
|
@@ -459,8 +441,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
459
441
|
*/
|
|
460
442
|
override async visitJsxNamespacedName(ns: JSX.NamespacedName, other: J): Promise<J | undefined> {
|
|
461
443
|
if (!this.match || other.kind !== JS.Kind.JsxNamespacedName) {
|
|
462
|
-
this.abort();
|
|
463
|
-
return ns;
|
|
444
|
+
return this.abort(ns);
|
|
464
445
|
}
|
|
465
446
|
|
|
466
447
|
const otherNs = other as JSX.NamespacedName;
|
|
@@ -484,8 +465,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
484
465
|
*/
|
|
485
466
|
override async visitConditionalType(conditionalType: JS.ConditionalType, other: J): Promise<J | undefined> {
|
|
486
467
|
if (!this.match || other.kind !== JS.Kind.ConditionalType) {
|
|
487
|
-
this.abort();
|
|
488
|
-
return conditionalType;
|
|
468
|
+
return this.abort(conditionalType);
|
|
489
469
|
}
|
|
490
470
|
|
|
491
471
|
const otherConditionalType = other as JS.ConditionalType;
|
|
@@ -509,8 +489,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
509
489
|
*/
|
|
510
490
|
override async visitDelete(delete_: JS.Delete, other: J): Promise<J | undefined> {
|
|
511
491
|
if (!this.match || other.kind !== JS.Kind.Delete) {
|
|
512
|
-
this.abort();
|
|
513
|
-
return delete_;
|
|
492
|
+
return this.abort(delete_);
|
|
514
493
|
}
|
|
515
494
|
|
|
516
495
|
const otherDelete = other as JS.Delete;
|
|
@@ -530,8 +509,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
530
509
|
*/
|
|
531
510
|
override async visitExpressionStatement(expressionStatement: JS.ExpressionStatement, other: J): Promise<J | undefined> {
|
|
532
511
|
if (!this.match || other.kind !== JS.Kind.ExpressionStatement) {
|
|
533
|
-
this.abort();
|
|
534
|
-
return expressionStatement;
|
|
512
|
+
return this.abort(expressionStatement);
|
|
535
513
|
}
|
|
536
514
|
|
|
537
515
|
const otherExpressionStatement = other as JS.ExpressionStatement;
|
|
@@ -551,8 +529,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
551
529
|
*/
|
|
552
530
|
override async visitExpressionWithTypeArguments(expressionWithTypeArguments: JS.ExpressionWithTypeArguments, other: J): Promise<J | undefined> {
|
|
553
531
|
if (!this.match || other.kind !== JS.Kind.ExpressionWithTypeArguments) {
|
|
554
|
-
this.abort();
|
|
555
|
-
return expressionWithTypeArguments;
|
|
532
|
+
return this.abort(expressionWithTypeArguments);
|
|
556
533
|
}
|
|
557
534
|
|
|
558
535
|
const otherExpressionWithTypeArguments = other as JS.ExpressionWithTypeArguments;
|
|
@@ -563,14 +540,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
563
540
|
|
|
564
541
|
// Compare type arguments
|
|
565
542
|
if (!!expressionWithTypeArguments.typeArguments !== !!otherExpressionWithTypeArguments.typeArguments) {
|
|
566
|
-
this.abort();
|
|
567
|
-
return expressionWithTypeArguments;
|
|
543
|
+
return this.abort(expressionWithTypeArguments);
|
|
568
544
|
}
|
|
569
545
|
|
|
570
546
|
if (expressionWithTypeArguments.typeArguments) {
|
|
571
547
|
if (expressionWithTypeArguments.typeArguments.elements.length !== otherExpressionWithTypeArguments.typeArguments!.elements.length) {
|
|
572
|
-
this.abort();
|
|
573
|
-
return expressionWithTypeArguments;
|
|
548
|
+
return this.abort(expressionWithTypeArguments);
|
|
574
549
|
}
|
|
575
550
|
|
|
576
551
|
// Visit type arguments in lock step
|
|
@@ -593,16 +568,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
593
568
|
*/
|
|
594
569
|
override async visitFunctionCall(functionCall: JS.FunctionCall, other: J): Promise<J | undefined> {
|
|
595
570
|
if (!this.match || other.kind !== JS.Kind.FunctionCall) {
|
|
596
|
-
this.abort();
|
|
597
|
-
return functionCall;
|
|
571
|
+
return this.abort(functionCall);
|
|
598
572
|
}
|
|
599
573
|
|
|
600
574
|
const otherFunctionCall = other as JS.FunctionCall;
|
|
601
575
|
|
|
602
576
|
// Compare function
|
|
603
577
|
if ((functionCall.function === undefined) !== (otherFunctionCall.function === undefined)) {
|
|
604
|
-
this.abort();
|
|
605
|
-
return functionCall;
|
|
578
|
+
return this.abort(functionCall);
|
|
606
579
|
}
|
|
607
580
|
|
|
608
581
|
// Visit function if present
|
|
@@ -613,15 +586,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
613
586
|
|
|
614
587
|
// Compare typeParameters
|
|
615
588
|
if ((functionCall.typeParameters === undefined) !== (otherFunctionCall.typeParameters === undefined)) {
|
|
616
|
-
this.abort();
|
|
617
|
-
return functionCall;
|
|
589
|
+
return this.abort(functionCall);
|
|
618
590
|
}
|
|
619
591
|
|
|
620
592
|
// Visit typeParameters if present
|
|
621
593
|
if (functionCall.typeParameters && otherFunctionCall.typeParameters) {
|
|
622
594
|
if (functionCall.typeParameters.elements.length !== otherFunctionCall.typeParameters.elements.length) {
|
|
623
|
-
this.abort();
|
|
624
|
-
return functionCall;
|
|
595
|
+
return this.abort(functionCall);
|
|
625
596
|
}
|
|
626
597
|
|
|
627
598
|
// Visit each type parameter in lock step
|
|
@@ -633,8 +604,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
633
604
|
|
|
634
605
|
// Compare arguments
|
|
635
606
|
if (functionCall.arguments.elements.length !== otherFunctionCall.arguments.elements.length) {
|
|
636
|
-
this.abort();
|
|
637
|
-
return functionCall;
|
|
607
|
+
return this.abort(functionCall);
|
|
638
608
|
}
|
|
639
609
|
|
|
640
610
|
// Visit each argument in lock step
|
|
@@ -655,29 +625,25 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
655
625
|
*/
|
|
656
626
|
override async visitFunctionType(functionType: JS.FunctionType, other: J): Promise<J | undefined> {
|
|
657
627
|
if (!this.match || other.kind !== JS.Kind.FunctionType) {
|
|
658
|
-
this.abort();
|
|
659
|
-
return functionType;
|
|
628
|
+
return this.abort(functionType);
|
|
660
629
|
}
|
|
661
630
|
|
|
662
631
|
const otherFunctionType = other as JS.FunctionType;
|
|
663
632
|
|
|
664
633
|
// Compare constructor type
|
|
665
634
|
if (!!functionType.constructorType.element !== !!otherFunctionType.constructorType.element) {
|
|
666
|
-
this.abort();
|
|
667
|
-
return functionType;
|
|
635
|
+
return this.abort(functionType);
|
|
668
636
|
}
|
|
669
637
|
|
|
670
638
|
if (functionType.constructorType.element) {
|
|
671
639
|
if (functionType.constructorType.element !== otherFunctionType.constructorType.element) {
|
|
672
|
-
this.abort();
|
|
673
|
-
return functionType;
|
|
640
|
+
return this.abort(functionType);
|
|
674
641
|
}
|
|
675
642
|
}
|
|
676
643
|
|
|
677
644
|
// Compare type parameters
|
|
678
645
|
if (!!functionType.typeParameters !== !!otherFunctionType.typeParameters) {
|
|
679
|
-
this.abort();
|
|
680
|
-
return functionType;
|
|
646
|
+
return this.abort(functionType);
|
|
681
647
|
}
|
|
682
648
|
|
|
683
649
|
if (functionType.typeParameters) {
|
|
@@ -687,8 +653,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
687
653
|
|
|
688
654
|
// Compare parameters
|
|
689
655
|
if (functionType.parameters.elements.length !== otherFunctionType.parameters.elements.length) {
|
|
690
|
-
this.abort();
|
|
691
|
-
return functionType;
|
|
656
|
+
return this.abort(functionType);
|
|
692
657
|
}
|
|
693
658
|
|
|
694
659
|
// Visit parameters in lock step
|
|
@@ -712,8 +677,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
712
677
|
*/
|
|
713
678
|
override async visitInferType(inferType: JS.InferType, other: J): Promise<J | undefined> {
|
|
714
679
|
if (!this.match || other.kind !== JS.Kind.InferType) {
|
|
715
|
-
this.abort();
|
|
716
|
-
return inferType;
|
|
680
|
+
return this.abort(inferType);
|
|
717
681
|
}
|
|
718
682
|
|
|
719
683
|
const otherInferType = other as JS.InferType;
|
|
@@ -733,22 +697,19 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
733
697
|
*/
|
|
734
698
|
override async visitImportType(importType: JS.ImportType, other: J): Promise<J | undefined> {
|
|
735
699
|
if (!this.match || other.kind !== JS.Kind.ImportType) {
|
|
736
|
-
this.abort();
|
|
737
|
-
return importType;
|
|
700
|
+
return this.abort(importType);
|
|
738
701
|
}
|
|
739
702
|
|
|
740
703
|
const otherImportType = other as JS.ImportType;
|
|
741
704
|
|
|
742
705
|
// Compare has typeof
|
|
743
706
|
if (importType.hasTypeof.element !== otherImportType.hasTypeof.element) {
|
|
744
|
-
this.abort();
|
|
745
|
-
return importType;
|
|
707
|
+
return this.abort(importType);
|
|
746
708
|
}
|
|
747
709
|
|
|
748
710
|
// Compare argument and attributes
|
|
749
711
|
if (importType.argumentAndAttributes.elements.length !== otherImportType.argumentAndAttributes.elements.length) {
|
|
750
|
-
this.abort();
|
|
751
|
-
return importType;
|
|
712
|
+
return this.abort(importType);
|
|
752
713
|
}
|
|
753
714
|
|
|
754
715
|
// Visit argument and attributes in lock step
|
|
@@ -760,8 +721,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
760
721
|
|
|
761
722
|
// Compare qualifier
|
|
762
723
|
if (!!importType.qualifier !== !!otherImportType.qualifier) {
|
|
763
|
-
this.abort();
|
|
764
|
-
return importType;
|
|
724
|
+
return this.abort(importType);
|
|
765
725
|
}
|
|
766
726
|
|
|
767
727
|
if (importType.qualifier) {
|
|
@@ -771,14 +731,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
771
731
|
|
|
772
732
|
// Compare type arguments
|
|
773
733
|
if (!!importType.typeArguments !== !!otherImportType.typeArguments) {
|
|
774
|
-
this.abort();
|
|
775
|
-
return importType;
|
|
734
|
+
return this.abort(importType);
|
|
776
735
|
}
|
|
777
736
|
|
|
778
737
|
if (importType.typeArguments) {
|
|
779
738
|
if (importType.typeArguments.elements.length !== otherImportType.typeArguments!.elements.length) {
|
|
780
|
-
this.abort();
|
|
781
|
-
return importType;
|
|
739
|
+
return this.abort(importType);
|
|
782
740
|
}
|
|
783
741
|
|
|
784
742
|
// Visit type arguments in lock step
|
|
@@ -801,16 +759,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
801
759
|
*/
|
|
802
760
|
override async visitImportDeclaration(jsImport: JS.Import, other: J): Promise<J | undefined> {
|
|
803
761
|
if (!this.match || other.kind !== JS.Kind.Import) {
|
|
804
|
-
this.abort();
|
|
805
|
-
return jsImport;
|
|
762
|
+
return this.abort(jsImport);
|
|
806
763
|
}
|
|
807
764
|
|
|
808
765
|
const otherImport = other as JS.Import;
|
|
809
766
|
|
|
810
767
|
// Compare modifiers
|
|
811
768
|
if (jsImport.modifiers.length !== otherImport.modifiers.length) {
|
|
812
|
-
this.abort();
|
|
813
|
-
return jsImport;
|
|
769
|
+
return this.abort(jsImport);
|
|
814
770
|
}
|
|
815
771
|
|
|
816
772
|
// Visit each modifier in lock step
|
|
@@ -821,8 +777,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
821
777
|
|
|
822
778
|
// Compare import clause
|
|
823
779
|
if (!!jsImport.importClause !== !!otherImport.importClause) {
|
|
824
|
-
this.abort();
|
|
825
|
-
return jsImport;
|
|
780
|
+
return this.abort(jsImport);
|
|
826
781
|
}
|
|
827
782
|
|
|
828
783
|
if (jsImport.importClause) {
|
|
@@ -838,8 +793,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
838
793
|
|
|
839
794
|
// Compare attributes
|
|
840
795
|
if (!!jsImport.attributes !== !!otherImport.attributes) {
|
|
841
|
-
this.abort();
|
|
842
|
-
return jsImport;
|
|
796
|
+
return this.abort(jsImport);
|
|
843
797
|
}
|
|
844
798
|
|
|
845
799
|
if (jsImport.attributes) {
|
|
@@ -864,16 +818,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
864
818
|
*/
|
|
865
819
|
override async visitImportClause(importClause: JS.ImportClause, other: J): Promise<J | undefined> {
|
|
866
820
|
if (!this.match || other.kind !== JS.Kind.ImportClause) {
|
|
867
|
-
this.abort();
|
|
868
|
-
return importClause;
|
|
821
|
+
return this.abort(importClause);
|
|
869
822
|
}
|
|
870
823
|
|
|
871
824
|
const otherImportClause = other as JS.ImportClause;
|
|
872
825
|
|
|
873
826
|
// Compare name
|
|
874
827
|
if (!!importClause.name !== !!otherImportClause.name) {
|
|
875
|
-
this.abort();
|
|
876
|
-
return importClause;
|
|
828
|
+
return this.abort(importClause);
|
|
877
829
|
}
|
|
878
830
|
|
|
879
831
|
if (importClause.name) {
|
|
@@ -883,8 +835,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
883
835
|
|
|
884
836
|
// Compare named bindings
|
|
885
837
|
if (!!importClause.namedBindings !== !!otherImportClause.namedBindings) {
|
|
886
|
-
this.abort();
|
|
887
|
-
return importClause;
|
|
838
|
+
return this.abort(importClause);
|
|
888
839
|
}
|
|
889
840
|
|
|
890
841
|
if (importClause.namedBindings) {
|
|
@@ -903,16 +854,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
903
854
|
*/
|
|
904
855
|
override async visitNamedImports(namedImports: JS.NamedImports, other: J): Promise<J | undefined> {
|
|
905
856
|
if (!this.match || other.kind !== JS.Kind.NamedImports) {
|
|
906
|
-
this.abort();
|
|
907
|
-
return namedImports;
|
|
857
|
+
return this.abort(namedImports);
|
|
908
858
|
}
|
|
909
859
|
|
|
910
860
|
const otherNamedImports = other as JS.NamedImports;
|
|
911
861
|
|
|
912
862
|
// Compare elements
|
|
913
863
|
if (namedImports.elements.elements.length !== otherNamedImports.elements.elements.length) {
|
|
914
|
-
this.abort();
|
|
915
|
-
return namedImports;
|
|
864
|
+
return this.abort(namedImports);
|
|
916
865
|
}
|
|
917
866
|
|
|
918
867
|
// Visit elements in lock step
|
|
@@ -933,22 +882,19 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
933
882
|
*/
|
|
934
883
|
override async visitImportSpecifier(importSpecifier: JS.ImportSpecifier, other: J): Promise<J | undefined> {
|
|
935
884
|
if (!this.match || other.kind !== JS.Kind.ImportSpecifier) {
|
|
936
|
-
this.abort();
|
|
937
|
-
return importSpecifier;
|
|
885
|
+
return this.abort(importSpecifier);
|
|
938
886
|
}
|
|
939
887
|
|
|
940
888
|
const otherImportSpecifier = other as JS.ImportSpecifier;
|
|
941
889
|
|
|
942
890
|
// Compare import type
|
|
943
891
|
if (!!importSpecifier.importType.element !== !!otherImportSpecifier.importType.element) {
|
|
944
|
-
this.abort();
|
|
945
|
-
return importSpecifier;
|
|
892
|
+
return this.abort(importSpecifier);
|
|
946
893
|
}
|
|
947
894
|
|
|
948
895
|
if (importSpecifier.importType.element) {
|
|
949
896
|
if (importSpecifier.importType.element !== otherImportSpecifier.importType.element) {
|
|
950
|
-
this.abort();
|
|
951
|
-
return importSpecifier;
|
|
897
|
+
return this.abort(importSpecifier);
|
|
952
898
|
}
|
|
953
899
|
}
|
|
954
900
|
|
|
@@ -967,16 +913,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
967
913
|
*/
|
|
968
914
|
override async visitImportAttributes(importAttributes: JS.ImportAttributes, other: J): Promise<J | undefined> {
|
|
969
915
|
if (!this.match || other.kind !== JS.Kind.ImportAttributes) {
|
|
970
|
-
this.abort();
|
|
971
|
-
return importAttributes;
|
|
916
|
+
return this.abort(importAttributes);
|
|
972
917
|
}
|
|
973
918
|
|
|
974
919
|
const otherImportAttributes = other as JS.ImportAttributes;
|
|
975
920
|
|
|
976
921
|
// Compare elements
|
|
977
922
|
if (importAttributes.elements.elements.length !== otherImportAttributes.elements.elements.length) {
|
|
978
|
-
this.abort();
|
|
979
|
-
return importAttributes;
|
|
923
|
+
return this.abort(importAttributes);
|
|
980
924
|
}
|
|
981
925
|
|
|
982
926
|
// Visit elements in lock step
|
|
@@ -997,8 +941,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
997
941
|
*/
|
|
998
942
|
override async visitImportTypeAttributes(importTypeAttributes: JS.ImportTypeAttributes, other: J): Promise<J | undefined> {
|
|
999
943
|
if (!this.match || other.kind !== JS.Kind.ImportTypeAttributes) {
|
|
1000
|
-
this.abort();
|
|
1001
|
-
return importTypeAttributes;
|
|
944
|
+
return this.abort(importTypeAttributes);
|
|
1002
945
|
}
|
|
1003
946
|
|
|
1004
947
|
const otherImportTypeAttributes = other as JS.ImportTypeAttributes;
|
|
@@ -1009,8 +952,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1009
952
|
|
|
1010
953
|
// Compare elements
|
|
1011
954
|
if (importTypeAttributes.elements.elements.length !== otherImportTypeAttributes.elements.elements.length) {
|
|
1012
|
-
this.abort();
|
|
1013
|
-
return importTypeAttributes;
|
|
955
|
+
return this.abort(importTypeAttributes);
|
|
1014
956
|
}
|
|
1015
957
|
|
|
1016
958
|
// Visit elements in lock step
|
|
@@ -1031,8 +973,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1031
973
|
*/
|
|
1032
974
|
override async visitImportAttribute(importAttribute: JS.ImportAttribute, other: J): Promise<J | undefined> {
|
|
1033
975
|
if (!this.match || other.kind !== JS.Kind.ImportAttribute) {
|
|
1034
|
-
this.abort();
|
|
1035
|
-
return importAttribute;
|
|
976
|
+
return this.abort(importAttribute);
|
|
1036
977
|
}
|
|
1037
978
|
|
|
1038
979
|
const otherImportAttribute = other as JS.ImportAttribute;
|
|
@@ -1056,8 +997,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1056
997
|
*/
|
|
1057
998
|
override async visitBinaryExtensions(jsBinary: JS.Binary, other: J): Promise<J | undefined> {
|
|
1058
999
|
if (!this.match || other.kind !== JS.Kind.Binary) {
|
|
1059
|
-
this.abort();
|
|
1060
|
-
return jsBinary;
|
|
1000
|
+
return this.abort(jsBinary);
|
|
1061
1001
|
}
|
|
1062
1002
|
|
|
1063
1003
|
const otherBinary = other as JS.Binary;
|
|
@@ -1068,8 +1008,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1068
1008
|
|
|
1069
1009
|
// Compare operator
|
|
1070
1010
|
if (jsBinary.operator.element !== otherBinary.operator.element) {
|
|
1071
|
-
this.abort();
|
|
1072
|
-
return jsBinary;
|
|
1011
|
+
return this.abort(jsBinary);
|
|
1073
1012
|
}
|
|
1074
1013
|
|
|
1075
1014
|
// Visit right operand
|
|
@@ -1087,8 +1026,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1087
1026
|
*/
|
|
1088
1027
|
override async visitLiteralType(literalType: JS.LiteralType, other: J): Promise<J | undefined> {
|
|
1089
1028
|
if (!this.match || other.kind !== JS.Kind.LiteralType) {
|
|
1090
|
-
this.abort();
|
|
1091
|
-
return literalType;
|
|
1029
|
+
return this.abort(literalType);
|
|
1092
1030
|
}
|
|
1093
1031
|
|
|
1094
1032
|
const otherLiteralType = other as JS.LiteralType;
|
|
@@ -1108,16 +1046,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1108
1046
|
*/
|
|
1109
1047
|
override async visitMappedType(mappedType: JS.MappedType, other: J): Promise<J | undefined> {
|
|
1110
1048
|
if (!this.match || other.kind !== JS.Kind.MappedType) {
|
|
1111
|
-
this.abort();
|
|
1112
|
-
return mappedType;
|
|
1049
|
+
return this.abort(mappedType);
|
|
1113
1050
|
}
|
|
1114
1051
|
|
|
1115
1052
|
const otherMappedType = other as JS.MappedType;
|
|
1116
1053
|
|
|
1117
1054
|
// Compare prefix token
|
|
1118
1055
|
if (!!mappedType.prefixToken !== !!otherMappedType.prefixToken) {
|
|
1119
|
-
this.abort();
|
|
1120
|
-
return mappedType;
|
|
1056
|
+
return this.abort(mappedType);
|
|
1121
1057
|
}
|
|
1122
1058
|
|
|
1123
1059
|
if (mappedType.prefixToken) {
|
|
@@ -1127,8 +1063,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1127
1063
|
|
|
1128
1064
|
// Compare has readonly
|
|
1129
1065
|
if (mappedType.hasReadonly.element !== otherMappedType.hasReadonly.element) {
|
|
1130
|
-
this.abort();
|
|
1131
|
-
return mappedType;
|
|
1066
|
+
return this.abort(mappedType);
|
|
1132
1067
|
}
|
|
1133
1068
|
|
|
1134
1069
|
// Visit keys remapping
|
|
@@ -1137,8 +1072,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1137
1072
|
|
|
1138
1073
|
// Compare suffix token
|
|
1139
1074
|
if (!!mappedType.suffixToken !== !!otherMappedType.suffixToken) {
|
|
1140
|
-
this.abort();
|
|
1141
|
-
return mappedType;
|
|
1075
|
+
return this.abort(mappedType);
|
|
1142
1076
|
}
|
|
1143
1077
|
|
|
1144
1078
|
if (mappedType.suffixToken) {
|
|
@@ -1148,14 +1082,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1148
1082
|
|
|
1149
1083
|
// Compare has question token
|
|
1150
1084
|
if (mappedType.hasQuestionToken.element !== otherMappedType.hasQuestionToken.element) {
|
|
1151
|
-
this.abort();
|
|
1152
|
-
return mappedType;
|
|
1085
|
+
return this.abort(mappedType);
|
|
1153
1086
|
}
|
|
1154
1087
|
|
|
1155
1088
|
// Compare value type
|
|
1156
1089
|
if (mappedType.valueType.elements.length !== otherMappedType.valueType.elements.length) {
|
|
1157
|
-
this.abort();
|
|
1158
|
-
return mappedType;
|
|
1090
|
+
return this.abort(mappedType);
|
|
1159
1091
|
}
|
|
1160
1092
|
|
|
1161
1093
|
// Visit value type elements in lock step
|
|
@@ -1176,8 +1108,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1176
1108
|
*/
|
|
1177
1109
|
override async visitMappedTypeKeysRemapping(keysRemapping: JS.MappedType.KeysRemapping, other: J): Promise<J | undefined> {
|
|
1178
1110
|
if (!this.match || other.kind !== JS.Kind.MappedTypeKeysRemapping) {
|
|
1179
|
-
this.abort();
|
|
1180
|
-
return keysRemapping;
|
|
1111
|
+
return this.abort(keysRemapping);
|
|
1181
1112
|
}
|
|
1182
1113
|
|
|
1183
1114
|
const otherKeysRemapping = other as JS.MappedType.KeysRemapping;
|
|
@@ -1188,8 +1119,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1188
1119
|
|
|
1189
1120
|
// Compare name type
|
|
1190
1121
|
if (!!keysRemapping.nameType !== !!otherKeysRemapping.nameType) {
|
|
1191
|
-
this.abort();
|
|
1192
|
-
return keysRemapping;
|
|
1122
|
+
return this.abort(keysRemapping);
|
|
1193
1123
|
}
|
|
1194
1124
|
|
|
1195
1125
|
if (keysRemapping.nameType) {
|
|
@@ -1208,8 +1138,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1208
1138
|
*/
|
|
1209
1139
|
override async visitMappedTypeParameter(mappedTypeParameter: JS.MappedType.Parameter, other: J): Promise<J | undefined> {
|
|
1210
1140
|
if (!this.match || other.kind !== JS.Kind.MappedTypeParameter) {
|
|
1211
|
-
this.abort();
|
|
1212
|
-
return mappedTypeParameter;
|
|
1141
|
+
return this.abort(mappedTypeParameter);
|
|
1213
1142
|
}
|
|
1214
1143
|
|
|
1215
1144
|
const otherMappedTypeParameter = other as JS.MappedType.Parameter;
|
|
@@ -1233,16 +1162,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1233
1162
|
*/
|
|
1234
1163
|
override async visitObjectBindingPattern(objectBindingPattern: JS.ObjectBindingPattern, other: J): Promise<J | undefined> {
|
|
1235
1164
|
if (!this.match || other.kind !== JS.Kind.ObjectBindingPattern) {
|
|
1236
|
-
this.abort();
|
|
1237
|
-
return objectBindingPattern;
|
|
1165
|
+
return this.abort(objectBindingPattern);
|
|
1238
1166
|
}
|
|
1239
1167
|
|
|
1240
1168
|
const otherObjectBindingPattern = other as JS.ObjectBindingPattern;
|
|
1241
1169
|
|
|
1242
1170
|
// Compare leading annotations
|
|
1243
1171
|
if (objectBindingPattern.leadingAnnotations.length !== otherObjectBindingPattern.leadingAnnotations.length) {
|
|
1244
|
-
this.abort();
|
|
1245
|
-
return objectBindingPattern;
|
|
1172
|
+
return this.abort(objectBindingPattern);
|
|
1246
1173
|
}
|
|
1247
1174
|
|
|
1248
1175
|
// Visit leading annotations in lock step
|
|
@@ -1253,8 +1180,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1253
1180
|
|
|
1254
1181
|
// Compare modifiers
|
|
1255
1182
|
if (objectBindingPattern.modifiers.length !== otherObjectBindingPattern.modifiers.length) {
|
|
1256
|
-
this.abort();
|
|
1257
|
-
return objectBindingPattern;
|
|
1183
|
+
return this.abort(objectBindingPattern);
|
|
1258
1184
|
}
|
|
1259
1185
|
|
|
1260
1186
|
// Visit modifiers in lock step
|
|
@@ -1265,8 +1191,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1265
1191
|
|
|
1266
1192
|
// Compare type expression
|
|
1267
1193
|
if (!!objectBindingPattern.typeExpression !== !!otherObjectBindingPattern.typeExpression) {
|
|
1268
|
-
this.abort();
|
|
1269
|
-
return objectBindingPattern;
|
|
1194
|
+
return this.abort(objectBindingPattern);
|
|
1270
1195
|
}
|
|
1271
1196
|
|
|
1272
1197
|
if (objectBindingPattern.typeExpression) {
|
|
@@ -1276,8 +1201,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1276
1201
|
|
|
1277
1202
|
// Compare bindings
|
|
1278
1203
|
if (objectBindingPattern.bindings.elements.length !== otherObjectBindingPattern.bindings.elements.length) {
|
|
1279
|
-
this.abort();
|
|
1280
|
-
return objectBindingPattern;
|
|
1204
|
+
return this.abort(objectBindingPattern);
|
|
1281
1205
|
}
|
|
1282
1206
|
|
|
1283
1207
|
// Visit bindings in lock step
|
|
@@ -1289,8 +1213,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1289
1213
|
|
|
1290
1214
|
// Compare initializer
|
|
1291
1215
|
if (!!objectBindingPattern.initializer !== !!otherObjectBindingPattern.initializer) {
|
|
1292
|
-
this.abort();
|
|
1293
|
-
return objectBindingPattern;
|
|
1216
|
+
return this.abort(objectBindingPattern);
|
|
1294
1217
|
}
|
|
1295
1218
|
|
|
1296
1219
|
if (objectBindingPattern.initializer) {
|
|
@@ -1309,8 +1232,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1309
1232
|
*/
|
|
1310
1233
|
override async visitPropertyAssignment(propertyAssignment: JS.PropertyAssignment, other: J): Promise<J | undefined> {
|
|
1311
1234
|
if (!this.match || other.kind !== JS.Kind.PropertyAssignment) {
|
|
1312
|
-
this.abort();
|
|
1313
|
-
return propertyAssignment;
|
|
1235
|
+
return this.abort(propertyAssignment);
|
|
1314
1236
|
}
|
|
1315
1237
|
|
|
1316
1238
|
const otherPropertyAssignment = other as JS.PropertyAssignment;
|
|
@@ -1321,8 +1243,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1321
1243
|
|
|
1322
1244
|
// Compare initializer
|
|
1323
1245
|
if (!!propertyAssignment.initializer !== !!otherPropertyAssignment.initializer) {
|
|
1324
|
-
this.abort();
|
|
1325
|
-
return propertyAssignment;
|
|
1246
|
+
return this.abort(propertyAssignment);
|
|
1326
1247
|
}
|
|
1327
1248
|
|
|
1328
1249
|
if (propertyAssignment.initializer) {
|
|
@@ -1341,8 +1262,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1341
1262
|
*/
|
|
1342
1263
|
override async visitSatisfiesExpression(satisfiesExpression: JS.SatisfiesExpression, other: J): Promise<J | undefined> {
|
|
1343
1264
|
if (!this.match || other.kind !== JS.Kind.SatisfiesExpression) {
|
|
1344
|
-
this.abort();
|
|
1345
|
-
return satisfiesExpression;
|
|
1265
|
+
return this.abort(satisfiesExpression);
|
|
1346
1266
|
}
|
|
1347
1267
|
|
|
1348
1268
|
const otherSatisfiesExpression = other as JS.SatisfiesExpression;
|
|
@@ -1366,16 +1286,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1366
1286
|
*/
|
|
1367
1287
|
override async visitScopedVariableDeclarations(scopedVariableDeclarations: JS.ScopedVariableDeclarations, other: J): Promise<J | undefined> {
|
|
1368
1288
|
if (!this.match || other.kind !== JS.Kind.ScopedVariableDeclarations) {
|
|
1369
|
-
this.abort();
|
|
1370
|
-
return scopedVariableDeclarations;
|
|
1289
|
+
return this.abort(scopedVariableDeclarations);
|
|
1371
1290
|
}
|
|
1372
1291
|
|
|
1373
1292
|
const otherScopedVariableDeclarations = other as JS.ScopedVariableDeclarations;
|
|
1374
1293
|
|
|
1375
1294
|
// Compare modifiers
|
|
1376
1295
|
if (scopedVariableDeclarations.modifiers.length !== otherScopedVariableDeclarations.modifiers.length) {
|
|
1377
|
-
this.abort();
|
|
1378
|
-
return scopedVariableDeclarations;
|
|
1296
|
+
return this.abort(scopedVariableDeclarations);
|
|
1379
1297
|
}
|
|
1380
1298
|
|
|
1381
1299
|
// Visit modifiers in lock step
|
|
@@ -1386,8 +1304,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1386
1304
|
|
|
1387
1305
|
// Compare variables
|
|
1388
1306
|
if (scopedVariableDeclarations.variables.length !== otherScopedVariableDeclarations.variables.length) {
|
|
1389
|
-
this.abort();
|
|
1390
|
-
return scopedVariableDeclarations;
|
|
1307
|
+
return this.abort(scopedVariableDeclarations);
|
|
1391
1308
|
}
|
|
1392
1309
|
|
|
1393
1310
|
// Visit variables in lock step
|
|
@@ -1408,8 +1325,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1408
1325
|
*/
|
|
1409
1326
|
override async visitStatementExpression(statementExpression: JS.StatementExpression, other: J): Promise<J | undefined> {
|
|
1410
1327
|
if (!this.match || other.kind !== JS.Kind.StatementExpression) {
|
|
1411
|
-
this.abort();
|
|
1412
|
-
return statementExpression;
|
|
1328
|
+
return this.abort(statementExpression);
|
|
1413
1329
|
}
|
|
1414
1330
|
|
|
1415
1331
|
const otherStatementExpression = other as JS.StatementExpression;
|
|
@@ -1429,16 +1345,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1429
1345
|
*/
|
|
1430
1346
|
override async visitTaggedTemplateExpression(taggedTemplateExpression: JS.TaggedTemplateExpression, other: J): Promise<J | undefined> {
|
|
1431
1347
|
if (!this.match || other.kind !== JS.Kind.TaggedTemplateExpression) {
|
|
1432
|
-
this.abort();
|
|
1433
|
-
return taggedTemplateExpression;
|
|
1348
|
+
return this.abort(taggedTemplateExpression);
|
|
1434
1349
|
}
|
|
1435
1350
|
|
|
1436
1351
|
const otherTaggedTemplateExpression = other as JS.TaggedTemplateExpression;
|
|
1437
1352
|
|
|
1438
1353
|
// Compare tag
|
|
1439
1354
|
if (!!taggedTemplateExpression.tag !== !!otherTaggedTemplateExpression.tag) {
|
|
1440
|
-
this.abort();
|
|
1441
|
-
return taggedTemplateExpression;
|
|
1355
|
+
return this.abort(taggedTemplateExpression);
|
|
1442
1356
|
}
|
|
1443
1357
|
|
|
1444
1358
|
if (taggedTemplateExpression.tag) {
|
|
@@ -1448,14 +1362,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1448
1362
|
|
|
1449
1363
|
// Compare type arguments
|
|
1450
1364
|
if (!!taggedTemplateExpression.typeArguments !== !!otherTaggedTemplateExpression.typeArguments) {
|
|
1451
|
-
this.abort();
|
|
1452
|
-
return taggedTemplateExpression;
|
|
1365
|
+
return this.abort(taggedTemplateExpression);
|
|
1453
1366
|
}
|
|
1454
1367
|
|
|
1455
1368
|
if (taggedTemplateExpression.typeArguments) {
|
|
1456
1369
|
if (taggedTemplateExpression.typeArguments.elements.length !== otherTaggedTemplateExpression.typeArguments!.elements.length) {
|
|
1457
|
-
this.abort();
|
|
1458
|
-
return taggedTemplateExpression;
|
|
1370
|
+
return this.abort(taggedTemplateExpression);
|
|
1459
1371
|
}
|
|
1460
1372
|
|
|
1461
1373
|
// Visit type arguments in lock step
|
|
@@ -1481,8 +1393,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1481
1393
|
*/
|
|
1482
1394
|
override async visitTemplateExpression(templateExpression: JS.TemplateExpression, other: J): Promise<J | undefined> {
|
|
1483
1395
|
if (!this.match || other.kind !== JS.Kind.TemplateExpression) {
|
|
1484
|
-
this.abort();
|
|
1485
|
-
return templateExpression;
|
|
1396
|
+
return this.abort(templateExpression);
|
|
1486
1397
|
}
|
|
1487
1398
|
|
|
1488
1399
|
const otherTemplateExpression = other as JS.TemplateExpression;
|
|
@@ -1493,8 +1404,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1493
1404
|
|
|
1494
1405
|
// Compare spans
|
|
1495
1406
|
if (templateExpression.spans.length !== otherTemplateExpression.spans.length) {
|
|
1496
|
-
this.abort();
|
|
1497
|
-
return templateExpression;
|
|
1407
|
+
return this.abort(templateExpression);
|
|
1498
1408
|
}
|
|
1499
1409
|
|
|
1500
1410
|
// Visit spans in lock step
|
|
@@ -1515,8 +1425,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1515
1425
|
*/
|
|
1516
1426
|
override async visitTemplateExpressionSpan(span: JS.TemplateExpression.Span, other: J): Promise<J | undefined> {
|
|
1517
1427
|
if (!this.match || other.kind !== JS.Kind.TemplateExpressionSpan) {
|
|
1518
|
-
this.abort();
|
|
1519
|
-
return span;
|
|
1428
|
+
return this.abort(span);
|
|
1520
1429
|
}
|
|
1521
1430
|
|
|
1522
1431
|
const otherSpan = other as JS.TemplateExpression.Span;
|
|
@@ -1540,16 +1449,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1540
1449
|
*/
|
|
1541
1450
|
override async visitTuple(tuple: JS.Tuple, other: J): Promise<J | undefined> {
|
|
1542
1451
|
if (!this.match || other.kind !== JS.Kind.Tuple) {
|
|
1543
|
-
this.abort();
|
|
1544
|
-
return tuple;
|
|
1452
|
+
return this.abort(tuple);
|
|
1545
1453
|
}
|
|
1546
1454
|
|
|
1547
1455
|
const otherTuple = other as JS.Tuple;
|
|
1548
1456
|
|
|
1549
1457
|
// Compare elements
|
|
1550
1458
|
if (tuple.elements.elements.length !== otherTuple.elements.elements.length) {
|
|
1551
|
-
this.abort();
|
|
1552
|
-
return tuple;
|
|
1459
|
+
return this.abort(tuple);
|
|
1553
1460
|
}
|
|
1554
1461
|
|
|
1555
1462
|
// Visit elements in lock step
|
|
@@ -1570,16 +1477,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1570
1477
|
*/
|
|
1571
1478
|
override async visitTypeDeclaration(typeDeclaration: JS.TypeDeclaration, other: J): Promise<J | undefined> {
|
|
1572
1479
|
if (!this.match || other.kind !== JS.Kind.TypeDeclaration) {
|
|
1573
|
-
this.abort();
|
|
1574
|
-
return typeDeclaration;
|
|
1480
|
+
return this.abort(typeDeclaration);
|
|
1575
1481
|
}
|
|
1576
1482
|
|
|
1577
1483
|
const otherTypeDeclaration = other as JS.TypeDeclaration;
|
|
1578
1484
|
|
|
1579
1485
|
// Compare modifiers
|
|
1580
1486
|
if (typeDeclaration.modifiers.length !== otherTypeDeclaration.modifiers.length) {
|
|
1581
|
-
this.abort();
|
|
1582
|
-
return typeDeclaration;
|
|
1487
|
+
return this.abort(typeDeclaration);
|
|
1583
1488
|
}
|
|
1584
1489
|
|
|
1585
1490
|
// Visit modifiers in lock step
|
|
@@ -1594,8 +1499,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1594
1499
|
|
|
1595
1500
|
// Compare type parameters
|
|
1596
1501
|
if (!!typeDeclaration.typeParameters !== !!otherTypeDeclaration.typeParameters) {
|
|
1597
|
-
this.abort();
|
|
1598
|
-
return typeDeclaration;
|
|
1502
|
+
return this.abort(typeDeclaration);
|
|
1599
1503
|
}
|
|
1600
1504
|
|
|
1601
1505
|
if (typeDeclaration.typeParameters) {
|
|
@@ -1618,8 +1522,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1618
1522
|
*/
|
|
1619
1523
|
override async visitTypeOf(typeOf: JS.TypeOf, other: J): Promise<J | undefined> {
|
|
1620
1524
|
if (!this.match || other.kind !== JS.Kind.TypeOf) {
|
|
1621
|
-
this.abort();
|
|
1622
|
-
return typeOf;
|
|
1525
|
+
return this.abort(typeOf);
|
|
1623
1526
|
}
|
|
1624
1527
|
|
|
1625
1528
|
const otherTypeOf = other as JS.TypeOf;
|
|
@@ -1639,8 +1542,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1639
1542
|
*/
|
|
1640
1543
|
override async visitTypeTreeExpression(typeTreeExpression: JS.TypeTreeExpression, other: J): Promise<J | undefined> {
|
|
1641
1544
|
if (!this.match || other.kind !== JS.Kind.TypeTreeExpression) {
|
|
1642
|
-
this.abort();
|
|
1643
|
-
return typeTreeExpression;
|
|
1545
|
+
return this.abort(typeTreeExpression);
|
|
1644
1546
|
}
|
|
1645
1547
|
|
|
1646
1548
|
const otherTypeTreeExpression = other as JS.TypeTreeExpression;
|
|
@@ -1660,8 +1562,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1660
1562
|
*/
|
|
1661
1563
|
override async visitAs(as_: JS.As, other: J): Promise<J | undefined> {
|
|
1662
1564
|
if (!this.match || other.kind !== JS.Kind.As) {
|
|
1663
|
-
this.abort();
|
|
1664
|
-
return as_;
|
|
1565
|
+
return this.abort(as_);
|
|
1665
1566
|
}
|
|
1666
1567
|
|
|
1667
1568
|
const otherAs = other as JS.As;
|
|
@@ -1683,8 +1584,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1683
1584
|
*/
|
|
1684
1585
|
override async visitAssignmentOperationExtensions(assignmentOperation: JS.AssignmentOperation, other: J): Promise<J | undefined> {
|
|
1685
1586
|
if (!this.match || other.kind !== JS.Kind.AssignmentOperation) {
|
|
1686
|
-
this.abort();
|
|
1687
|
-
return assignmentOperation;
|
|
1587
|
+
return this.abort(assignmentOperation);
|
|
1688
1588
|
}
|
|
1689
1589
|
|
|
1690
1590
|
const otherAssignmentOperation = other as JS.AssignmentOperation;
|
|
@@ -1695,8 +1595,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1695
1595
|
|
|
1696
1596
|
// Compare operator
|
|
1697
1597
|
if (assignmentOperation.operator.element !== otherAssignmentOperation.operator.element) {
|
|
1698
|
-
this.abort();
|
|
1699
|
-
return assignmentOperation;
|
|
1598
|
+
return this.abort(assignmentOperation);
|
|
1700
1599
|
}
|
|
1701
1600
|
|
|
1702
1601
|
// Visit assignment
|
|
@@ -1714,8 +1613,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1714
1613
|
*/
|
|
1715
1614
|
override async visitIndexedAccessType(indexedAccessType: JS.IndexedAccessType, other: J): Promise<J | undefined> {
|
|
1716
1615
|
if (!this.match || other.kind !== JS.Kind.IndexedAccessType) {
|
|
1717
|
-
this.abort();
|
|
1718
|
-
return indexedAccessType;
|
|
1616
|
+
return this.abort(indexedAccessType);
|
|
1719
1617
|
}
|
|
1720
1618
|
|
|
1721
1619
|
const otherIndexedAccessType = other as JS.IndexedAccessType;
|
|
@@ -1739,8 +1637,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1739
1637
|
*/
|
|
1740
1638
|
override async visitIndexedAccessTypeIndexType(indexType: JS.IndexedAccessType.IndexType, other: J): Promise<J | undefined> {
|
|
1741
1639
|
if (!this.match || other.kind !== JS.Kind.IndexType) {
|
|
1742
|
-
this.abort();
|
|
1743
|
-
return indexType;
|
|
1640
|
+
return this.abort(indexType);
|
|
1744
1641
|
}
|
|
1745
1642
|
|
|
1746
1643
|
const otherIndexType = other as JS.IndexedAccessType.IndexType;
|
|
@@ -1760,8 +1657,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1760
1657
|
*/
|
|
1761
1658
|
override async visitTypeQuery(typeQuery: JS.TypeQuery, other: J): Promise<J | undefined> {
|
|
1762
1659
|
if (!this.match || other.kind !== JS.Kind.TypeQuery) {
|
|
1763
|
-
this.abort();
|
|
1764
|
-
return typeQuery;
|
|
1660
|
+
return this.abort(typeQuery);
|
|
1765
1661
|
}
|
|
1766
1662
|
|
|
1767
1663
|
const otherTypeQuery = other as JS.TypeQuery;
|
|
@@ -1772,14 +1668,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1772
1668
|
|
|
1773
1669
|
// Compare type arguments
|
|
1774
1670
|
if (!!typeQuery.typeArguments !== !!otherTypeQuery.typeArguments) {
|
|
1775
|
-
this.abort();
|
|
1776
|
-
return typeQuery;
|
|
1671
|
+
return this.abort(typeQuery);
|
|
1777
1672
|
}
|
|
1778
1673
|
|
|
1779
1674
|
if (typeQuery.typeArguments) {
|
|
1780
1675
|
if (typeQuery.typeArguments.elements.length !== otherTypeQuery.typeArguments!.elements.length) {
|
|
1781
|
-
this.abort();
|
|
1782
|
-
return typeQuery;
|
|
1676
|
+
return this.abort(typeQuery);
|
|
1783
1677
|
}
|
|
1784
1678
|
|
|
1785
1679
|
// Visit type arguments in lock step
|
|
@@ -1802,8 +1696,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1802
1696
|
*/
|
|
1803
1697
|
override async visitTypeInfo(typeInfo: JS.TypeInfo, other: J): Promise<J | undefined> {
|
|
1804
1698
|
if (!this.match || other.kind !== JS.Kind.TypeInfo) {
|
|
1805
|
-
this.abort();
|
|
1806
|
-
return typeInfo;
|
|
1699
|
+
return this.abort(typeInfo);
|
|
1807
1700
|
}
|
|
1808
1701
|
|
|
1809
1702
|
const otherTypeInfo = other as JS.TypeInfo;
|
|
@@ -1823,8 +1716,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1823
1716
|
*/
|
|
1824
1717
|
override async visitComputedPropertyName(computedPropertyName: JS.ComputedPropertyName, other: J): Promise<J | undefined> {
|
|
1825
1718
|
if (!this.match || other.kind !== JS.Kind.ComputedPropertyName) {
|
|
1826
|
-
this.abort();
|
|
1827
|
-
return computedPropertyName;
|
|
1719
|
+
return this.abort(computedPropertyName);
|
|
1828
1720
|
}
|
|
1829
1721
|
|
|
1830
1722
|
const otherComputedPropertyName = other as JS.ComputedPropertyName;
|
|
@@ -1844,8 +1736,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1844
1736
|
*/
|
|
1845
1737
|
override async visitTypeOperator(typeOperator: JS.TypeOperator, other: J): Promise<J | undefined> {
|
|
1846
1738
|
if (!this.match || other.kind !== JS.Kind.TypeOperator) {
|
|
1847
|
-
this.abort();
|
|
1848
|
-
return typeOperator;
|
|
1739
|
+
return this.abort(typeOperator);
|
|
1849
1740
|
}
|
|
1850
1741
|
|
|
1851
1742
|
const otherTypeOperator = other as JS.TypeOperator;
|
|
@@ -1865,16 +1756,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1865
1756
|
*/
|
|
1866
1757
|
override async visitTypePredicate(typePredicate: JS.TypePredicate, other: J): Promise<J | undefined> {
|
|
1867
1758
|
if (!this.match || other.kind !== JS.Kind.TypePredicate) {
|
|
1868
|
-
this.abort();
|
|
1869
|
-
return typePredicate;
|
|
1759
|
+
return this.abort(typePredicate);
|
|
1870
1760
|
}
|
|
1871
1761
|
|
|
1872
1762
|
const otherTypePredicate = other as JS.TypePredicate;
|
|
1873
1763
|
|
|
1874
1764
|
// Compare asserts
|
|
1875
1765
|
if (typePredicate.asserts.element !== otherTypePredicate.asserts.element) {
|
|
1876
|
-
this.abort();
|
|
1877
|
-
return typePredicate;
|
|
1766
|
+
return this.abort(typePredicate);
|
|
1878
1767
|
}
|
|
1879
1768
|
|
|
1880
1769
|
// Visit parameter name
|
|
@@ -1883,8 +1772,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1883
1772
|
|
|
1884
1773
|
// Compare expression
|
|
1885
1774
|
if (!!typePredicate.expression !== !!otherTypePredicate.expression) {
|
|
1886
|
-
this.abort();
|
|
1887
|
-
return typePredicate;
|
|
1775
|
+
return this.abort(typePredicate);
|
|
1888
1776
|
}
|
|
1889
1777
|
|
|
1890
1778
|
if (typePredicate.expression) {
|
|
@@ -1903,16 +1791,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1903
1791
|
*/
|
|
1904
1792
|
override async visitUnion(union: JS.Union, other: J): Promise<J | undefined> {
|
|
1905
1793
|
if (!this.match || other.kind !== JS.Kind.Union) {
|
|
1906
|
-
this.abort();
|
|
1907
|
-
return union;
|
|
1794
|
+
return this.abort(union);
|
|
1908
1795
|
}
|
|
1909
1796
|
|
|
1910
1797
|
const otherUnion = other as JS.Union;
|
|
1911
1798
|
|
|
1912
1799
|
// Compare types
|
|
1913
1800
|
if (union.types.length !== otherUnion.types.length) {
|
|
1914
|
-
this.abort();
|
|
1915
|
-
return union;
|
|
1801
|
+
return this.abort(union);
|
|
1916
1802
|
}
|
|
1917
1803
|
|
|
1918
1804
|
// Visit types in lock step
|
|
@@ -1933,16 +1819,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1933
1819
|
*/
|
|
1934
1820
|
override async visitIntersection(intersection: JS.Intersection, other: J): Promise<J | undefined> {
|
|
1935
1821
|
if (!this.match || other.kind !== JS.Kind.Intersection) {
|
|
1936
|
-
this.abort();
|
|
1937
|
-
return intersection;
|
|
1822
|
+
return this.abort(intersection);
|
|
1938
1823
|
}
|
|
1939
1824
|
|
|
1940
1825
|
const otherIntersection = other as JS.Intersection;
|
|
1941
1826
|
|
|
1942
1827
|
// Compare types
|
|
1943
1828
|
if (intersection.types.length !== otherIntersection.types.length) {
|
|
1944
|
-
this.abort();
|
|
1945
|
-
return intersection;
|
|
1829
|
+
return this.abort(intersection);
|
|
1946
1830
|
}
|
|
1947
1831
|
|
|
1948
1832
|
// Visit types in lock step
|
|
@@ -1963,16 +1847,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1963
1847
|
*/
|
|
1964
1848
|
override async visitAnnotatedType(annotatedType: J.AnnotatedType, other: J): Promise<J | undefined> {
|
|
1965
1849
|
if (!this.match || other.kind !== J.Kind.AnnotatedType) {
|
|
1966
|
-
this.abort();
|
|
1967
|
-
return annotatedType;
|
|
1850
|
+
return this.abort(annotatedType);
|
|
1968
1851
|
}
|
|
1969
1852
|
|
|
1970
1853
|
const otherAnnotatedType = other as J.AnnotatedType;
|
|
1971
1854
|
|
|
1972
1855
|
// Compare annotations
|
|
1973
1856
|
if (annotatedType.annotations.length !== otherAnnotatedType.annotations.length) {
|
|
1974
|
-
this.abort();
|
|
1975
|
-
return annotatedType;
|
|
1857
|
+
return this.abort(annotatedType);
|
|
1976
1858
|
}
|
|
1977
1859
|
|
|
1978
1860
|
// Visit each annotation in lock step
|
|
@@ -1996,8 +1878,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
1996
1878
|
*/
|
|
1997
1879
|
override async visitAnnotation(annotation: J.Annotation, other: J): Promise<J | undefined> {
|
|
1998
1880
|
if (!this.match || other.kind !== J.Kind.Annotation) {
|
|
1999
|
-
this.abort();
|
|
2000
|
-
return annotation;
|
|
1881
|
+
return this.abort(annotation);
|
|
2001
1882
|
}
|
|
2002
1883
|
|
|
2003
1884
|
const otherAnnotation = other as J.Annotation;
|
|
@@ -2008,15 +1889,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2008
1889
|
|
|
2009
1890
|
// Compare arguments
|
|
2010
1891
|
if ((annotation.arguments === undefined) !== (otherAnnotation.arguments === undefined)) {
|
|
2011
|
-
this.abort();
|
|
2012
|
-
return annotation;
|
|
1892
|
+
return this.abort(annotation);
|
|
2013
1893
|
}
|
|
2014
1894
|
|
|
2015
1895
|
// If both have arguments, visit them
|
|
2016
1896
|
if (annotation.arguments && otherAnnotation.arguments) {
|
|
2017
1897
|
if (annotation.arguments.elements.length !== otherAnnotation.arguments.elements.length) {
|
|
2018
|
-
this.abort();
|
|
2019
|
-
return annotation;
|
|
1898
|
+
return this.abort(annotation);
|
|
2020
1899
|
}
|
|
2021
1900
|
|
|
2022
1901
|
// Visit each argument in lock step
|
|
@@ -2038,8 +1917,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2038
1917
|
*/
|
|
2039
1918
|
override async visitArrayAccess(arrayAccess: J.ArrayAccess, other: J): Promise<J | undefined> {
|
|
2040
1919
|
if (!this.match || other.kind !== J.Kind.ArrayAccess) {
|
|
2041
|
-
this.abort();
|
|
2042
|
-
return arrayAccess;
|
|
1920
|
+
return this.abort(arrayAccess);
|
|
2043
1921
|
}
|
|
2044
1922
|
|
|
2045
1923
|
const otherArrayAccess = other as J.ArrayAccess;
|
|
@@ -2063,8 +1941,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2063
1941
|
*/
|
|
2064
1942
|
override async visitArrayDimension(arrayDimension: J.ArrayDimension, other: J): Promise<J | undefined> {
|
|
2065
1943
|
if (!this.match || other.kind !== J.Kind.ArrayDimension) {
|
|
2066
|
-
this.abort();
|
|
2067
|
-
return arrayDimension;
|
|
1944
|
+
return this.abort(arrayDimension);
|
|
2068
1945
|
}
|
|
2069
1946
|
|
|
2070
1947
|
const otherArrayDimension = other as J.ArrayDimension;
|
|
@@ -2074,7 +1951,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2074
1951
|
await this.visit(arrayDimension.index.element, otherArrayDimension.index.element);
|
|
2075
1952
|
} else if (arrayDimension.index !== otherArrayDimension.index) {
|
|
2076
1953
|
// One has an index and the other doesn't
|
|
2077
|
-
this.abort();
|
|
1954
|
+
return this.abort(arrayDimension);
|
|
2078
1955
|
}
|
|
2079
1956
|
|
|
2080
1957
|
return arrayDimension;
|
|
@@ -2089,8 +1966,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2089
1966
|
*/
|
|
2090
1967
|
override async visitArrayType(arrayType: J.ArrayType, other: J): Promise<J | undefined> {
|
|
2091
1968
|
if (!this.match || other.kind !== J.Kind.ArrayType) {
|
|
2092
|
-
this.abort();
|
|
2093
|
-
return arrayType;
|
|
1969
|
+
return this.abort(arrayType);
|
|
2094
1970
|
}
|
|
2095
1971
|
|
|
2096
1972
|
const otherArrayType = other as J.ArrayType;
|
|
@@ -2101,8 +1977,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2101
1977
|
|
|
2102
1978
|
// Compare annotations
|
|
2103
1979
|
if ((arrayType.annotations?.length || 0) !== (otherArrayType.annotations?.length || 0)) {
|
|
2104
|
-
this.abort();
|
|
2105
|
-
return arrayType;
|
|
1980
|
+
return this.abort(arrayType);
|
|
2106
1981
|
}
|
|
2107
1982
|
|
|
2108
1983
|
// Visit annotations if they exist
|
|
@@ -2125,8 +2000,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2125
2000
|
*/
|
|
2126
2001
|
override async visitAssert(anAssert: J.Assert, other: J): Promise<J | undefined> {
|
|
2127
2002
|
if (!this.match || other.kind !== J.Kind.Assert) {
|
|
2128
|
-
this.abort();
|
|
2129
|
-
return anAssert;
|
|
2003
|
+
return this.abort(anAssert);
|
|
2130
2004
|
}
|
|
2131
2005
|
|
|
2132
2006
|
const otherAssert = other as J.Assert;
|
|
@@ -2137,8 +2011,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2137
2011
|
|
|
2138
2012
|
// Compare detail
|
|
2139
2013
|
if ((anAssert.detail !== undefined) !== (otherAssert.detail !== undefined)) {
|
|
2140
|
-
this.abort();
|
|
2141
|
-
return anAssert;
|
|
2014
|
+
return this.abort(anAssert);
|
|
2142
2015
|
}
|
|
2143
2016
|
|
|
2144
2017
|
// Visit detail if it exists
|
|
@@ -2158,8 +2031,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2158
2031
|
*/
|
|
2159
2032
|
override async visitAssignment(assignment: J.Assignment, other: J): Promise<J | undefined> {
|
|
2160
2033
|
if (!this.match || other.kind !== J.Kind.Assignment) {
|
|
2161
|
-
this.abort();
|
|
2162
|
-
return assignment;
|
|
2034
|
+
return this.abort(assignment);
|
|
2163
2035
|
}
|
|
2164
2036
|
|
|
2165
2037
|
const otherAssignment = other as J.Assignment;
|
|
@@ -2173,7 +2045,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2173
2045
|
await this.visit(assignment.assignment.element, otherAssignment.assignment.element);
|
|
2174
2046
|
} else if (assignment.assignment !== otherAssignment.assignment) {
|
|
2175
2047
|
// One has an assignment and the other doesn't
|
|
2176
|
-
this.abort();
|
|
2048
|
+
return this.abort(assignment);
|
|
2177
2049
|
}
|
|
2178
2050
|
|
|
2179
2051
|
return assignment;
|
|
@@ -2188,8 +2060,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2188
2060
|
*/
|
|
2189
2061
|
override async visitAssignmentOperation(assignOp: J.AssignmentOperation, other: J): Promise<J | undefined> {
|
|
2190
2062
|
if (!this.match || other.kind !== J.Kind.AssignmentOperation) {
|
|
2191
|
-
this.abort();
|
|
2192
|
-
return assignOp;
|
|
2063
|
+
return this.abort(assignOp);
|
|
2193
2064
|
}
|
|
2194
2065
|
|
|
2195
2066
|
const otherAssignOp = other as J.AssignmentOperation;
|
|
@@ -2200,8 +2071,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2200
2071
|
|
|
2201
2072
|
// Compare operator
|
|
2202
2073
|
if (assignOp.operator.element !== otherAssignOp.operator.element) {
|
|
2203
|
-
this.abort();
|
|
2204
|
-
return assignOp;
|
|
2074
|
+
return this.abort(assignOp);
|
|
2205
2075
|
}
|
|
2206
2076
|
|
|
2207
2077
|
// Visit assignment
|
|
@@ -2219,16 +2089,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2219
2089
|
*/
|
|
2220
2090
|
override async visitBreak(breakStatement: J.Break, other: J): Promise<J | undefined> {
|
|
2221
2091
|
if (!this.match || other.kind !== J.Kind.Break) {
|
|
2222
|
-
this.abort();
|
|
2223
|
-
return breakStatement;
|
|
2092
|
+
return this.abort(breakStatement);
|
|
2224
2093
|
}
|
|
2225
2094
|
|
|
2226
2095
|
const otherBreak = other as J.Break;
|
|
2227
2096
|
|
|
2228
2097
|
// Compare label presence
|
|
2229
2098
|
if ((breakStatement.label !== undefined) !== (otherBreak.label !== undefined)) {
|
|
2230
|
-
this.abort();
|
|
2231
|
-
return breakStatement;
|
|
2099
|
+
return this.abort(breakStatement);
|
|
2232
2100
|
}
|
|
2233
2101
|
|
|
2234
2102
|
// Visit label if it exists
|
|
@@ -2248,16 +2116,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2248
2116
|
*/
|
|
2249
2117
|
override async visitCase(aCase: J.Case, other: J): Promise<J | undefined> {
|
|
2250
2118
|
if (!this.match || other.kind !== J.Kind.Case) {
|
|
2251
|
-
this.abort();
|
|
2252
|
-
return aCase;
|
|
2119
|
+
return this.abort(aCase);
|
|
2253
2120
|
}
|
|
2254
2121
|
|
|
2255
2122
|
const otherCase = other as J.Case;
|
|
2256
2123
|
|
|
2257
2124
|
// Compare case labels
|
|
2258
2125
|
if (aCase.caseLabels.elements.length !== otherCase.caseLabels.elements.length) {
|
|
2259
|
-
this.abort();
|
|
2260
|
-
return aCase;
|
|
2126
|
+
return this.abort(aCase);
|
|
2261
2127
|
}
|
|
2262
2128
|
|
|
2263
2129
|
// Visit each case label in lock step
|
|
@@ -2268,8 +2134,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2268
2134
|
|
|
2269
2135
|
// Compare statements
|
|
2270
2136
|
if (aCase.statements.elements.length !== otherCase.statements.elements.length) {
|
|
2271
|
-
this.abort();
|
|
2272
|
-
return aCase;
|
|
2137
|
+
return this.abort(aCase);
|
|
2273
2138
|
}
|
|
2274
2139
|
|
|
2275
2140
|
// Visit each statement in lock step
|
|
@@ -2280,8 +2145,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2280
2145
|
|
|
2281
2146
|
// Compare body presence
|
|
2282
2147
|
if ((aCase.body !== undefined) !== (otherCase.body !== undefined)) {
|
|
2283
|
-
this.abort();
|
|
2284
|
-
return aCase;
|
|
2148
|
+
return this.abort(aCase);
|
|
2285
2149
|
}
|
|
2286
2150
|
|
|
2287
2151
|
// Visit body if it exists
|
|
@@ -2292,8 +2156,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2292
2156
|
|
|
2293
2157
|
// Compare guard presence
|
|
2294
2158
|
if ((aCase.guard !== undefined) !== (otherCase.guard !== undefined)) {
|
|
2295
|
-
this.abort();
|
|
2296
|
-
return aCase;
|
|
2159
|
+
return this.abort(aCase);
|
|
2297
2160
|
}
|
|
2298
2161
|
|
|
2299
2162
|
// Visit guard if it exists
|
|
@@ -2313,16 +2176,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2313
2176
|
*/
|
|
2314
2177
|
override async visitClassDeclaration(classDecl: J.ClassDeclaration, other: J): Promise<J | undefined> {
|
|
2315
2178
|
if (!this.match || other.kind !== J.Kind.ClassDeclaration) {
|
|
2316
|
-
this.abort();
|
|
2317
|
-
return classDecl;
|
|
2179
|
+
return this.abort(classDecl);
|
|
2318
2180
|
}
|
|
2319
2181
|
|
|
2320
2182
|
const otherClassDecl = other as J.ClassDeclaration;
|
|
2321
2183
|
|
|
2322
2184
|
// Compare leading annotations
|
|
2323
2185
|
if (classDecl.leadingAnnotations.length !== otherClassDecl.leadingAnnotations.length) {
|
|
2324
|
-
this.abort();
|
|
2325
|
-
return classDecl;
|
|
2186
|
+
return this.abort(classDecl);
|
|
2326
2187
|
}
|
|
2327
2188
|
|
|
2328
2189
|
// Visit each leading annotation in lock step
|
|
@@ -2333,8 +2194,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2333
2194
|
|
|
2334
2195
|
// Compare modifiers
|
|
2335
2196
|
if (classDecl.modifiers.length !== otherClassDecl.modifiers.length) {
|
|
2336
|
-
this.abort();
|
|
2337
|
-
return classDecl;
|
|
2197
|
+
return this.abort(classDecl);
|
|
2338
2198
|
}
|
|
2339
2199
|
|
|
2340
2200
|
// Visit each modifier in lock step
|
|
@@ -2353,15 +2213,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2353
2213
|
|
|
2354
2214
|
// Compare type parameters presence
|
|
2355
2215
|
if ((classDecl.typeParameters !== undefined) !== (otherClassDecl.typeParameters !== undefined)) {
|
|
2356
|
-
this.abort();
|
|
2357
|
-
return classDecl;
|
|
2216
|
+
return this.abort(classDecl);
|
|
2358
2217
|
}
|
|
2359
2218
|
|
|
2360
2219
|
// Visit type parameters if they exist
|
|
2361
2220
|
if (classDecl.typeParameters && otherClassDecl.typeParameters) {
|
|
2362
2221
|
if (classDecl.typeParameters.elements.length !== otherClassDecl.typeParameters.elements.length) {
|
|
2363
|
-
this.abort();
|
|
2364
|
-
return classDecl;
|
|
2222
|
+
return this.abort(classDecl);
|
|
2365
2223
|
}
|
|
2366
2224
|
|
|
2367
2225
|
// Visit each type parameter in lock step
|
|
@@ -2373,15 +2231,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2373
2231
|
|
|
2374
2232
|
// Compare primary constructor presence
|
|
2375
2233
|
if ((classDecl.primaryConstructor !== undefined) !== (otherClassDecl.primaryConstructor !== undefined)) {
|
|
2376
|
-
this.abort();
|
|
2377
|
-
return classDecl;
|
|
2234
|
+
return this.abort(classDecl);
|
|
2378
2235
|
}
|
|
2379
2236
|
|
|
2380
2237
|
// Visit primary constructor if it exists
|
|
2381
2238
|
if (classDecl.primaryConstructor && otherClassDecl.primaryConstructor) {
|
|
2382
2239
|
if (classDecl.primaryConstructor.elements.length !== otherClassDecl.primaryConstructor.elements.length) {
|
|
2383
|
-
this.abort();
|
|
2384
|
-
return classDecl;
|
|
2240
|
+
return this.abort(classDecl);
|
|
2385
2241
|
}
|
|
2386
2242
|
|
|
2387
2243
|
// Visit each primary constructor element in lock step
|
|
@@ -2393,8 +2249,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2393
2249
|
|
|
2394
2250
|
// Compare extends presence
|
|
2395
2251
|
if ((classDecl.extends !== undefined) !== (otherClassDecl.extends !== undefined)) {
|
|
2396
|
-
this.abort();
|
|
2397
|
-
return classDecl;
|
|
2252
|
+
return this.abort(classDecl);
|
|
2398
2253
|
}
|
|
2399
2254
|
|
|
2400
2255
|
// Visit extends if it exists
|
|
@@ -2405,15 +2260,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2405
2260
|
|
|
2406
2261
|
// Compare implements presence
|
|
2407
2262
|
if ((classDecl.implements !== undefined) !== (otherClassDecl.implements !== undefined)) {
|
|
2408
|
-
this.abort();
|
|
2409
|
-
return classDecl;
|
|
2263
|
+
return this.abort(classDecl);
|
|
2410
2264
|
}
|
|
2411
2265
|
|
|
2412
2266
|
// Visit implements if it exists
|
|
2413
2267
|
if (classDecl.implements && otherClassDecl.implements) {
|
|
2414
2268
|
if (classDecl.implements.elements.length !== otherClassDecl.implements.elements.length) {
|
|
2415
|
-
this.abort();
|
|
2416
|
-
return classDecl;
|
|
2269
|
+
return this.abort(classDecl);
|
|
2417
2270
|
}
|
|
2418
2271
|
|
|
2419
2272
|
// Visit each implements element in lock step
|
|
@@ -2425,15 +2278,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2425
2278
|
|
|
2426
2279
|
// Compare permitting presence
|
|
2427
2280
|
if ((classDecl.permitting !== undefined) !== (otherClassDecl.permitting !== undefined)) {
|
|
2428
|
-
this.abort();
|
|
2429
|
-
return classDecl;
|
|
2281
|
+
return this.abort(classDecl);
|
|
2430
2282
|
}
|
|
2431
2283
|
|
|
2432
2284
|
// Visit permitting if it exists
|
|
2433
2285
|
if (classDecl.permitting && otherClassDecl.permitting) {
|
|
2434
2286
|
if (classDecl.permitting.elements.length !== otherClassDecl.permitting.elements.length) {
|
|
2435
|
-
this.abort();
|
|
2436
|
-
return classDecl;
|
|
2287
|
+
return this.abort(classDecl);
|
|
2437
2288
|
}
|
|
2438
2289
|
|
|
2439
2290
|
// Visit each permitting element in lock step
|
|
@@ -2458,16 +2309,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2458
2309
|
*/
|
|
2459
2310
|
override async visitClassDeclarationKind(kind: J.ClassDeclaration.Kind, other: J): Promise<J | undefined> {
|
|
2460
2311
|
if (!this.match || other.kind !== J.Kind.ClassDeclarationKind) {
|
|
2461
|
-
this.abort();
|
|
2462
|
-
return kind;
|
|
2312
|
+
return this.abort(kind);
|
|
2463
2313
|
}
|
|
2464
2314
|
|
|
2465
2315
|
const otherKind = other as J.ClassDeclaration.Kind;
|
|
2466
2316
|
|
|
2467
2317
|
// Compare annotations
|
|
2468
2318
|
if (kind.annotations.length !== otherKind.annotations.length) {
|
|
2469
|
-
this.abort();
|
|
2470
|
-
return kind;
|
|
2319
|
+
return this.abort(kind);
|
|
2471
2320
|
}
|
|
2472
2321
|
|
|
2473
2322
|
// Visit each annotation in lock step
|
|
@@ -2488,16 +2337,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2488
2337
|
*/
|
|
2489
2338
|
override async visitCompilationUnit(compilationUnit: J.CompilationUnit, other: J): Promise<J | undefined> {
|
|
2490
2339
|
if (!this.match || other.kind !== J.Kind.CompilationUnit) {
|
|
2491
|
-
this.abort();
|
|
2492
|
-
return compilationUnit;
|
|
2340
|
+
return this.abort(compilationUnit);
|
|
2493
2341
|
}
|
|
2494
2342
|
|
|
2495
2343
|
const otherCompilationUnit = other as J.CompilationUnit;
|
|
2496
2344
|
|
|
2497
2345
|
// Compare package declaration presence
|
|
2498
2346
|
if ((compilationUnit.packageDeclaration !== undefined) !== (otherCompilationUnit.packageDeclaration !== undefined)) {
|
|
2499
|
-
this.abort();
|
|
2500
|
-
return compilationUnit;
|
|
2347
|
+
return this.abort(compilationUnit);
|
|
2501
2348
|
}
|
|
2502
2349
|
|
|
2503
2350
|
// Visit package declaration if it exists
|
|
@@ -2508,8 +2355,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2508
2355
|
|
|
2509
2356
|
// Compare imports
|
|
2510
2357
|
if (compilationUnit.imports.length !== otherCompilationUnit.imports.length) {
|
|
2511
|
-
this.abort();
|
|
2512
|
-
return compilationUnit;
|
|
2358
|
+
return this.abort(compilationUnit);
|
|
2513
2359
|
}
|
|
2514
2360
|
|
|
2515
2361
|
// Visit each import in lock step
|
|
@@ -2520,8 +2366,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2520
2366
|
|
|
2521
2367
|
// Compare classes
|
|
2522
2368
|
if (compilationUnit.classes.length !== otherCompilationUnit.classes.length) {
|
|
2523
|
-
this.abort();
|
|
2524
|
-
return compilationUnit;
|
|
2369
|
+
return this.abort(compilationUnit);
|
|
2525
2370
|
}
|
|
2526
2371
|
|
|
2527
2372
|
// Visit each class in lock step
|
|
@@ -2542,16 +2387,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2542
2387
|
*/
|
|
2543
2388
|
override async visitContinue(continueStatement: J.Continue, other: J): Promise<J | undefined> {
|
|
2544
2389
|
if (!this.match || other.kind !== J.Kind.Continue) {
|
|
2545
|
-
this.abort();
|
|
2546
|
-
return continueStatement;
|
|
2390
|
+
return this.abort(continueStatement);
|
|
2547
2391
|
}
|
|
2548
2392
|
|
|
2549
2393
|
const otherContinue = other as J.Continue;
|
|
2550
2394
|
|
|
2551
2395
|
// Compare label presence
|
|
2552
2396
|
if ((continueStatement.label !== undefined) !== (otherContinue.label !== undefined)) {
|
|
2553
|
-
this.abort();
|
|
2554
|
-
return continueStatement;
|
|
2397
|
+
return this.abort(continueStatement);
|
|
2555
2398
|
}
|
|
2556
2399
|
|
|
2557
2400
|
// Visit label if it exists
|
|
@@ -2571,8 +2414,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2571
2414
|
*/
|
|
2572
2415
|
override async visitControlParentheses<T extends J>(controlParens: J.ControlParentheses<T>, other: J): Promise<J | undefined> {
|
|
2573
2416
|
if (!this.match || other.kind !== J.Kind.ControlParentheses) {
|
|
2574
|
-
this.abort();
|
|
2575
|
-
return controlParens;
|
|
2417
|
+
return this.abort(controlParens);
|
|
2576
2418
|
}
|
|
2577
2419
|
|
|
2578
2420
|
const otherControlParens = other as J.ControlParentheses<J>;
|
|
@@ -2592,8 +2434,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2592
2434
|
*/
|
|
2593
2435
|
override async visitDeconstructionPattern(pattern: J.DeconstructionPattern, other: J): Promise<J | undefined> {
|
|
2594
2436
|
if (!this.match || other.kind !== J.Kind.DeconstructionPattern) {
|
|
2595
|
-
this.abort();
|
|
2596
|
-
return pattern;
|
|
2437
|
+
return this.abort(pattern);
|
|
2597
2438
|
}
|
|
2598
2439
|
|
|
2599
2440
|
const otherPattern = other as J.DeconstructionPattern;
|
|
@@ -2604,8 +2445,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2604
2445
|
|
|
2605
2446
|
// Compare nested elements
|
|
2606
2447
|
if (pattern.nested.elements.length !== otherPattern.nested.elements.length) {
|
|
2607
|
-
this.abort();
|
|
2608
|
-
return pattern;
|
|
2448
|
+
return this.abort(pattern);
|
|
2609
2449
|
}
|
|
2610
2450
|
|
|
2611
2451
|
// Visit each nested element in lock step
|
|
@@ -2626,8 +2466,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2626
2466
|
*/
|
|
2627
2467
|
override async visitDoWhileLoop(doWhileLoop: J.DoWhileLoop, other: J): Promise<J | undefined> {
|
|
2628
2468
|
if (!this.match || other.kind !== J.Kind.DoWhileLoop) {
|
|
2629
|
-
this.abort();
|
|
2630
|
-
return doWhileLoop;
|
|
2469
|
+
return this.abort(doWhileLoop);
|
|
2631
2470
|
}
|
|
2632
2471
|
|
|
2633
2472
|
const otherDoWhileLoop = other as J.DoWhileLoop;
|
|
@@ -2651,8 +2490,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2651
2490
|
*/
|
|
2652
2491
|
override async visitEmpty(empty: J.Empty, other: J): Promise<J | undefined> {
|
|
2653
2492
|
if (!this.match || other.kind !== J.Kind.Empty) {
|
|
2654
|
-
this.abort();
|
|
2655
|
-
return empty;
|
|
2493
|
+
return this.abort(empty);
|
|
2656
2494
|
}
|
|
2657
2495
|
|
|
2658
2496
|
// Empty statements have no properties to compare, so we just check the kind
|
|
@@ -2669,16 +2507,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2669
2507
|
*/
|
|
2670
2508
|
override async visitEnumValue(enumValue: J.EnumValue, other: J): Promise<J | undefined> {
|
|
2671
2509
|
if (!this.match || other.kind !== J.Kind.EnumValue) {
|
|
2672
|
-
this.abort();
|
|
2673
|
-
return enumValue;
|
|
2510
|
+
return this.abort(enumValue);
|
|
2674
2511
|
}
|
|
2675
2512
|
|
|
2676
2513
|
const otherEnumValue = other as J.EnumValue;
|
|
2677
2514
|
|
|
2678
2515
|
// Compare annotations
|
|
2679
2516
|
if (enumValue.annotations.length !== otherEnumValue.annotations.length) {
|
|
2680
|
-
this.abort();
|
|
2681
|
-
return enumValue;
|
|
2517
|
+
return this.abort(enumValue);
|
|
2682
2518
|
}
|
|
2683
2519
|
|
|
2684
2520
|
// Visit each annotation in lock step
|
|
@@ -2693,8 +2529,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2693
2529
|
|
|
2694
2530
|
// Compare initializer presence
|
|
2695
2531
|
if ((enumValue.initializer !== undefined) !== (otherEnumValue.initializer !== undefined)) {
|
|
2696
|
-
this.abort();
|
|
2697
|
-
return enumValue;
|
|
2532
|
+
return this.abort(enumValue);
|
|
2698
2533
|
}
|
|
2699
2534
|
|
|
2700
2535
|
// Visit initializer if it exists
|
|
@@ -2714,16 +2549,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2714
2549
|
*/
|
|
2715
2550
|
override async visitEnumValueSet(enumValueSet: J.EnumValueSet, other: J): Promise<J | undefined> {
|
|
2716
2551
|
if (!this.match || other.kind !== J.Kind.EnumValueSet) {
|
|
2717
|
-
this.abort();
|
|
2718
|
-
return enumValueSet;
|
|
2552
|
+
return this.abort(enumValueSet);
|
|
2719
2553
|
}
|
|
2720
2554
|
|
|
2721
2555
|
const otherEnumValueSet = other as J.EnumValueSet;
|
|
2722
2556
|
|
|
2723
2557
|
// Compare enums
|
|
2724
2558
|
if (enumValueSet.enums.length !== otherEnumValueSet.enums.length) {
|
|
2725
|
-
this.abort();
|
|
2726
|
-
return enumValueSet;
|
|
2559
|
+
return this.abort(enumValueSet);
|
|
2727
2560
|
}
|
|
2728
2561
|
|
|
2729
2562
|
// Visit each enum in lock step
|
|
@@ -2744,16 +2577,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2744
2577
|
*/
|
|
2745
2578
|
override async visitErroneous(erroneous: J.Erroneous, other: J): Promise<J | undefined> {
|
|
2746
2579
|
if (!this.match || other.kind !== J.Kind.Erroneous) {
|
|
2747
|
-
this.abort();
|
|
2748
|
-
return erroneous;
|
|
2580
|
+
return this.abort(erroneous);
|
|
2749
2581
|
}
|
|
2750
2582
|
|
|
2751
2583
|
const otherErroneous = other as J.Erroneous;
|
|
2752
2584
|
|
|
2753
2585
|
// Compare text
|
|
2754
2586
|
if (erroneous.text !== otherErroneous.text) {
|
|
2755
|
-
this.abort();
|
|
2756
|
-
return erroneous;
|
|
2587
|
+
return this.abort(erroneous);
|
|
2757
2588
|
}
|
|
2758
2589
|
|
|
2759
2590
|
return erroneous;
|
|
@@ -2768,8 +2599,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2768
2599
|
*/
|
|
2769
2600
|
override async visitFieldAccess(fieldAccess: J.FieldAccess, other: J): Promise<J | undefined> {
|
|
2770
2601
|
if (!this.match || other.kind !== J.Kind.FieldAccess) {
|
|
2771
|
-
this.abort();
|
|
2772
|
-
return fieldAccess;
|
|
2602
|
+
return this.abort(fieldAccess);
|
|
2773
2603
|
}
|
|
2774
2604
|
|
|
2775
2605
|
const otherFieldAccess = other as J.FieldAccess;
|
|
@@ -2794,8 +2624,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2794
2624
|
*/
|
|
2795
2625
|
override async visitForEachLoop(forEachLoop: J.ForEachLoop, other: J): Promise<J | undefined> {
|
|
2796
2626
|
if (!this.match || other.kind !== J.Kind.ForEachLoop) {
|
|
2797
|
-
this.abort();
|
|
2798
|
-
return forEachLoop;
|
|
2627
|
+
return this.abort(forEachLoop);
|
|
2799
2628
|
}
|
|
2800
2629
|
|
|
2801
2630
|
const otherForEachLoop = other as J.ForEachLoop;
|
|
@@ -2820,8 +2649,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2820
2649
|
*/
|
|
2821
2650
|
override async visitForEachLoopControl(control: J.ForEachLoop.Control, other: J): Promise<J | undefined> {
|
|
2822
2651
|
if (!this.match || other.kind !== J.Kind.ForEachLoopControl) {
|
|
2823
|
-
this.abort();
|
|
2824
|
-
return control;
|
|
2652
|
+
return this.abort(control);
|
|
2825
2653
|
}
|
|
2826
2654
|
|
|
2827
2655
|
const otherControl = other as J.ForEachLoop.Control;
|
|
@@ -2846,8 +2674,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2846
2674
|
*/
|
|
2847
2675
|
override async visitForLoop(forLoop: J.ForLoop, other: J): Promise<J | undefined> {
|
|
2848
2676
|
if (!this.match || other.kind !== J.Kind.ForLoop) {
|
|
2849
|
-
this.abort();
|
|
2850
|
-
return forLoop;
|
|
2677
|
+
return this.abort(forLoop);
|
|
2851
2678
|
}
|
|
2852
2679
|
|
|
2853
2680
|
const otherForLoop = other as J.ForLoop;
|
|
@@ -2872,16 +2699,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2872
2699
|
*/
|
|
2873
2700
|
override async visitForLoopControl(control: J.ForLoop.Control, other: J): Promise<J | undefined> {
|
|
2874
2701
|
if (!this.match || other.kind !== J.Kind.ForLoopControl) {
|
|
2875
|
-
this.abort();
|
|
2876
|
-
return control;
|
|
2702
|
+
return this.abort(control);
|
|
2877
2703
|
}
|
|
2878
2704
|
|
|
2879
2705
|
const otherControl = other as J.ForLoop.Control;
|
|
2880
2706
|
|
|
2881
2707
|
// Compare init statements
|
|
2882
2708
|
if (control.init.length !== otherControl.init.length) {
|
|
2883
|
-
this.abort();
|
|
2884
|
-
return control;
|
|
2709
|
+
return this.abort(control);
|
|
2885
2710
|
}
|
|
2886
2711
|
|
|
2887
2712
|
// Visit each init statement in lock step
|
|
@@ -2892,8 +2717,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2892
2717
|
|
|
2893
2718
|
// Compare condition
|
|
2894
2719
|
if ((control.condition === undefined) !== (otherControl.condition === undefined)) {
|
|
2895
|
-
this.abort();
|
|
2896
|
-
return control;
|
|
2720
|
+
return this.abort(control);
|
|
2897
2721
|
}
|
|
2898
2722
|
|
|
2899
2723
|
// Visit condition if present
|
|
@@ -2904,8 +2728,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2904
2728
|
|
|
2905
2729
|
// Compare update statements
|
|
2906
2730
|
if (control.update.length !== otherControl.update.length) {
|
|
2907
|
-
this.abort();
|
|
2908
|
-
return control;
|
|
2731
|
+
return this.abort(control);
|
|
2909
2732
|
}
|
|
2910
2733
|
|
|
2911
2734
|
// Visit each update statement in lock step
|
|
@@ -2926,8 +2749,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2926
2749
|
*/
|
|
2927
2750
|
override async visitIf(ifStatement: J.If, other: J): Promise<J | undefined> {
|
|
2928
2751
|
if (!this.match || other.kind !== J.Kind.If) {
|
|
2929
|
-
this.abort();
|
|
2930
|
-
return ifStatement;
|
|
2752
|
+
return this.abort(ifStatement);
|
|
2931
2753
|
}
|
|
2932
2754
|
|
|
2933
2755
|
const otherIfStatement = other as J.If;
|
|
@@ -2942,8 +2764,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2942
2764
|
|
|
2943
2765
|
// Compare else part
|
|
2944
2766
|
if ((ifStatement.elsePart === undefined) !== (otherIfStatement.elsePart === undefined)) {
|
|
2945
|
-
this.abort();
|
|
2946
|
-
return ifStatement;
|
|
2767
|
+
return this.abort(ifStatement);
|
|
2947
2768
|
}
|
|
2948
2769
|
|
|
2949
2770
|
// Visit else part if present
|
|
@@ -2964,8 +2785,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2964
2785
|
*/
|
|
2965
2786
|
override async visitElse(elseStatement: J.If.Else, other: J): Promise<J | undefined> {
|
|
2966
2787
|
if (!this.match || other.kind !== J.Kind.IfElse) {
|
|
2967
|
-
this.abort();
|
|
2968
|
-
return elseStatement;
|
|
2788
|
+
return this.abort(elseStatement);
|
|
2969
2789
|
}
|
|
2970
2790
|
|
|
2971
2791
|
const otherElseStatement = other as J.If.Else;
|
|
@@ -2986,16 +2806,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
2986
2806
|
*/
|
|
2987
2807
|
override async visitImport(importStatement: J.Import, other: J): Promise<J | undefined> {
|
|
2988
2808
|
if (!this.match || other.kind !== J.Kind.Import) {
|
|
2989
|
-
this.abort();
|
|
2990
|
-
return importStatement;
|
|
2809
|
+
return this.abort(importStatement);
|
|
2991
2810
|
}
|
|
2992
2811
|
|
|
2993
2812
|
const otherImportStatement = other as J.Import;
|
|
2994
2813
|
|
|
2995
2814
|
// Compare static
|
|
2996
2815
|
if (importStatement.static.element !== otherImportStatement.static.element) {
|
|
2997
|
-
this.abort();
|
|
2998
|
-
return importStatement;
|
|
2816
|
+
return this.abort(importStatement);
|
|
2999
2817
|
}
|
|
3000
2818
|
|
|
3001
2819
|
// Visit qualid
|
|
@@ -3004,8 +2822,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3004
2822
|
|
|
3005
2823
|
// Compare alias
|
|
3006
2824
|
if ((importStatement.alias === undefined) !== (otherImportStatement.alias === undefined)) {
|
|
3007
|
-
this.abort();
|
|
3008
|
-
return importStatement;
|
|
2825
|
+
return this.abort(importStatement);
|
|
3009
2826
|
}
|
|
3010
2827
|
|
|
3011
2828
|
// Visit alias if present
|
|
@@ -3026,8 +2843,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3026
2843
|
*/
|
|
3027
2844
|
override async visitInstanceOf(instanceOf: J.InstanceOf, other: J): Promise<J | undefined> {
|
|
3028
2845
|
if (!this.match || other.kind !== J.Kind.InstanceOf) {
|
|
3029
|
-
this.abort();
|
|
3030
|
-
return instanceOf;
|
|
2846
|
+
return this.abort(instanceOf);
|
|
3031
2847
|
}
|
|
3032
2848
|
|
|
3033
2849
|
const otherInstanceOf = other as J.InstanceOf;
|
|
@@ -3042,8 +2858,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3042
2858
|
|
|
3043
2859
|
// Compare pattern
|
|
3044
2860
|
if ((instanceOf.pattern === undefined) !== (otherInstanceOf.pattern === undefined)) {
|
|
3045
|
-
this.abort();
|
|
3046
|
-
return instanceOf;
|
|
2861
|
+
return this.abort(instanceOf);
|
|
3047
2862
|
}
|
|
3048
2863
|
|
|
3049
2864
|
// Visit pattern if present
|
|
@@ -3054,8 +2869,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3054
2869
|
|
|
3055
2870
|
// Compare modifier
|
|
3056
2871
|
if ((instanceOf.modifier === undefined) !== (otherInstanceOf.modifier === undefined)) {
|
|
3057
|
-
this.abort();
|
|
3058
|
-
return instanceOf;
|
|
2872
|
+
return this.abort(instanceOf);
|
|
3059
2873
|
}
|
|
3060
2874
|
|
|
3061
2875
|
// Visit modifier if present
|
|
@@ -3076,16 +2890,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3076
2890
|
*/
|
|
3077
2891
|
override async visitIntersectionType(intersectionType: J.IntersectionType, other: J): Promise<J | undefined> {
|
|
3078
2892
|
if (!this.match || other.kind !== J.Kind.IntersectionType) {
|
|
3079
|
-
this.abort();
|
|
3080
|
-
return intersectionType;
|
|
2893
|
+
return this.abort(intersectionType);
|
|
3081
2894
|
}
|
|
3082
2895
|
|
|
3083
2896
|
const otherIntersectionType = other as J.IntersectionType;
|
|
3084
2897
|
|
|
3085
2898
|
// Compare bounds
|
|
3086
2899
|
if (intersectionType.bounds.elements.length !== otherIntersectionType.bounds.elements.length) {
|
|
3087
|
-
this.abort();
|
|
3088
|
-
return intersectionType;
|
|
2900
|
+
return this.abort(intersectionType);
|
|
3089
2901
|
}
|
|
3090
2902
|
|
|
3091
2903
|
// Visit each bound in lock step
|
|
@@ -3106,8 +2918,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3106
2918
|
*/
|
|
3107
2919
|
override async visitLabel(label: J.Label, other: J): Promise<J | undefined> {
|
|
3108
2920
|
if (!this.match || other.kind !== J.Kind.Label) {
|
|
3109
|
-
this.abort();
|
|
3110
|
-
return label;
|
|
2921
|
+
return this.abort(label);
|
|
3111
2922
|
}
|
|
3112
2923
|
|
|
3113
2924
|
const otherLabel = other as J.Label;
|
|
@@ -3132,8 +2943,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3132
2943
|
*/
|
|
3133
2944
|
override async visitLambda(lambda: J.Lambda, other: J): Promise<J | undefined> {
|
|
3134
2945
|
if (!this.match || other.kind !== J.Kind.Lambda) {
|
|
3135
|
-
this.abort();
|
|
3136
|
-
return lambda;
|
|
2946
|
+
return this.abort(lambda);
|
|
3137
2947
|
}
|
|
3138
2948
|
|
|
3139
2949
|
const otherLambda = other as J.Lambda;
|
|
@@ -3158,22 +2968,19 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3158
2968
|
*/
|
|
3159
2969
|
override async visitLambdaParameters(parameters: J.Lambda.Parameters, other: J): Promise<J | undefined> {
|
|
3160
2970
|
if (!this.match || other.kind !== J.Kind.LambdaParameters) {
|
|
3161
|
-
this.abort();
|
|
3162
|
-
return parameters;
|
|
2971
|
+
return this.abort(parameters);
|
|
3163
2972
|
}
|
|
3164
2973
|
|
|
3165
2974
|
const otherParameters = other as J.Lambda.Parameters;
|
|
3166
2975
|
|
|
3167
2976
|
// Compare parenthesized
|
|
3168
2977
|
if (parameters.parenthesized !== otherParameters.parenthesized) {
|
|
3169
|
-
this.abort();
|
|
3170
|
-
return parameters;
|
|
2978
|
+
return this.abort(parameters);
|
|
3171
2979
|
}
|
|
3172
2980
|
|
|
3173
2981
|
// Compare parameters
|
|
3174
2982
|
if (parameters.parameters.length !== otherParameters.parameters.length) {
|
|
3175
|
-
this.abort();
|
|
3176
|
-
return parameters;
|
|
2983
|
+
return this.abort(parameters);
|
|
3177
2984
|
}
|
|
3178
2985
|
|
|
3179
2986
|
// Visit each parameter in lock step
|
|
@@ -3194,8 +3001,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3194
3001
|
*/
|
|
3195
3002
|
override async visitMemberReference(memberReference: J.MemberReference, other: J): Promise<J | undefined> {
|
|
3196
3003
|
if (!this.match || other.kind !== J.Kind.MemberReference) {
|
|
3197
|
-
this.abort();
|
|
3198
|
-
return memberReference;
|
|
3004
|
+
return this.abort(memberReference);
|
|
3199
3005
|
}
|
|
3200
3006
|
|
|
3201
3007
|
const otherMemberReference = other as J.MemberReference;
|
|
@@ -3206,15 +3012,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3206
3012
|
|
|
3207
3013
|
// Compare typeParameters
|
|
3208
3014
|
if ((memberReference.typeParameters === undefined) !== (otherMemberReference.typeParameters === undefined)) {
|
|
3209
|
-
this.abort();
|
|
3210
|
-
return memberReference;
|
|
3015
|
+
return this.abort(memberReference);
|
|
3211
3016
|
}
|
|
3212
3017
|
|
|
3213
3018
|
// Visit typeParameters if present
|
|
3214
3019
|
if (memberReference.typeParameters && otherMemberReference.typeParameters) {
|
|
3215
3020
|
if (memberReference.typeParameters.elements.length !== otherMemberReference.typeParameters.elements.length) {
|
|
3216
|
-
this.abort();
|
|
3217
|
-
return memberReference;
|
|
3021
|
+
return this.abort(memberReference);
|
|
3218
3022
|
}
|
|
3219
3023
|
|
|
3220
3024
|
// Visit each type parameter in lock step
|
|
@@ -3240,16 +3044,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3240
3044
|
*/
|
|
3241
3045
|
override async visitMethodDeclaration(methodDeclaration: J.MethodDeclaration, other: J): Promise<J | undefined> {
|
|
3242
3046
|
if (!this.match || other.kind !== J.Kind.MethodDeclaration) {
|
|
3243
|
-
this.abort();
|
|
3244
|
-
return methodDeclaration;
|
|
3047
|
+
return this.abort(methodDeclaration);
|
|
3245
3048
|
}
|
|
3246
3049
|
|
|
3247
3050
|
const otherMethodDeclaration = other as J.MethodDeclaration;
|
|
3248
3051
|
|
|
3249
3052
|
// Compare leadingAnnotations
|
|
3250
3053
|
if (methodDeclaration.leadingAnnotations.length !== otherMethodDeclaration.leadingAnnotations.length) {
|
|
3251
|
-
this.abort();
|
|
3252
|
-
return methodDeclaration;
|
|
3054
|
+
return this.abort(methodDeclaration);
|
|
3253
3055
|
}
|
|
3254
3056
|
|
|
3255
3057
|
// Visit each leading annotation in lock step
|
|
@@ -3260,8 +3062,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3260
3062
|
|
|
3261
3063
|
// Compare modifiers
|
|
3262
3064
|
if (methodDeclaration.modifiers.length !== otherMethodDeclaration.modifiers.length) {
|
|
3263
|
-
this.abort();
|
|
3264
|
-
return methodDeclaration;
|
|
3065
|
+
return this.abort(methodDeclaration);
|
|
3265
3066
|
}
|
|
3266
3067
|
|
|
3267
3068
|
// Visit each modifier in lock step
|
|
@@ -3272,8 +3073,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3272
3073
|
|
|
3273
3074
|
// Compare typeParameters
|
|
3274
3075
|
if ((methodDeclaration.typeParameters === undefined) !== (otherMethodDeclaration.typeParameters === undefined)) {
|
|
3275
|
-
this.abort();
|
|
3276
|
-
return methodDeclaration;
|
|
3076
|
+
return this.abort(methodDeclaration);
|
|
3277
3077
|
}
|
|
3278
3078
|
|
|
3279
3079
|
// Visit typeParameters if present
|
|
@@ -3284,8 +3084,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3284
3084
|
|
|
3285
3085
|
// Compare returnTypeExpression
|
|
3286
3086
|
if ((methodDeclaration.returnTypeExpression === undefined) !== (otherMethodDeclaration.returnTypeExpression === undefined)) {
|
|
3287
|
-
this.abort();
|
|
3288
|
-
return methodDeclaration;
|
|
3087
|
+
return this.abort(methodDeclaration);
|
|
3289
3088
|
}
|
|
3290
3089
|
|
|
3291
3090
|
// Visit returnTypeExpression if present
|
|
@@ -3296,8 +3095,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3296
3095
|
|
|
3297
3096
|
// Compare nameAnnotations
|
|
3298
3097
|
if (methodDeclaration.nameAnnotations.length !== otherMethodDeclaration.nameAnnotations.length) {
|
|
3299
|
-
this.abort();
|
|
3300
|
-
return methodDeclaration;
|
|
3098
|
+
return this.abort(methodDeclaration);
|
|
3301
3099
|
}
|
|
3302
3100
|
|
|
3303
3101
|
// Visit each name annotation in lock step
|
|
@@ -3312,8 +3110,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3312
3110
|
|
|
3313
3111
|
// Compare parameters
|
|
3314
3112
|
if (methodDeclaration.parameters.elements.length !== otherMethodDeclaration.parameters.elements.length) {
|
|
3315
|
-
this.abort();
|
|
3316
|
-
return methodDeclaration;
|
|
3113
|
+
return this.abort(methodDeclaration);
|
|
3317
3114
|
}
|
|
3318
3115
|
|
|
3319
3116
|
// Visit each parameter in lock step
|
|
@@ -3324,15 +3121,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3324
3121
|
|
|
3325
3122
|
// Compare throws
|
|
3326
3123
|
if ((methodDeclaration.throws === undefined) !== (otherMethodDeclaration.throws === undefined)) {
|
|
3327
|
-
this.abort();
|
|
3328
|
-
return methodDeclaration;
|
|
3124
|
+
return this.abort(methodDeclaration);
|
|
3329
3125
|
}
|
|
3330
3126
|
|
|
3331
3127
|
// Visit throws if present
|
|
3332
3128
|
if (methodDeclaration.throws && otherMethodDeclaration.throws) {
|
|
3333
3129
|
if (methodDeclaration.throws.elements.length !== otherMethodDeclaration.throws.elements.length) {
|
|
3334
|
-
this.abort();
|
|
3335
|
-
return methodDeclaration;
|
|
3130
|
+
return this.abort(methodDeclaration);
|
|
3336
3131
|
}
|
|
3337
3132
|
|
|
3338
3133
|
// Visit each throw in lock step
|
|
@@ -3344,8 +3139,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3344
3139
|
|
|
3345
3140
|
// Compare body
|
|
3346
3141
|
if ((methodDeclaration.body === undefined) !== (otherMethodDeclaration.body === undefined)) {
|
|
3347
|
-
this.abort();
|
|
3348
|
-
return methodDeclaration;
|
|
3142
|
+
return this.abort(methodDeclaration);
|
|
3349
3143
|
}
|
|
3350
3144
|
|
|
3351
3145
|
// Visit body if present
|
|
@@ -3356,8 +3150,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3356
3150
|
|
|
3357
3151
|
// Compare defaultValue
|
|
3358
3152
|
if ((methodDeclaration.defaultValue === undefined) !== (otherMethodDeclaration.defaultValue === undefined)) {
|
|
3359
|
-
this.abort();
|
|
3360
|
-
return methodDeclaration;
|
|
3153
|
+
return this.abort(methodDeclaration);
|
|
3361
3154
|
}
|
|
3362
3155
|
|
|
3363
3156
|
// Visit defaultValue if present
|
|
@@ -3378,16 +3171,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3378
3171
|
*/
|
|
3379
3172
|
override async visitMethodInvocation(methodInvocation: J.MethodInvocation, other: J): Promise<J | undefined> {
|
|
3380
3173
|
if (!this.match || other.kind !== J.Kind.MethodInvocation) {
|
|
3381
|
-
this.abort();
|
|
3382
|
-
return methodInvocation;
|
|
3174
|
+
return this.abort(methodInvocation);
|
|
3383
3175
|
}
|
|
3384
3176
|
|
|
3385
3177
|
const otherMethodInvocation = other as J.MethodInvocation;
|
|
3386
3178
|
|
|
3387
3179
|
// Compare select
|
|
3388
3180
|
if ((methodInvocation.select === undefined) !== (otherMethodInvocation.select === undefined)) {
|
|
3389
|
-
this.abort();
|
|
3390
|
-
return methodInvocation;
|
|
3181
|
+
return this.abort(methodInvocation);
|
|
3391
3182
|
}
|
|
3392
3183
|
|
|
3393
3184
|
// Visit select if present
|
|
@@ -3398,15 +3189,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3398
3189
|
|
|
3399
3190
|
// Compare typeParameters
|
|
3400
3191
|
if ((methodInvocation.typeParameters === undefined) !== (otherMethodInvocation.typeParameters === undefined)) {
|
|
3401
|
-
this.abort();
|
|
3402
|
-
return methodInvocation;
|
|
3192
|
+
return this.abort(methodInvocation);
|
|
3403
3193
|
}
|
|
3404
3194
|
|
|
3405
3195
|
// Visit typeParameters if present
|
|
3406
3196
|
if (methodInvocation.typeParameters && otherMethodInvocation.typeParameters) {
|
|
3407
3197
|
if (methodInvocation.typeParameters.elements.length !== otherMethodInvocation.typeParameters.elements.length) {
|
|
3408
|
-
this.abort();
|
|
3409
|
-
return methodInvocation;
|
|
3198
|
+
return this.abort(methodInvocation);
|
|
3410
3199
|
}
|
|
3411
3200
|
|
|
3412
3201
|
// Visit each type parameter in lock step
|
|
@@ -3422,8 +3211,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3422
3211
|
|
|
3423
3212
|
// Compare arguments
|
|
3424
3213
|
if (methodInvocation.arguments.elements.length !== otherMethodInvocation.arguments.elements.length) {
|
|
3425
|
-
this.abort();
|
|
3426
|
-
return methodInvocation;
|
|
3214
|
+
return this.abort(methodInvocation);
|
|
3427
3215
|
}
|
|
3428
3216
|
|
|
3429
3217
|
// Visit each argument in lock step
|
|
@@ -3444,28 +3232,24 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3444
3232
|
*/
|
|
3445
3233
|
override async visitModifier(modifier: J.Modifier, other: J): Promise<J | undefined> {
|
|
3446
3234
|
if (!this.match || other.kind !== J.Kind.Modifier) {
|
|
3447
|
-
this.abort();
|
|
3448
|
-
return modifier;
|
|
3235
|
+
return this.abort(modifier);
|
|
3449
3236
|
}
|
|
3450
3237
|
|
|
3451
3238
|
const otherModifier = other as J.Modifier;
|
|
3452
3239
|
|
|
3453
3240
|
// Compare keyword
|
|
3454
3241
|
if (modifier.keyword !== otherModifier.keyword) {
|
|
3455
|
-
this.abort();
|
|
3456
|
-
return modifier;
|
|
3242
|
+
return this.abort(modifier);
|
|
3457
3243
|
}
|
|
3458
3244
|
|
|
3459
3245
|
// Compare type
|
|
3460
3246
|
if (modifier.type !== otherModifier.type) {
|
|
3461
|
-
this.abort();
|
|
3462
|
-
return modifier;
|
|
3247
|
+
return this.abort(modifier);
|
|
3463
3248
|
}
|
|
3464
3249
|
|
|
3465
3250
|
// Compare annotations
|
|
3466
3251
|
if (modifier.annotations.length !== otherModifier.annotations.length) {
|
|
3467
|
-
this.abort();
|
|
3468
|
-
return modifier;
|
|
3252
|
+
return this.abort(modifier);
|
|
3469
3253
|
}
|
|
3470
3254
|
|
|
3471
3255
|
// Visit each annotation in lock step
|
|
@@ -3486,16 +3270,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3486
3270
|
*/
|
|
3487
3271
|
override async visitMultiCatch(multiCatch: J.MultiCatch, other: J): Promise<J | undefined> {
|
|
3488
3272
|
if (!this.match || other.kind !== J.Kind.MultiCatch) {
|
|
3489
|
-
this.abort();
|
|
3490
|
-
return multiCatch;
|
|
3273
|
+
return this.abort(multiCatch);
|
|
3491
3274
|
}
|
|
3492
3275
|
|
|
3493
3276
|
const otherMultiCatch = other as J.MultiCatch;
|
|
3494
3277
|
|
|
3495
3278
|
// Compare alternatives
|
|
3496
3279
|
if (multiCatch.alternatives.length !== otherMultiCatch.alternatives.length) {
|
|
3497
|
-
this.abort();
|
|
3498
|
-
return multiCatch;
|
|
3280
|
+
return this.abort(multiCatch);
|
|
3499
3281
|
}
|
|
3500
3282
|
|
|
3501
3283
|
// Visit each alternative in lock step
|
|
@@ -3516,16 +3298,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3516
3298
|
*/
|
|
3517
3299
|
override async visitNewArray(newArray: J.NewArray, other: J): Promise<J | undefined> {
|
|
3518
3300
|
if (!this.match || other.kind !== J.Kind.NewArray) {
|
|
3519
|
-
this.abort();
|
|
3520
|
-
return newArray;
|
|
3301
|
+
return this.abort(newArray);
|
|
3521
3302
|
}
|
|
3522
3303
|
|
|
3523
3304
|
const otherNewArray = other as J.NewArray;
|
|
3524
3305
|
|
|
3525
3306
|
// Compare typeExpression
|
|
3526
3307
|
if ((newArray.typeExpression === undefined) !== (otherNewArray.typeExpression === undefined)) {
|
|
3527
|
-
this.abort();
|
|
3528
|
-
return newArray;
|
|
3308
|
+
return this.abort(newArray);
|
|
3529
3309
|
}
|
|
3530
3310
|
|
|
3531
3311
|
// Visit typeExpression if present
|
|
@@ -3536,8 +3316,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3536
3316
|
|
|
3537
3317
|
// Compare dimensions
|
|
3538
3318
|
if (newArray.dimensions.length !== otherNewArray.dimensions.length) {
|
|
3539
|
-
this.abort();
|
|
3540
|
-
return newArray;
|
|
3319
|
+
return this.abort(newArray);
|
|
3541
3320
|
}
|
|
3542
3321
|
|
|
3543
3322
|
// Visit each dimension in lock step
|
|
@@ -3548,15 +3327,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3548
3327
|
|
|
3549
3328
|
// Compare initializer
|
|
3550
3329
|
if ((newArray.initializer === undefined) !== (otherNewArray.initializer === undefined)) {
|
|
3551
|
-
this.abort();
|
|
3552
|
-
return newArray;
|
|
3330
|
+
return this.abort(newArray);
|
|
3553
3331
|
}
|
|
3554
3332
|
|
|
3555
3333
|
// Visit initializer if present
|
|
3556
3334
|
if (newArray.initializer && otherNewArray.initializer) {
|
|
3557
3335
|
if (newArray.initializer.elements.length !== otherNewArray.initializer.elements.length) {
|
|
3558
|
-
this.abort();
|
|
3559
|
-
return newArray;
|
|
3336
|
+
return this.abort(newArray);
|
|
3560
3337
|
}
|
|
3561
3338
|
|
|
3562
3339
|
// Visit each initializer element in lock step
|
|
@@ -3578,16 +3355,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3578
3355
|
*/
|
|
3579
3356
|
override async visitNewClass(newClass: J.NewClass, other: J): Promise<J | undefined> {
|
|
3580
3357
|
if (!this.match || other.kind !== J.Kind.NewClass) {
|
|
3581
|
-
this.abort();
|
|
3582
|
-
return newClass;
|
|
3358
|
+
return this.abort(newClass);
|
|
3583
3359
|
}
|
|
3584
3360
|
|
|
3585
3361
|
const otherNewClass = other as J.NewClass;
|
|
3586
3362
|
|
|
3587
3363
|
// Compare enclosing
|
|
3588
3364
|
if ((newClass.enclosing === undefined) !== (otherNewClass.enclosing === undefined)) {
|
|
3589
|
-
this.abort();
|
|
3590
|
-
return newClass;
|
|
3365
|
+
return this.abort(newClass);
|
|
3591
3366
|
}
|
|
3592
3367
|
|
|
3593
3368
|
// Visit enclosing if present
|
|
@@ -3598,8 +3373,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3598
3373
|
|
|
3599
3374
|
// Compare class
|
|
3600
3375
|
if ((newClass.class === undefined) !== (otherNewClass.class === undefined)) {
|
|
3601
|
-
this.abort();
|
|
3602
|
-
return newClass;
|
|
3376
|
+
return this.abort(newClass);
|
|
3603
3377
|
}
|
|
3604
3378
|
|
|
3605
3379
|
// Visit class if present
|
|
@@ -3610,8 +3384,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3610
3384
|
|
|
3611
3385
|
// Compare arguments
|
|
3612
3386
|
if (newClass.arguments.elements.length !== otherNewClass.arguments.elements.length) {
|
|
3613
|
-
this.abort();
|
|
3614
|
-
return newClass;
|
|
3387
|
+
return this.abort(newClass);
|
|
3615
3388
|
}
|
|
3616
3389
|
|
|
3617
3390
|
// Visit each argument in lock step
|
|
@@ -3622,8 +3395,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3622
3395
|
|
|
3623
3396
|
// Compare body
|
|
3624
3397
|
if ((newClass.body === undefined) !== (otherNewClass.body === undefined)) {
|
|
3625
|
-
this.abort();
|
|
3626
|
-
return newClass;
|
|
3398
|
+
return this.abort(newClass);
|
|
3627
3399
|
}
|
|
3628
3400
|
|
|
3629
3401
|
// Visit body if present
|
|
@@ -3644,16 +3416,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3644
3416
|
*/
|
|
3645
3417
|
override async visitNullableType(nullableType: J.NullableType, other: J): Promise<J | undefined> {
|
|
3646
3418
|
if (!this.match || other.kind !== J.Kind.NullableType) {
|
|
3647
|
-
this.abort();
|
|
3648
|
-
return nullableType;
|
|
3419
|
+
return this.abort(nullableType);
|
|
3649
3420
|
}
|
|
3650
3421
|
|
|
3651
3422
|
const otherNullableType = other as J.NullableType;
|
|
3652
3423
|
|
|
3653
3424
|
// Compare annotations
|
|
3654
3425
|
if (nullableType.annotations.length !== otherNullableType.annotations.length) {
|
|
3655
|
-
this.abort();
|
|
3656
|
-
return nullableType;
|
|
3426
|
+
return this.abort(nullableType);
|
|
3657
3427
|
}
|
|
3658
3428
|
|
|
3659
3429
|
// Visit each annotation in lock step
|
|
@@ -3678,8 +3448,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3678
3448
|
*/
|
|
3679
3449
|
override async visitPackage(packageDeclaration: J.Package, other: J): Promise<J | undefined> {
|
|
3680
3450
|
if (!this.match || other.kind !== J.Kind.Package) {
|
|
3681
|
-
this.abort();
|
|
3682
|
-
return packageDeclaration;
|
|
3451
|
+
return this.abort(packageDeclaration);
|
|
3683
3452
|
}
|
|
3684
3453
|
|
|
3685
3454
|
const otherPackageDeclaration = other as J.Package;
|
|
@@ -3690,15 +3459,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3690
3459
|
|
|
3691
3460
|
// Compare annotations
|
|
3692
3461
|
if ((packageDeclaration.annotations === undefined) !== (otherPackageDeclaration.annotations === undefined)) {
|
|
3693
|
-
this.abort();
|
|
3694
|
-
return packageDeclaration;
|
|
3462
|
+
return this.abort(packageDeclaration);
|
|
3695
3463
|
}
|
|
3696
3464
|
|
|
3697
3465
|
// Visit annotations if present
|
|
3698
3466
|
if (packageDeclaration.annotations && otherPackageDeclaration.annotations) {
|
|
3699
3467
|
if (packageDeclaration.annotations.length !== otherPackageDeclaration.annotations.length) {
|
|
3700
|
-
this.abort();
|
|
3701
|
-
return packageDeclaration;
|
|
3468
|
+
return this.abort(packageDeclaration);
|
|
3702
3469
|
}
|
|
3703
3470
|
|
|
3704
3471
|
// Visit each annotation in lock step
|
|
@@ -3720,8 +3487,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3720
3487
|
*/
|
|
3721
3488
|
override async visitParameterizedType(parameterizedType: J.ParameterizedType, other: J): Promise<J | undefined> {
|
|
3722
3489
|
if (!this.match || other.kind !== J.Kind.ParameterizedType) {
|
|
3723
|
-
this.abort();
|
|
3724
|
-
return parameterizedType;
|
|
3490
|
+
return this.abort(parameterizedType);
|
|
3725
3491
|
}
|
|
3726
3492
|
|
|
3727
3493
|
const otherParameterizedType = other as J.ParameterizedType;
|
|
@@ -3732,15 +3498,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3732
3498
|
|
|
3733
3499
|
// Compare typeParameters
|
|
3734
3500
|
if ((parameterizedType.typeParameters === undefined) !== (otherParameterizedType.typeParameters === undefined)) {
|
|
3735
|
-
this.abort();
|
|
3736
|
-
return parameterizedType;
|
|
3501
|
+
return this.abort(parameterizedType);
|
|
3737
3502
|
}
|
|
3738
3503
|
|
|
3739
3504
|
// Visit typeParameters if present
|
|
3740
3505
|
if (parameterizedType.typeParameters && otherParameterizedType.typeParameters) {
|
|
3741
3506
|
if (parameterizedType.typeParameters.elements.length !== otherParameterizedType.typeParameters.elements.length) {
|
|
3742
|
-
this.abort();
|
|
3743
|
-
return parameterizedType;
|
|
3507
|
+
return this.abort(parameterizedType);
|
|
3744
3508
|
}
|
|
3745
3509
|
|
|
3746
3510
|
// Visit each type parameter in lock step
|
|
@@ -3762,8 +3526,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3762
3526
|
*/
|
|
3763
3527
|
override async visitParentheses(parentheses: J.Parentheses<J>, other: J): Promise<J | undefined> {
|
|
3764
3528
|
if (!this.match || other.kind !== J.Kind.Parentheses) {
|
|
3765
|
-
this.abort();
|
|
3766
|
-
return parentheses;
|
|
3529
|
+
return this.abort(parentheses);
|
|
3767
3530
|
}
|
|
3768
3531
|
|
|
3769
3532
|
const otherParentheses = other as J.Parentheses<J>;
|
|
@@ -3784,16 +3547,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3784
3547
|
*/
|
|
3785
3548
|
override async visitParenthesizedTypeTree(parenthesizedTypeTree: J.ParenthesizedTypeTree, other: J): Promise<J | undefined> {
|
|
3786
3549
|
if (!this.match || other.kind !== J.Kind.ParenthesizedTypeTree) {
|
|
3787
|
-
this.abort();
|
|
3788
|
-
return parenthesizedTypeTree;
|
|
3550
|
+
return this.abort(parenthesizedTypeTree);
|
|
3789
3551
|
}
|
|
3790
3552
|
|
|
3791
3553
|
const otherParenthesizedTypeTree = other as J.ParenthesizedTypeTree;
|
|
3792
3554
|
|
|
3793
3555
|
// Compare annotations
|
|
3794
3556
|
if (parenthesizedTypeTree.annotations.length !== otherParenthesizedTypeTree.annotations.length) {
|
|
3795
|
-
this.abort();
|
|
3796
|
-
return parenthesizedTypeTree;
|
|
3557
|
+
return this.abort(parenthesizedTypeTree);
|
|
3797
3558
|
}
|
|
3798
3559
|
|
|
3799
3560
|
// Visit each annotation in lock step
|
|
@@ -3818,16 +3579,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3818
3579
|
*/
|
|
3819
3580
|
override async visitPrimitive(primitive: J.Primitive, other: J): Promise<J | undefined> {
|
|
3820
3581
|
if (!this.match || other.kind !== J.Kind.Primitive) {
|
|
3821
|
-
this.abort();
|
|
3822
|
-
return primitive;
|
|
3582
|
+
return this.abort(primitive);
|
|
3823
3583
|
}
|
|
3824
3584
|
|
|
3825
3585
|
const otherPrimitive = other as J.Primitive;
|
|
3826
3586
|
|
|
3827
3587
|
// Compare type
|
|
3828
3588
|
if (primitive.type.kind !== otherPrimitive.type.kind) {
|
|
3829
|
-
this.abort();
|
|
3830
|
-
return primitive;
|
|
3589
|
+
return this.abort(primitive);
|
|
3831
3590
|
}
|
|
3832
3591
|
|
|
3833
3592
|
return primitive;
|
|
@@ -3842,16 +3601,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3842
3601
|
*/
|
|
3843
3602
|
override async visitReturn(returnStatement: J.Return, other: J): Promise<J | undefined> {
|
|
3844
3603
|
if (!this.match || other.kind !== J.Kind.Return) {
|
|
3845
|
-
this.abort();
|
|
3846
|
-
return returnStatement;
|
|
3604
|
+
return this.abort(returnStatement);
|
|
3847
3605
|
}
|
|
3848
3606
|
|
|
3849
3607
|
const otherReturnStatement = other as J.Return;
|
|
3850
3608
|
|
|
3851
3609
|
// Compare expression
|
|
3852
3610
|
if ((returnStatement.expression === undefined) !== (otherReturnStatement.expression === undefined)) {
|
|
3853
|
-
this.abort();
|
|
3854
|
-
return returnStatement;
|
|
3611
|
+
return this.abort(returnStatement);
|
|
3855
3612
|
}
|
|
3856
3613
|
|
|
3857
3614
|
// Visit expression if present
|
|
@@ -3872,8 +3629,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3872
3629
|
*/
|
|
3873
3630
|
override async visitSwitch(switchStatement: J.Switch, other: J): Promise<J | undefined> {
|
|
3874
3631
|
if (!this.match || other.kind !== J.Kind.Switch) {
|
|
3875
|
-
this.abort();
|
|
3876
|
-
return switchStatement;
|
|
3632
|
+
return this.abort(switchStatement);
|
|
3877
3633
|
}
|
|
3878
3634
|
|
|
3879
3635
|
const otherSwitchStatement = other as J.Switch;
|
|
@@ -3898,8 +3654,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3898
3654
|
*/
|
|
3899
3655
|
override async visitSwitchExpression(switchExpression: J.SwitchExpression, other: J): Promise<J | undefined> {
|
|
3900
3656
|
if (!this.match || other.kind !== J.Kind.SwitchExpression) {
|
|
3901
|
-
this.abort();
|
|
3902
|
-
return switchExpression;
|
|
3657
|
+
return this.abort(switchExpression);
|
|
3903
3658
|
}
|
|
3904
3659
|
|
|
3905
3660
|
const otherSwitchExpression = other as J.SwitchExpression;
|
|
@@ -3924,8 +3679,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3924
3679
|
*/
|
|
3925
3680
|
override async visitSynchronized(synchronizedStatement: J.Synchronized, other: J): Promise<J | undefined> {
|
|
3926
3681
|
if (!this.match || other.kind !== J.Kind.Synchronized) {
|
|
3927
|
-
this.abort();
|
|
3928
|
-
return synchronizedStatement;
|
|
3682
|
+
return this.abort(synchronizedStatement);
|
|
3929
3683
|
}
|
|
3930
3684
|
|
|
3931
3685
|
const otherSynchronizedStatement = other as J.Synchronized;
|
|
@@ -3950,8 +3704,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3950
3704
|
*/
|
|
3951
3705
|
override async visitTernary(ternary: J.Ternary, other: J): Promise<J | undefined> {
|
|
3952
3706
|
if (!this.match || other.kind !== J.Kind.Ternary) {
|
|
3953
|
-
this.abort();
|
|
3954
|
-
return ternary;
|
|
3707
|
+
return this.abort(ternary);
|
|
3955
3708
|
}
|
|
3956
3709
|
|
|
3957
3710
|
const otherTernary = other as J.Ternary;
|
|
@@ -3980,8 +3733,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
3980
3733
|
*/
|
|
3981
3734
|
override async visitThrow(throwStatement: J.Throw, other: J): Promise<J | undefined> {
|
|
3982
3735
|
if (!this.match || other.kind !== J.Kind.Throw) {
|
|
3983
|
-
this.abort();
|
|
3984
|
-
return throwStatement;
|
|
3736
|
+
return this.abort(throwStatement);
|
|
3985
3737
|
}
|
|
3986
3738
|
|
|
3987
3739
|
const otherThrowStatement = other as J.Throw;
|
|
@@ -4002,23 +3754,20 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4002
3754
|
*/
|
|
4003
3755
|
override async visitTry(tryStatement: J.Try, other: J): Promise<J | undefined> {
|
|
4004
3756
|
if (!this.match || other.kind !== J.Kind.Try) {
|
|
4005
|
-
this.abort();
|
|
4006
|
-
return tryStatement;
|
|
3757
|
+
return this.abort(tryStatement);
|
|
4007
3758
|
}
|
|
4008
3759
|
|
|
4009
3760
|
const otherTryStatement = other as J.Try;
|
|
4010
3761
|
|
|
4011
3762
|
// Compare resources
|
|
4012
3763
|
if ((tryStatement.resources === undefined) !== (otherTryStatement.resources === undefined)) {
|
|
4013
|
-
this.abort();
|
|
4014
|
-
return tryStatement;
|
|
3764
|
+
return this.abort(tryStatement);
|
|
4015
3765
|
}
|
|
4016
3766
|
|
|
4017
3767
|
// Visit resources if present
|
|
4018
3768
|
if (tryStatement.resources && otherTryStatement.resources) {
|
|
4019
3769
|
if (tryStatement.resources.elements.length !== otherTryStatement.resources.elements.length) {
|
|
4020
|
-
this.abort();
|
|
4021
|
-
return tryStatement;
|
|
3770
|
+
return this.abort(tryStatement);
|
|
4022
3771
|
}
|
|
4023
3772
|
|
|
4024
3773
|
// Visit each resource in lock step
|
|
@@ -4034,8 +3783,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4034
3783
|
|
|
4035
3784
|
// Compare catches
|
|
4036
3785
|
if (tryStatement.catches.length !== otherTryStatement.catches.length) {
|
|
4037
|
-
this.abort();
|
|
4038
|
-
return tryStatement;
|
|
3786
|
+
return this.abort(tryStatement);
|
|
4039
3787
|
}
|
|
4040
3788
|
|
|
4041
3789
|
// Visit each catch in lock step
|
|
@@ -4046,8 +3794,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4046
3794
|
|
|
4047
3795
|
// Compare finally
|
|
4048
3796
|
if ((tryStatement.finally === undefined) !== (otherTryStatement.finally === undefined)) {
|
|
4049
|
-
this.abort();
|
|
4050
|
-
return tryStatement;
|
|
3797
|
+
return this.abort(tryStatement);
|
|
4051
3798
|
}
|
|
4052
3799
|
|
|
4053
3800
|
// Visit finally if present
|
|
@@ -4068,8 +3815,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4068
3815
|
*/
|
|
4069
3816
|
override async visitTryResource(resource: J.Try.Resource, other: J): Promise<J | undefined> {
|
|
4070
3817
|
if (!this.match || other.kind !== J.Kind.TryResource) {
|
|
4071
|
-
this.abort();
|
|
4072
|
-
return resource;
|
|
3818
|
+
return this.abort(resource);
|
|
4073
3819
|
}
|
|
4074
3820
|
|
|
4075
3821
|
const otherResource = other as J.Try.Resource;
|
|
@@ -4080,8 +3826,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4080
3826
|
|
|
4081
3827
|
// Compare terminatedWithSemicolon
|
|
4082
3828
|
if (resource.terminatedWithSemicolon !== otherResource.terminatedWithSemicolon) {
|
|
4083
|
-
this.abort();
|
|
4084
|
-
return resource;
|
|
3829
|
+
return this.abort(resource);
|
|
4085
3830
|
}
|
|
4086
3831
|
|
|
4087
3832
|
return resource;
|
|
@@ -4096,8 +3841,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4096
3841
|
*/
|
|
4097
3842
|
override async visitTryCatch(tryCatch: J.Try.Catch, other: J): Promise<J | undefined> {
|
|
4098
3843
|
if (!this.match || other.kind !== J.Kind.TryCatch) {
|
|
4099
|
-
this.abort();
|
|
4100
|
-
return tryCatch;
|
|
3844
|
+
return this.abort(tryCatch);
|
|
4101
3845
|
}
|
|
4102
3846
|
|
|
4103
3847
|
const otherTryCatch = other as J.Try.Catch;
|
|
@@ -4122,8 +3866,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4122
3866
|
*/
|
|
4123
3867
|
override async visitTypeCast(typeCast: J.TypeCast, other: J): Promise<J | undefined> {
|
|
4124
3868
|
if (!this.match || other.kind !== J.Kind.TypeCast) {
|
|
4125
|
-
this.abort();
|
|
4126
|
-
return typeCast;
|
|
3869
|
+
return this.abort(typeCast);
|
|
4127
3870
|
}
|
|
4128
3871
|
|
|
4129
3872
|
const otherTypeCast = other as J.TypeCast;
|
|
@@ -4148,16 +3891,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4148
3891
|
*/
|
|
4149
3892
|
override async visitTypeParameter(typeParameter: J.TypeParameter, other: J): Promise<J | undefined> {
|
|
4150
3893
|
if (!this.match || other.kind !== J.Kind.TypeParameter) {
|
|
4151
|
-
this.abort();
|
|
4152
|
-
return typeParameter;
|
|
3894
|
+
return this.abort(typeParameter);
|
|
4153
3895
|
}
|
|
4154
3896
|
|
|
4155
3897
|
const otherTypeParameter = other as J.TypeParameter;
|
|
4156
3898
|
|
|
4157
3899
|
// Compare annotations
|
|
4158
3900
|
if (typeParameter.annotations.length !== otherTypeParameter.annotations.length) {
|
|
4159
|
-
this.abort();
|
|
4160
|
-
return typeParameter;
|
|
3901
|
+
return this.abort(typeParameter);
|
|
4161
3902
|
}
|
|
4162
3903
|
|
|
4163
3904
|
// Visit each annotation in lock step
|
|
@@ -4168,8 +3909,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4168
3909
|
|
|
4169
3910
|
// Compare modifiers
|
|
4170
3911
|
if (typeParameter.modifiers.length !== otherTypeParameter.modifiers.length) {
|
|
4171
|
-
this.abort();
|
|
4172
|
-
return typeParameter;
|
|
3912
|
+
return this.abort(typeParameter);
|
|
4173
3913
|
}
|
|
4174
3914
|
|
|
4175
3915
|
// Visit each modifier in lock step
|
|
@@ -4184,15 +3924,13 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4184
3924
|
|
|
4185
3925
|
// Compare bounds
|
|
4186
3926
|
if ((typeParameter.bounds === undefined) !== (otherTypeParameter.bounds === undefined)) {
|
|
4187
|
-
this.abort();
|
|
4188
|
-
return typeParameter;
|
|
3927
|
+
return this.abort(typeParameter);
|
|
4189
3928
|
}
|
|
4190
3929
|
|
|
4191
3930
|
// Visit bounds if present
|
|
4192
3931
|
if (typeParameter.bounds && otherTypeParameter.bounds) {
|
|
4193
3932
|
if (typeParameter.bounds.elements.length !== otherTypeParameter.bounds.elements.length) {
|
|
4194
|
-
this.abort();
|
|
4195
|
-
return typeParameter;
|
|
3933
|
+
return this.abort(typeParameter);
|
|
4196
3934
|
}
|
|
4197
3935
|
|
|
4198
3936
|
// Visit each bound in lock step
|
|
@@ -4214,16 +3952,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4214
3952
|
*/
|
|
4215
3953
|
override async visitTypeParameters(typeParameters: J.TypeParameters, other: J): Promise<J | undefined> {
|
|
4216
3954
|
if (!this.match || other.kind !== J.Kind.TypeParameters) {
|
|
4217
|
-
this.abort();
|
|
4218
|
-
return typeParameters;
|
|
3955
|
+
return this.abort(typeParameters);
|
|
4219
3956
|
}
|
|
4220
3957
|
|
|
4221
3958
|
const otherTypeParameters = other as J.TypeParameters;
|
|
4222
3959
|
|
|
4223
3960
|
// Compare annotations
|
|
4224
3961
|
if (typeParameters.annotations.length !== otherTypeParameters.annotations.length) {
|
|
4225
|
-
this.abort();
|
|
4226
|
-
return typeParameters;
|
|
3962
|
+
return this.abort(typeParameters);
|
|
4227
3963
|
}
|
|
4228
3964
|
|
|
4229
3965
|
// Visit each annotation in lock step
|
|
@@ -4234,8 +3970,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4234
3970
|
|
|
4235
3971
|
// Compare typeParameters
|
|
4236
3972
|
if (typeParameters.typeParameters.length !== otherTypeParameters.typeParameters.length) {
|
|
4237
|
-
this.abort();
|
|
4238
|
-
return typeParameters;
|
|
3973
|
+
return this.abort(typeParameters);
|
|
4239
3974
|
}
|
|
4240
3975
|
|
|
4241
3976
|
// Visit each type parameter in lock step
|
|
@@ -4256,16 +3991,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4256
3991
|
*/
|
|
4257
3992
|
override async visitUnary(unary: J.Unary, other: J): Promise<J | undefined> {
|
|
4258
3993
|
if (!this.match || other.kind !== J.Kind.Unary) {
|
|
4259
|
-
this.abort();
|
|
4260
|
-
return unary;
|
|
3994
|
+
return this.abort(unary);
|
|
4261
3995
|
}
|
|
4262
3996
|
|
|
4263
3997
|
const otherUnary = other as J.Unary;
|
|
4264
3998
|
|
|
4265
3999
|
// Compare operator
|
|
4266
4000
|
if (unary.operator.element !== otherUnary.operator.element) {
|
|
4267
|
-
this.abort();
|
|
4268
|
-
return unary;
|
|
4001
|
+
return this.abort(unary);
|
|
4269
4002
|
}
|
|
4270
4003
|
|
|
4271
4004
|
// Visit expression
|
|
@@ -4284,8 +4017,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4284
4017
|
*/
|
|
4285
4018
|
override async visitUnknown(unknown: J.Unknown, other: J): Promise<J | undefined> {
|
|
4286
4019
|
if (!this.match || other.kind !== J.Kind.Unknown) {
|
|
4287
|
-
this.abort();
|
|
4288
|
-
return unknown;
|
|
4020
|
+
return this.abort(unknown);
|
|
4289
4021
|
}
|
|
4290
4022
|
|
|
4291
4023
|
const otherUnknown = other as J.Unknown;
|
|
@@ -4306,16 +4038,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4306
4038
|
*/
|
|
4307
4039
|
override async visitUnknownSource(unknownSource: J.UnknownSource, other: J): Promise<J | undefined> {
|
|
4308
4040
|
if (!this.match || other.kind !== J.Kind.UnknownSource) {
|
|
4309
|
-
this.abort();
|
|
4310
|
-
return unknownSource;
|
|
4041
|
+
return this.abort(unknownSource);
|
|
4311
4042
|
}
|
|
4312
4043
|
|
|
4313
4044
|
const otherUnknownSource = other as J.UnknownSource;
|
|
4314
4045
|
|
|
4315
4046
|
// Compare text
|
|
4316
4047
|
if (unknownSource.text !== otherUnknownSource.text) {
|
|
4317
|
-
this.abort();
|
|
4318
|
-
return unknownSource;
|
|
4048
|
+
return this.abort(unknownSource);
|
|
4319
4049
|
}
|
|
4320
4050
|
|
|
4321
4051
|
return unknownSource;
|
|
@@ -4330,16 +4060,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4330
4060
|
*/
|
|
4331
4061
|
override async visitVariableDeclarations(variableDeclarations: J.VariableDeclarations, other: J): Promise<J | undefined> {
|
|
4332
4062
|
if (!this.match || other.kind !== J.Kind.VariableDeclarations) {
|
|
4333
|
-
this.abort();
|
|
4334
|
-
return variableDeclarations;
|
|
4063
|
+
return this.abort(variableDeclarations);
|
|
4335
4064
|
}
|
|
4336
4065
|
|
|
4337
4066
|
const otherVariableDeclarations = other as J.VariableDeclarations;
|
|
4338
4067
|
|
|
4339
4068
|
// Compare leadingAnnotations
|
|
4340
4069
|
if (variableDeclarations.leadingAnnotations.length !== otherVariableDeclarations.leadingAnnotations.length) {
|
|
4341
|
-
this.abort();
|
|
4342
|
-
return variableDeclarations;
|
|
4070
|
+
return this.abort(variableDeclarations);
|
|
4343
4071
|
}
|
|
4344
4072
|
|
|
4345
4073
|
// Visit each leading annotation in lock step
|
|
@@ -4350,8 +4078,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4350
4078
|
|
|
4351
4079
|
// Compare modifiers
|
|
4352
4080
|
if (variableDeclarations.modifiers.length !== otherVariableDeclarations.modifiers.length) {
|
|
4353
|
-
this.abort();
|
|
4354
|
-
return variableDeclarations;
|
|
4081
|
+
return this.abort(variableDeclarations);
|
|
4355
4082
|
}
|
|
4356
4083
|
|
|
4357
4084
|
// Visit each modifier in lock step
|
|
@@ -4362,8 +4089,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4362
4089
|
|
|
4363
4090
|
// Compare typeExpression
|
|
4364
4091
|
if ((variableDeclarations.typeExpression === undefined) !== (otherVariableDeclarations.typeExpression === undefined)) {
|
|
4365
|
-
this.abort();
|
|
4366
|
-
return variableDeclarations;
|
|
4092
|
+
return this.abort(variableDeclarations);
|
|
4367
4093
|
}
|
|
4368
4094
|
|
|
4369
4095
|
// Visit typeExpression if present
|
|
@@ -4374,14 +4100,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4374
4100
|
|
|
4375
4101
|
// Compare varargs
|
|
4376
4102
|
if ((variableDeclarations.varargs === undefined) !== (otherVariableDeclarations.varargs === undefined)) {
|
|
4377
|
-
this.abort();
|
|
4378
|
-
return variableDeclarations;
|
|
4103
|
+
return this.abort(variableDeclarations);
|
|
4379
4104
|
}
|
|
4380
4105
|
|
|
4381
4106
|
// Compare variables
|
|
4382
4107
|
if (variableDeclarations.variables.length !== otherVariableDeclarations.variables.length) {
|
|
4383
|
-
this.abort();
|
|
4384
|
-
return variableDeclarations;
|
|
4108
|
+
return this.abort(variableDeclarations);
|
|
4385
4109
|
}
|
|
4386
4110
|
|
|
4387
4111
|
// Visit each variable in lock step
|
|
@@ -4402,8 +4126,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4402
4126
|
*/
|
|
4403
4127
|
override async visitVariable(variable: J.VariableDeclarations.NamedVariable, other: J): Promise<J | undefined> {
|
|
4404
4128
|
if (!this.match || other.kind !== J.Kind.NamedVariable) {
|
|
4405
|
-
this.abort();
|
|
4406
|
-
return variable;
|
|
4129
|
+
return this.abort(variable);
|
|
4407
4130
|
}
|
|
4408
4131
|
|
|
4409
4132
|
const otherVariable = other as J.VariableDeclarations.NamedVariable;
|
|
@@ -4414,14 +4137,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4414
4137
|
|
|
4415
4138
|
// Compare dimensionsAfterName
|
|
4416
4139
|
if (variable.dimensionsAfterName.length !== otherVariable.dimensionsAfterName.length) {
|
|
4417
|
-
this.abort();
|
|
4418
|
-
return variable;
|
|
4140
|
+
return this.abort(variable);
|
|
4419
4141
|
}
|
|
4420
4142
|
|
|
4421
4143
|
// Compare initializer
|
|
4422
4144
|
if ((variable.initializer === undefined) !== (otherVariable.initializer === undefined)) {
|
|
4423
|
-
this.abort();
|
|
4424
|
-
return variable;
|
|
4145
|
+
return this.abort(variable);
|
|
4425
4146
|
}
|
|
4426
4147
|
|
|
4427
4148
|
// Visit initializer if present
|
|
@@ -4442,8 +4163,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4442
4163
|
*/
|
|
4443
4164
|
override async visitWhileLoop(whileLoop: J.WhileLoop, other: J): Promise<J | undefined> {
|
|
4444
4165
|
if (!this.match || other.kind !== J.Kind.WhileLoop) {
|
|
4445
|
-
this.abort();
|
|
4446
|
-
return whileLoop;
|
|
4166
|
+
return this.abort(whileLoop);
|
|
4447
4167
|
}
|
|
4448
4168
|
|
|
4449
4169
|
const otherWhileLoop = other as J.WhileLoop;
|
|
@@ -4468,30 +4188,26 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4468
4188
|
*/
|
|
4469
4189
|
override async visitWildcard(wildcard: J.Wildcard, other: J): Promise<J | undefined> {
|
|
4470
4190
|
if (!this.match || other.kind !== J.Kind.Wildcard) {
|
|
4471
|
-
this.abort();
|
|
4472
|
-
return wildcard;
|
|
4191
|
+
return this.abort(wildcard);
|
|
4473
4192
|
}
|
|
4474
4193
|
|
|
4475
4194
|
const otherWildcard = other as J.Wildcard;
|
|
4476
4195
|
|
|
4477
4196
|
// Compare bound
|
|
4478
4197
|
if ((wildcard.bound === undefined) !== (otherWildcard.bound === undefined)) {
|
|
4479
|
-
this.abort();
|
|
4480
|
-
return wildcard;
|
|
4198
|
+
return this.abort(wildcard);
|
|
4481
4199
|
}
|
|
4482
4200
|
|
|
4483
4201
|
// Compare bound if present
|
|
4484
4202
|
if (wildcard.bound && otherWildcard.bound) {
|
|
4485
4203
|
if (wildcard.bound.element !== otherWildcard.bound.element) {
|
|
4486
|
-
this.abort();
|
|
4487
|
-
return wildcard;
|
|
4204
|
+
return this.abort(wildcard);
|
|
4488
4205
|
}
|
|
4489
4206
|
}
|
|
4490
4207
|
|
|
4491
4208
|
// Compare boundedType
|
|
4492
4209
|
if ((wildcard.boundedType === undefined) !== (otherWildcard.boundedType === undefined)) {
|
|
4493
|
-
this.abort();
|
|
4494
|
-
return wildcard;
|
|
4210
|
+
return this.abort(wildcard);
|
|
4495
4211
|
}
|
|
4496
4212
|
|
|
4497
4213
|
// Visit boundedType if present
|
|
@@ -4512,16 +4228,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4512
4228
|
*/
|
|
4513
4229
|
override async visitYield(yieldStatement: J.Yield, other: J): Promise<J | undefined> {
|
|
4514
4230
|
if (!this.match || other.kind !== J.Kind.Yield) {
|
|
4515
|
-
this.abort();
|
|
4516
|
-
return yieldStatement;
|
|
4231
|
+
return this.abort(yieldStatement);
|
|
4517
4232
|
}
|
|
4518
4233
|
|
|
4519
4234
|
const otherYieldStatement = other as J.Yield;
|
|
4520
4235
|
|
|
4521
4236
|
// Compare implicit
|
|
4522
4237
|
if (yieldStatement.implicit !== otherYieldStatement.implicit) {
|
|
4523
|
-
this.abort();
|
|
4524
|
-
return yieldStatement;
|
|
4238
|
+
return this.abort(yieldStatement);
|
|
4525
4239
|
}
|
|
4526
4240
|
|
|
4527
4241
|
// Visit value
|
|
@@ -4540,8 +4254,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4540
4254
|
*/
|
|
4541
4255
|
override async visitVoid(void_: JS.Void, other: J): Promise<J | undefined> {
|
|
4542
4256
|
if (!this.match || other.kind !== JS.Kind.Void) {
|
|
4543
|
-
this.abort();
|
|
4544
|
-
return void_;
|
|
4257
|
+
return this.abort(void_);
|
|
4545
4258
|
}
|
|
4546
4259
|
|
|
4547
4260
|
const otherVoid = other as JS.Void;
|
|
@@ -4561,8 +4274,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4561
4274
|
*/
|
|
4562
4275
|
override async visitWithStatement(withStatement: JS.WithStatement, other: J): Promise<J | undefined> {
|
|
4563
4276
|
if (!this.match || other.kind !== JS.Kind.WithStatement) {
|
|
4564
|
-
this.abort();
|
|
4565
|
-
return withStatement;
|
|
4277
|
+
return this.abort(withStatement);
|
|
4566
4278
|
}
|
|
4567
4279
|
|
|
4568
4280
|
const otherWithStatement = other as JS.WithStatement;
|
|
@@ -4586,16 +4298,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4586
4298
|
*/
|
|
4587
4299
|
override async visitIndexSignatureDeclaration(indexSignatureDeclaration: JS.IndexSignatureDeclaration, other: J): Promise<J | undefined> {
|
|
4588
4300
|
if (!this.match || other.kind !== JS.Kind.IndexSignatureDeclaration) {
|
|
4589
|
-
this.abort();
|
|
4590
|
-
return indexSignatureDeclaration;
|
|
4301
|
+
return this.abort(indexSignatureDeclaration);
|
|
4591
4302
|
}
|
|
4592
4303
|
|
|
4593
4304
|
const otherIndexSignatureDeclaration = other as JS.IndexSignatureDeclaration;
|
|
4594
4305
|
|
|
4595
4306
|
// Compare modifiers
|
|
4596
4307
|
if (indexSignatureDeclaration.modifiers.length !== otherIndexSignatureDeclaration.modifiers.length) {
|
|
4597
|
-
this.abort();
|
|
4598
|
-
return indexSignatureDeclaration;
|
|
4308
|
+
return this.abort(indexSignatureDeclaration);
|
|
4599
4309
|
}
|
|
4600
4310
|
|
|
4601
4311
|
// Visit modifiers in lock step
|
|
@@ -4606,8 +4316,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4606
4316
|
|
|
4607
4317
|
// Compare parameters
|
|
4608
4318
|
if (indexSignatureDeclaration.parameters.elements.length !== otherIndexSignatureDeclaration.parameters.elements.length) {
|
|
4609
|
-
this.abort();
|
|
4610
|
-
return indexSignatureDeclaration;
|
|
4319
|
+
return this.abort(indexSignatureDeclaration);
|
|
4611
4320
|
}
|
|
4612
4321
|
|
|
4613
4322
|
// Visit parameters in lock step
|
|
@@ -4632,16 +4341,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4632
4341
|
*/
|
|
4633
4342
|
override async visitForOfLoop(forOfLoop: JS.ForOfLoop, other: J): Promise<J | undefined> {
|
|
4634
4343
|
if (!this.match || other.kind !== JS.Kind.ForOfLoop) {
|
|
4635
|
-
this.abort();
|
|
4636
|
-
return forOfLoop;
|
|
4344
|
+
return this.abort(forOfLoop);
|
|
4637
4345
|
}
|
|
4638
4346
|
|
|
4639
4347
|
const otherForOfLoop = other as JS.ForOfLoop;
|
|
4640
4348
|
|
|
4641
4349
|
// Compare await
|
|
4642
4350
|
if ((forOfLoop.await === undefined) !== (otherForOfLoop.await === undefined)) {
|
|
4643
|
-
this.abort();
|
|
4644
|
-
return forOfLoop;
|
|
4351
|
+
return this.abort(forOfLoop);
|
|
4645
4352
|
}
|
|
4646
4353
|
|
|
4647
4354
|
// Visit loop
|
|
@@ -4660,8 +4367,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4660
4367
|
*/
|
|
4661
4368
|
override async visitForInLoop(forInLoop: JS.ForInLoop, other: J): Promise<J | undefined> {
|
|
4662
4369
|
if (!this.match || other.kind !== JS.Kind.ForInLoop) {
|
|
4663
|
-
this.abort();
|
|
4664
|
-
return forInLoop;
|
|
4370
|
+
return this.abort(forInLoop);
|
|
4665
4371
|
}
|
|
4666
4372
|
|
|
4667
4373
|
const otherForInLoop = other as JS.ForInLoop;
|
|
@@ -4686,16 +4392,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4686
4392
|
*/
|
|
4687
4393
|
override async visitNamespaceDeclaration(namespaceDeclaration: JS.NamespaceDeclaration, other: J): Promise<J | undefined> {
|
|
4688
4394
|
if (!this.match || other.kind !== JS.Kind.NamespaceDeclaration) {
|
|
4689
|
-
this.abort();
|
|
4690
|
-
return namespaceDeclaration;
|
|
4395
|
+
return this.abort(namespaceDeclaration);
|
|
4691
4396
|
}
|
|
4692
4397
|
|
|
4693
4398
|
const otherNamespaceDeclaration = other as JS.NamespaceDeclaration;
|
|
4694
4399
|
|
|
4695
4400
|
// Compare modifiers
|
|
4696
4401
|
if (namespaceDeclaration.modifiers.length !== otherNamespaceDeclaration.modifiers.length) {
|
|
4697
|
-
this.abort();
|
|
4698
|
-
return namespaceDeclaration;
|
|
4402
|
+
return this.abort(namespaceDeclaration);
|
|
4699
4403
|
}
|
|
4700
4404
|
|
|
4701
4405
|
// Visit each modifier in lock step
|
|
@@ -4706,8 +4410,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4706
4410
|
|
|
4707
4411
|
// Compare keywordType
|
|
4708
4412
|
if (namespaceDeclaration.keywordType.element !== otherNamespaceDeclaration.keywordType.element) {
|
|
4709
|
-
this.abort();
|
|
4710
|
-
return namespaceDeclaration;
|
|
4413
|
+
return this.abort(namespaceDeclaration);
|
|
4711
4414
|
}
|
|
4712
4415
|
|
|
4713
4416
|
// Visit name
|
|
@@ -4716,8 +4419,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4716
4419
|
|
|
4717
4420
|
// Compare body
|
|
4718
4421
|
if ((namespaceDeclaration.body === undefined) !== (otherNamespaceDeclaration.body === undefined)) {
|
|
4719
|
-
this.abort();
|
|
4720
|
-
return namespaceDeclaration;
|
|
4422
|
+
return this.abort(namespaceDeclaration);
|
|
4721
4423
|
}
|
|
4722
4424
|
|
|
4723
4425
|
// Visit body if present
|
|
@@ -4738,8 +4440,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4738
4440
|
*/
|
|
4739
4441
|
override async visitTypeLiteral(typeLiteral: JS.TypeLiteral, other: J): Promise<J | undefined> {
|
|
4740
4442
|
if (!this.match || other.kind !== JS.Kind.TypeLiteral) {
|
|
4741
|
-
this.abort();
|
|
4742
|
-
return typeLiteral;
|
|
4443
|
+
return this.abort(typeLiteral);
|
|
4743
4444
|
}
|
|
4744
4445
|
|
|
4745
4446
|
const otherTypeLiteral = other as JS.TypeLiteral;
|
|
@@ -4760,16 +4461,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4760
4461
|
*/
|
|
4761
4462
|
override async visitBindingElement(bindingElement: JS.BindingElement, other: J): Promise<J | undefined> {
|
|
4762
4463
|
if (!this.match || other.kind !== JS.Kind.BindingElement) {
|
|
4763
|
-
this.abort();
|
|
4764
|
-
return bindingElement;
|
|
4464
|
+
return this.abort(bindingElement);
|
|
4765
4465
|
}
|
|
4766
4466
|
|
|
4767
4467
|
const otherBindingElement = other as JS.BindingElement;
|
|
4768
4468
|
|
|
4769
4469
|
// Compare propertyName
|
|
4770
4470
|
if ((bindingElement.propertyName === undefined) !== (otherBindingElement.propertyName === undefined)) {
|
|
4771
|
-
this.abort();
|
|
4772
|
-
return bindingElement;
|
|
4471
|
+
return this.abort(bindingElement);
|
|
4773
4472
|
}
|
|
4774
4473
|
|
|
4775
4474
|
// Visit propertyName if present
|
|
@@ -4784,8 +4483,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4784
4483
|
|
|
4785
4484
|
// Compare initializer
|
|
4786
4485
|
if ((bindingElement.initializer === undefined) !== (otherBindingElement.initializer === undefined)) {
|
|
4787
|
-
this.abort();
|
|
4788
|
-
return bindingElement;
|
|
4486
|
+
return this.abort(bindingElement);
|
|
4789
4487
|
}
|
|
4790
4488
|
|
|
4791
4489
|
// Visit initializer if present
|
|
@@ -4806,16 +4504,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4806
4504
|
*/
|
|
4807
4505
|
override async visitArrayBindingPattern(arrayBindingPattern: JS.ArrayBindingPattern, other: J): Promise<J | undefined> {
|
|
4808
4506
|
if (!this.match || other.kind !== JS.Kind.ArrayBindingPattern) {
|
|
4809
|
-
this.abort();
|
|
4810
|
-
return arrayBindingPattern;
|
|
4507
|
+
return this.abort(arrayBindingPattern);
|
|
4811
4508
|
}
|
|
4812
4509
|
|
|
4813
4510
|
const otherArrayBindingPattern = other as JS.ArrayBindingPattern;
|
|
4814
4511
|
|
|
4815
4512
|
// Compare elements
|
|
4816
4513
|
if (arrayBindingPattern.elements.elements.length !== otherArrayBindingPattern.elements.elements.length) {
|
|
4817
|
-
this.abort();
|
|
4818
|
-
return arrayBindingPattern;
|
|
4514
|
+
return this.abort(arrayBindingPattern);
|
|
4819
4515
|
}
|
|
4820
4516
|
|
|
4821
4517
|
// Visit each element in lock step
|
|
@@ -4836,16 +4532,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4836
4532
|
*/
|
|
4837
4533
|
override async visitExportDeclaration(exportDeclaration: JS.ExportDeclaration, other: J): Promise<J | undefined> {
|
|
4838
4534
|
if (!this.match || other.kind !== JS.Kind.ExportDeclaration) {
|
|
4839
|
-
this.abort();
|
|
4840
|
-
return exportDeclaration;
|
|
4535
|
+
return this.abort(exportDeclaration);
|
|
4841
4536
|
}
|
|
4842
4537
|
|
|
4843
4538
|
const otherExportDeclaration = other as JS.ExportDeclaration;
|
|
4844
4539
|
|
|
4845
4540
|
// Compare modifiers
|
|
4846
4541
|
if (exportDeclaration.modifiers.length !== otherExportDeclaration.modifiers.length) {
|
|
4847
|
-
this.abort();
|
|
4848
|
-
return exportDeclaration;
|
|
4542
|
+
return this.abort(exportDeclaration);
|
|
4849
4543
|
}
|
|
4850
4544
|
|
|
4851
4545
|
// Visit each modifier in lock step
|
|
@@ -4856,14 +4550,12 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4856
4550
|
|
|
4857
4551
|
// Compare typeOnly
|
|
4858
4552
|
if (exportDeclaration.typeOnly.element !== otherExportDeclaration.typeOnly.element) {
|
|
4859
|
-
this.abort();
|
|
4860
|
-
return exportDeclaration;
|
|
4553
|
+
return this.abort(exportDeclaration);
|
|
4861
4554
|
}
|
|
4862
4555
|
|
|
4863
4556
|
// Compare exportClause
|
|
4864
4557
|
if ((exportDeclaration.exportClause === undefined) !== (otherExportDeclaration.exportClause === undefined)) {
|
|
4865
|
-
this.abort();
|
|
4866
|
-
return exportDeclaration;
|
|
4558
|
+
return this.abort(exportDeclaration);
|
|
4867
4559
|
}
|
|
4868
4560
|
|
|
4869
4561
|
// Visit exportClause if present
|
|
@@ -4874,8 +4566,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4874
4566
|
|
|
4875
4567
|
// Compare moduleSpecifier
|
|
4876
4568
|
if ((exportDeclaration.moduleSpecifier === undefined) !== (otherExportDeclaration.moduleSpecifier === undefined)) {
|
|
4877
|
-
this.abort();
|
|
4878
|
-
return exportDeclaration;
|
|
4569
|
+
return this.abort(exportDeclaration);
|
|
4879
4570
|
}
|
|
4880
4571
|
|
|
4881
4572
|
// Visit moduleSpecifier if present
|
|
@@ -4886,8 +4577,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4886
4577
|
|
|
4887
4578
|
// Compare attributes
|
|
4888
4579
|
if ((exportDeclaration.attributes === undefined) !== (otherExportDeclaration.attributes === undefined)) {
|
|
4889
|
-
this.abort();
|
|
4890
|
-
return exportDeclaration;
|
|
4580
|
+
return this.abort(exportDeclaration);
|
|
4891
4581
|
}
|
|
4892
4582
|
|
|
4893
4583
|
// Visit attributes if present
|
|
@@ -4908,16 +4598,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4908
4598
|
*/
|
|
4909
4599
|
override async visitExportAssignment(exportAssignment: JS.ExportAssignment, other: J): Promise<J | undefined> {
|
|
4910
4600
|
if (!this.match || other.kind !== JS.Kind.ExportAssignment) {
|
|
4911
|
-
this.abort();
|
|
4912
|
-
return exportAssignment;
|
|
4601
|
+
return this.abort(exportAssignment);
|
|
4913
4602
|
}
|
|
4914
4603
|
|
|
4915
4604
|
const otherExportAssignment = other as JS.ExportAssignment;
|
|
4916
4605
|
|
|
4917
4606
|
// Compare exportEquals
|
|
4918
4607
|
if (exportAssignment.exportEquals !== otherExportAssignment.exportEquals) {
|
|
4919
|
-
this.abort();
|
|
4920
|
-
return exportAssignment;
|
|
4608
|
+
return this.abort(exportAssignment);
|
|
4921
4609
|
}
|
|
4922
4610
|
|
|
4923
4611
|
// Visit expression
|
|
@@ -4936,16 +4624,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4936
4624
|
*/
|
|
4937
4625
|
override async visitNamedExports(namedExports: JS.NamedExports, other: J): Promise<J | undefined> {
|
|
4938
4626
|
if (!this.match || other.kind !== JS.Kind.NamedExports) {
|
|
4939
|
-
this.abort();
|
|
4940
|
-
return namedExports;
|
|
4627
|
+
return this.abort(namedExports);
|
|
4941
4628
|
}
|
|
4942
4629
|
|
|
4943
4630
|
const otherNamedExports = other as JS.NamedExports;
|
|
4944
4631
|
|
|
4945
4632
|
// Compare elements
|
|
4946
4633
|
if (namedExports.elements.elements.length !== otherNamedExports.elements.elements.length) {
|
|
4947
|
-
this.abort();
|
|
4948
|
-
return namedExports;
|
|
4634
|
+
return this.abort(namedExports);
|
|
4949
4635
|
}
|
|
4950
4636
|
|
|
4951
4637
|
// Visit each element in lock step
|
|
@@ -4966,16 +4652,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4966
4652
|
*/
|
|
4967
4653
|
override async visitExportSpecifier(exportSpecifier: JS.ExportSpecifier, other: J): Promise<J | undefined> {
|
|
4968
4654
|
if (!this.match || other.kind !== JS.Kind.ExportSpecifier) {
|
|
4969
|
-
this.abort();
|
|
4970
|
-
return exportSpecifier;
|
|
4655
|
+
return this.abort(exportSpecifier);
|
|
4971
4656
|
}
|
|
4972
4657
|
|
|
4973
4658
|
const otherExportSpecifier = other as JS.ExportSpecifier;
|
|
4974
4659
|
|
|
4975
4660
|
// Compare typeOnly
|
|
4976
4661
|
if (exportSpecifier.typeOnly.element !== otherExportSpecifier.typeOnly.element) {
|
|
4977
|
-
this.abort();
|
|
4978
|
-
return exportSpecifier;
|
|
4662
|
+
return this.abort(exportSpecifier);
|
|
4979
4663
|
}
|
|
4980
4664
|
|
|
4981
4665
|
// Visit specifier
|
|
@@ -4994,16 +4678,14 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
4994
4678
|
*/
|
|
4995
4679
|
override async visitComputedPropertyMethodDeclaration(computedPropMethod: JS.ComputedPropertyMethodDeclaration, other: J): Promise<J | undefined> {
|
|
4996
4680
|
if (!this.match || other.kind !== JS.Kind.ComputedPropertyMethodDeclaration) {
|
|
4997
|
-
this.abort();
|
|
4998
|
-
return computedPropMethod;
|
|
4681
|
+
return this.abort(computedPropMethod);
|
|
4999
4682
|
}
|
|
5000
4683
|
|
|
5001
4684
|
const otherComputedPropMethod = other as JS.ComputedPropertyMethodDeclaration;
|
|
5002
4685
|
|
|
5003
4686
|
// Compare leading annotations
|
|
5004
4687
|
if (computedPropMethod.leadingAnnotations.length !== otherComputedPropMethod.leadingAnnotations.length) {
|
|
5005
|
-
this.abort();
|
|
5006
|
-
return computedPropMethod;
|
|
4688
|
+
return this.abort(computedPropMethod);
|
|
5007
4689
|
}
|
|
5008
4690
|
|
|
5009
4691
|
// Visit leading annotations in lock step
|
|
@@ -5014,8 +4696,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
5014
4696
|
|
|
5015
4697
|
// Compare modifiers
|
|
5016
4698
|
if (computedPropMethod.modifiers.length !== otherComputedPropMethod.modifiers.length) {
|
|
5017
|
-
this.abort();
|
|
5018
|
-
return computedPropMethod;
|
|
4699
|
+
return this.abort(computedPropMethod);
|
|
5019
4700
|
}
|
|
5020
4701
|
|
|
5021
4702
|
// Visit modifiers in lock step
|
|
@@ -5026,8 +4707,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
5026
4707
|
|
|
5027
4708
|
// Compare type parameters
|
|
5028
4709
|
if (!!computedPropMethod.typeParameters !== !!otherComputedPropMethod.typeParameters) {
|
|
5029
|
-
this.abort();
|
|
5030
|
-
return computedPropMethod;
|
|
4710
|
+
return this.abort(computedPropMethod);
|
|
5031
4711
|
}
|
|
5032
4712
|
|
|
5033
4713
|
if (computedPropMethod.typeParameters) {
|
|
@@ -5037,8 +4717,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
5037
4717
|
|
|
5038
4718
|
// Compare return type expression
|
|
5039
4719
|
if (!!computedPropMethod.returnTypeExpression !== !!otherComputedPropMethod.returnTypeExpression) {
|
|
5040
|
-
this.abort();
|
|
5041
|
-
return computedPropMethod;
|
|
4720
|
+
return this.abort(computedPropMethod);
|
|
5042
4721
|
}
|
|
5043
4722
|
|
|
5044
4723
|
if (computedPropMethod.returnTypeExpression) {
|
|
@@ -5052,8 +4731,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
5052
4731
|
|
|
5053
4732
|
// Compare parameters
|
|
5054
4733
|
if (computedPropMethod.parameters.elements.length !== otherComputedPropMethod.parameters.elements.length) {
|
|
5055
|
-
this.abort();
|
|
5056
|
-
return computedPropMethod;
|
|
4734
|
+
return this.abort(computedPropMethod);
|
|
5057
4735
|
}
|
|
5058
4736
|
|
|
5059
4737
|
// Visit parameters in lock step
|
|
@@ -5065,8 +4743,7 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
5065
4743
|
|
|
5066
4744
|
// Compare body
|
|
5067
4745
|
if (!!computedPropMethod.body !== !!otherComputedPropMethod.body) {
|
|
5068
|
-
this.abort();
|
|
5069
|
-
return computedPropMethod;
|
|
4746
|
+
return this.abort(computedPropMethod);
|
|
5070
4747
|
}
|
|
5071
4748
|
|
|
5072
4749
|
if (computedPropMethod.body) {
|
|
@@ -5076,3 +4753,209 @@ export class JavaScriptComparatorVisitor extends JavaScriptVisitor<J> {
|
|
|
5076
4753
|
return computedPropMethod;
|
|
5077
4754
|
}
|
|
5078
4755
|
}
|
|
4756
|
+
|
|
4757
|
+
/**
|
|
4758
|
+
* A comparator visitor that checks semantic equality including type attribution.
|
|
4759
|
+
* This ensures comparisons account for type information, allowing semantically
|
|
4760
|
+
* equivalent code to match even when structurally different (e.g., `foo()` vs `module.foo()`
|
|
4761
|
+
* when both refer to the same method).
|
|
4762
|
+
*/
|
|
4763
|
+
export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVisitor {
|
|
4764
|
+
/**
|
|
4765
|
+
* Checks if two types are semantically equal.
|
|
4766
|
+
* For method types, this checks that the declaring type and method name match.
|
|
4767
|
+
*/
|
|
4768
|
+
private isOfType(target?: Type, source?: Type): boolean {
|
|
4769
|
+
if (!target || !source) {
|
|
4770
|
+
return target === source;
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
if (target.kind !== source.kind) {
|
|
4774
|
+
return false;
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4777
|
+
// For method types, check declaring type
|
|
4778
|
+
// Note: We don't check the name field because it might not be fully resolved in patterns
|
|
4779
|
+
// The method invocation visitor already checks that simple names match
|
|
4780
|
+
if (target.kind === Type.Kind.Method && source.kind === Type.Kind.Method) {
|
|
4781
|
+
const targetMethod = target as Type.Method;
|
|
4782
|
+
const sourceMethod = source as Type.Method;
|
|
4783
|
+
|
|
4784
|
+
// Check if declaring types match
|
|
4785
|
+
const declaringTypesMatch = this.isOfType(targetMethod.declaringType, sourceMethod.declaringType);
|
|
4786
|
+
if (declaringTypesMatch) {
|
|
4787
|
+
return true;
|
|
4788
|
+
}
|
|
4789
|
+
|
|
4790
|
+
// If declaring types don't match exactly, check if they might be semantically equivalent
|
|
4791
|
+
// (e.g., 'react' module vs 'React' namespace importing from 'react')
|
|
4792
|
+
// In this case, we check if the method signatures are otherwise identical
|
|
4793
|
+
if (targetMethod.declaringType && sourceMethod.declaringType &&
|
|
4794
|
+
Type.isFullyQualified(targetMethod.declaringType) && Type.isFullyQualified(sourceMethod.declaringType)) {
|
|
4795
|
+
|
|
4796
|
+
const targetDeclType = targetMethod.declaringType as Type.FullyQualified;
|
|
4797
|
+
const sourceDeclType = sourceMethod.declaringType as Type.FullyQualified;
|
|
4798
|
+
|
|
4799
|
+
// Check if the declaring type names could represent the same module
|
|
4800
|
+
// (e.g., 'react' and 'React', where React is a namespace alias)
|
|
4801
|
+
const targetFQN = Type.FullyQualified.getFullyQualifiedName(targetDeclType);
|
|
4802
|
+
const sourceFQN = Type.FullyQualified.getFullyQualifiedName(sourceDeclType);
|
|
4803
|
+
|
|
4804
|
+
// If the names differ only in case and one appears to be a module name
|
|
4805
|
+
// (all lowercase) while the other is capitalized (namespace alias),
|
|
4806
|
+
// check if the method signatures match
|
|
4807
|
+
if (targetFQN.toLowerCase() === sourceFQN.toLowerCase()) {
|
|
4808
|
+
// Method signatures should match: return type and parameters
|
|
4809
|
+
if (!this.isOfType(targetMethod.returnType, sourceMethod.returnType)) {
|
|
4810
|
+
return false;
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4813
|
+
if (targetMethod.parameterTypes.length !== sourceMethod.parameterTypes.length) {
|
|
4814
|
+
return false;
|
|
4815
|
+
}
|
|
4816
|
+
|
|
4817
|
+
for (let i = 0; i < targetMethod.parameterTypes.length; i++) {
|
|
4818
|
+
if (!this.isOfType(targetMethod.parameterTypes[i], sourceMethod.parameterTypes[i])) {
|
|
4819
|
+
return false;
|
|
4820
|
+
}
|
|
4821
|
+
}
|
|
4822
|
+
|
|
4823
|
+
return true;
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4827
|
+
return false;
|
|
4828
|
+
}
|
|
4829
|
+
|
|
4830
|
+
// For fully qualified types, check the fully qualified name
|
|
4831
|
+
if (Type.isFullyQualified(target) && Type.isFullyQualified(source)) {
|
|
4832
|
+
return Type.FullyQualified.getFullyQualifiedName(target) ===
|
|
4833
|
+
Type.FullyQualified.getFullyQualifiedName(source);
|
|
4834
|
+
}
|
|
4835
|
+
|
|
4836
|
+
// Default: types are equal if they're the same kind
|
|
4837
|
+
return true;
|
|
4838
|
+
}
|
|
4839
|
+
|
|
4840
|
+
/**
|
|
4841
|
+
* Override method invocation comparison to include type attribution checking.
|
|
4842
|
+
* When types match semantically, we allow matching even if one has a receiver
|
|
4843
|
+
* and the other doesn't (e.g., `isDate(x)` vs `util.isDate(x)`).
|
|
4844
|
+
*/
|
|
4845
|
+
override async visitMethodInvocation(method: J.MethodInvocation, other: J): Promise<J | undefined> {
|
|
4846
|
+
if (other.kind !== J.Kind.MethodInvocation) {
|
|
4847
|
+
return this.abort(method);
|
|
4848
|
+
}
|
|
4849
|
+
|
|
4850
|
+
const otherMethod = other as J.MethodInvocation;
|
|
4851
|
+
|
|
4852
|
+
// Check basic structural equality first
|
|
4853
|
+
if (method.name.simpleName !== otherMethod.name.simpleName ||
|
|
4854
|
+
method.arguments.elements.length !== otherMethod.arguments.elements.length) {
|
|
4855
|
+
return this.abort(method);
|
|
4856
|
+
}
|
|
4857
|
+
|
|
4858
|
+
// Check type attribution
|
|
4859
|
+
// Both must have method types for semantic equality
|
|
4860
|
+
if (!method.methodType || !otherMethod.methodType) {
|
|
4861
|
+
// If template has type but target doesn't, they don't match
|
|
4862
|
+
if (method.methodType || otherMethod.methodType) {
|
|
4863
|
+
return this.abort(method);
|
|
4864
|
+
}
|
|
4865
|
+
// If neither has type, fall through to structural comparison
|
|
4866
|
+
return super.visitMethodInvocation(method, other);
|
|
4867
|
+
}
|
|
4868
|
+
|
|
4869
|
+
// Both have types - check they match semantically
|
|
4870
|
+
const typesMatch = this.isOfType(method.methodType, otherMethod.methodType);
|
|
4871
|
+
if (!typesMatch) {
|
|
4872
|
+
// Types don't match - abort comparison
|
|
4873
|
+
return this.abort(method);
|
|
4874
|
+
}
|
|
4875
|
+
|
|
4876
|
+
// Types match! Now check if we can ignore receiver differences.
|
|
4877
|
+
// We can only ignore receiver differences when one or both receivers are identifiers
|
|
4878
|
+
// that represent module/namespace imports (e.g., `util` in `util.isDate()`).
|
|
4879
|
+
// For other receivers (e.g., variables, expressions), we must compare them.
|
|
4880
|
+
|
|
4881
|
+
const canIgnoreReceiverDifference =
|
|
4882
|
+
// Case 1: One has no select (direct call like `forwardRef()`), other has select (namespace like `React.forwardRef()`)
|
|
4883
|
+
(!method.select && otherMethod.select) ||
|
|
4884
|
+
(method.select && !otherMethod.select);
|
|
4885
|
+
|
|
4886
|
+
if (!canIgnoreReceiverDifference) {
|
|
4887
|
+
// Both have selects or both don't - must compare them structurally
|
|
4888
|
+
if ((method.select === undefined) !== (otherMethod.select === undefined)) {
|
|
4889
|
+
return this.abort(method);
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
if (method.select && otherMethod.select) {
|
|
4893
|
+
await this.visit(method.select.element, otherMethod.select.element);
|
|
4894
|
+
if (!this.match) {
|
|
4895
|
+
return this.abort(method);
|
|
4896
|
+
}
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4899
|
+
|
|
4900
|
+
// Compare type parameters
|
|
4901
|
+
if ((method.typeParameters === undefined) !== (otherMethod.typeParameters === undefined)) {
|
|
4902
|
+
return this.abort(method);
|
|
4903
|
+
}
|
|
4904
|
+
|
|
4905
|
+
if (method.typeParameters && otherMethod.typeParameters) {
|
|
4906
|
+
if (method.typeParameters.elements.length !== otherMethod.typeParameters.elements.length) {
|
|
4907
|
+
return this.abort(method);
|
|
4908
|
+
}
|
|
4909
|
+
for (let i = 0; i < method.typeParameters.elements.length; i++) {
|
|
4910
|
+
await this.visit(method.typeParameters.elements[i].element, otherMethod.typeParameters.elements[i].element);
|
|
4911
|
+
if (!this.match) {
|
|
4912
|
+
return this.abort(method);
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4917
|
+
// Compare name (already checked simpleName above, but visit for markers/prefix)
|
|
4918
|
+
await this.visit(method.name, otherMethod.name);
|
|
4919
|
+
if (!this.match) {
|
|
4920
|
+
return this.abort(method);
|
|
4921
|
+
}
|
|
4922
|
+
|
|
4923
|
+
// Compare arguments
|
|
4924
|
+
for (let i = 0; i < method.arguments.elements.length; i++) {
|
|
4925
|
+
await this.visit(method.arguments.elements[i].element, otherMethod.arguments.elements[i].element);
|
|
4926
|
+
if (!this.match) {
|
|
4927
|
+
return this.abort(method);
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
|
|
4931
|
+
return method;
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4934
|
+
/**
|
|
4935
|
+
* Override identifier comparison to include type checking for field access.
|
|
4936
|
+
*/
|
|
4937
|
+
override async visitIdentifier(identifier: J.Identifier, other: J): Promise<J | undefined> {
|
|
4938
|
+
if (other.kind !== J.Kind.Identifier) {
|
|
4939
|
+
return this.abort(identifier);
|
|
4940
|
+
}
|
|
4941
|
+
|
|
4942
|
+
const otherIdentifier = other as J.Identifier;
|
|
4943
|
+
|
|
4944
|
+
// Check name matches
|
|
4945
|
+
if (identifier.simpleName !== otherIdentifier.simpleName) {
|
|
4946
|
+
return this.abort(identifier);
|
|
4947
|
+
}
|
|
4948
|
+
|
|
4949
|
+
// For identifiers with field types, check type attribution
|
|
4950
|
+
if (identifier.fieldType && otherIdentifier.fieldType) {
|
|
4951
|
+
if (!this.isOfType(identifier.fieldType, otherIdentifier.fieldType)) {
|
|
4952
|
+
return this.abort(identifier);
|
|
4953
|
+
}
|
|
4954
|
+
} else if (identifier.fieldType || otherIdentifier.fieldType) {
|
|
4955
|
+
// If only one has a type, they don't match
|
|
4956
|
+
return this.abort(identifier);
|
|
4957
|
+
}
|
|
4958
|
+
|
|
4959
|
+
return super.visitIdentifier(identifier, other);
|
|
4960
|
+
}
|
|
4961
|
+
}
|