-
-
Notifications
You must be signed in to change notification settings - Fork 342
/
CtVisitor.java
580 lines (487 loc) · 14.7 KB
/
CtVisitor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
/*
* SPDX-License-Identifier: (MIT OR CECILL-C)
*
* Copyright (C) 2006-2023 INRIA and contributors
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.reflect.visitor;
import java.lang.annotation.Annotation;
import spoon.reflect.code.CtAnnotationFieldAccess;
import spoon.reflect.code.CtArrayRead;
import spoon.reflect.code.CtArrayWrite;
import spoon.reflect.code.CtAssert;
import spoon.reflect.code.CtAssignment;
import spoon.reflect.code.CtBinaryOperator;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtBreak;
import spoon.reflect.code.CtCase;
import spoon.reflect.code.CtCasePattern;
import spoon.reflect.code.CtCatch;
import spoon.reflect.code.CtCatchVariable;
import spoon.reflect.code.CtCodeSnippetExpression;
import spoon.reflect.code.CtCodeSnippetStatement;
import spoon.reflect.code.CtComment;
import spoon.reflect.code.CtConditional;
import spoon.reflect.code.CtConstructorCall;
import spoon.reflect.code.CtContinue;
import spoon.reflect.code.CtDo;
import spoon.reflect.code.CtExecutableReferenceExpression;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtFieldRead;
import spoon.reflect.code.CtFieldWrite;
import spoon.reflect.code.CtFor;
import spoon.reflect.code.CtForEach;
import spoon.reflect.code.CtIf;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtJavaDoc;
import spoon.reflect.code.CtJavaDocTag;
import spoon.reflect.code.CtLambda;
import spoon.reflect.code.CtLiteral;
import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.code.CtNewArray;
import spoon.reflect.code.CtNewClass;
import spoon.reflect.code.CtOperatorAssignment;
import spoon.reflect.code.CtRecordPattern;
import spoon.reflect.code.CtReturn;
import spoon.reflect.code.CtStatementList;
import spoon.reflect.code.CtSuperAccess;
import spoon.reflect.code.CtSwitch;
import spoon.reflect.code.CtSwitchExpression;
import spoon.reflect.code.CtSynchronized;
import spoon.reflect.code.CtTextBlock;
import spoon.reflect.code.CtThisAccess;
import spoon.reflect.code.CtThrow;
import spoon.reflect.code.CtTry;
import spoon.reflect.code.CtTryWithResource;
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.code.CtTypePattern;
import spoon.reflect.code.CtUnaryOperator;
import spoon.reflect.code.CtVariableRead;
import spoon.reflect.code.CtVariableWrite;
import spoon.reflect.code.CtWhile;
import spoon.reflect.code.CtYieldStatement;
import spoon.reflect.declaration.CtAnnotation;
import spoon.reflect.declaration.CtAnnotationMethod;
import spoon.reflect.declaration.CtAnnotationType;
import spoon.reflect.declaration.CtAnonymousExecutable;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtCompilationUnit;
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtEnum;
import spoon.reflect.declaration.CtEnumValue;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.declaration.CtInterface;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtModule;
import spoon.reflect.declaration.CtModuleRequirement;
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtPackageDeclaration;
import spoon.reflect.declaration.CtPackageExport;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtProvidedService;
import spoon.reflect.declaration.CtReceiverParameter;
import spoon.reflect.declaration.CtRecord;
import spoon.reflect.declaration.CtRecordComponent;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.declaration.CtUsedService;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.reference.CtIntersectionTypeReference;
import spoon.reflect.reference.CtLocalVariableReference;
import spoon.reflect.reference.CtModuleReference;
import spoon.reflect.reference.CtPackageReference;
import spoon.reflect.reference.CtParameterReference;
import spoon.reflect.reference.CtTypeMemberWildcardImportReference;
import spoon.reflect.reference.CtTypeParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.reference.CtUnboundVariableReference;
import spoon.reflect.reference.CtWildcardReference;
/**
* This interface defines the visitor for the Spoon metamodel, as defined in
* {@link spoon.reflect.declaration}, {@link spoon.reflect.code}, and
* {@link spoon.reflect.reference}. It declares a visit method for each
* element of the AST.
*/
public interface CtVisitor {
/**
* Visits an annotation.
*/
<A extends Annotation> void visitCtAnnotation(CtAnnotation<A> annotation);
/**
* Visits a code snippet expression.
*/
<T> void visitCtCodeSnippetExpression(CtCodeSnippetExpression<T> expression);
/**
* Visits a code snippet statement.
*/
void visitCtCodeSnippetStatement(CtCodeSnippetStatement statement);
/**
* Visits an annotation type declaration.
*/
<A extends Annotation> void visitCtAnnotationType(CtAnnotationType<A> annotationType);
/**
* Visits an anonymous executable.
*/
void visitCtAnonymousExecutable(CtAnonymousExecutable anonymousExec);
/**
* Visits an array read access.
*/
<T> void visitCtArrayRead(CtArrayRead<T> arrayRead);
/**
* Visits an array write access.
*/
<T> void visitCtArrayWrite(CtArrayWrite<T> arrayWrite);
/**
* Visits a reference to an array type.
*/
<T> void visitCtArrayTypeReference(CtArrayTypeReference<T> reference);
/**
* Visits an assert.
*/
<T> void visitCtAssert(CtAssert<T> asserted);
/**
* Visits an assignment.
*/
<T, A extends T> void visitCtAssignment(CtAssignment<T, A> assignement);
/**
* Visits a binary operator.
*/
<T> void visitCtBinaryOperator(CtBinaryOperator<T> operator);
/**
* Visits a block of code.
*/
<R> void visitCtBlock(CtBlock<R> block);
/**
* Visits a <code>break</code> statement.
*/
void visitCtBreak(CtBreak breakStatement);
/**
* Visits a <code>case</code> clause.
*/
<S> void visitCtCase(CtCase<S> caseStatement);
/**
* Visits a <code>catch</code> clause.
*/
void visitCtCatch(CtCatch catchBlock);
/**
* Visits a class declaration.
*/
<T> void visitCtClass(CtClass<T> ctClass);
/**
* Visits a type parameter declaration.
*/
void visitCtTypeParameter(CtTypeParameter typeParameter);
/**
* Visits a conditional expression
*/
<T> void visitCtConditional(CtConditional<T> conditional);
/**
* Visits a constructor declaration.
*/
<T> void visitCtConstructor(CtConstructor<T> c);
/**
* Visits a <code>continue</code> statement.
*/
void visitCtContinue(CtContinue continueStatement);
/**
* Visits a <code>do</code> loop.
*/
void visitCtDo(CtDo doLoop);
/**
* Visits an enumeration declaration.
*/
<T extends Enum<?>> void visitCtEnum(CtEnum<T> ctEnum);
/**
* Visits a reference to an executable.
*/
<T> void visitCtExecutableReference(CtExecutableReference<T> reference);
/**
* Visits a field declaration.
*/
<T> void visitCtField(CtField<T> f);
/**
* Visits an enum value declaration.
*/
<T> void visitCtEnumValue(CtEnumValue<T> enumValue);
/**
* Visits a this access.
*/
<T> void visitCtThisAccess(CtThisAccess<T> thisAccess);
/**
* Visits a reference to a field.
*/
<T> void visitCtFieldReference(CtFieldReference<T> reference);
/**
* Visits a reference to an unbound field
*/
<T> void visitCtUnboundVariableReference(CtUnboundVariableReference<T> reference);
/**
* Visits a <code>for</code> loop.
*/
void visitCtFor(CtFor forLoop);
/**
* Visits an enhanced <code>for</code> loop.
*/
void visitCtForEach(CtForEach foreach);
/**
* Visits an <code>if</code> statement.
*/
void visitCtIf(CtIf ifElement);
/**
* Visits an interface declaration.
*/
<T> void visitCtInterface(CtInterface<T> intrface);
/**
* Visits an executable invocation.
*/
<T> void visitCtInvocation(CtInvocation<T> invocation);
/**
* Visits a literal expression.
*/
<T> void visitCtLiteral(CtLiteral<T> literal);
/**
* Visits a literal TextBlock string.
*/
void visitCtTextBlock(CtTextBlock ctTextBlock);
/**
* Visits a local variable declaration.
*/
<T> void visitCtLocalVariable(CtLocalVariable<T> localVariable);
/**
* Visits a reference to a local variable.
*/
<T> void visitCtLocalVariableReference(CtLocalVariableReference<T> reference);
/**
* Visits a catch variable declaration.
*/
<T> void visitCtCatchVariable(CtCatchVariable<T> catchVariable);
/**
* Visits a reference to a catch variable.
*/
<T> void visitCtCatchVariableReference(CtCatchVariableReference<T> reference);
/**
* Visits a method declaration.
*/
<T> void visitCtMethod(CtMethod<T> m);
/**
* Visits an annotation method declaration.
*/
<T> void visitCtAnnotationMethod(CtAnnotationMethod<T> annotationMethod);
/**
* Visits an array construction.
*/
<T> void visitCtNewArray(CtNewArray<T> newArray);
/**
* Visits a call to a constructor.
*/
<T> void visitCtConstructorCall(CtConstructorCall<T> ctConstructorCall);
/**
* Visits an anonymous class construction.
*/
<T> void visitCtNewClass(CtNewClass<T> newClass);
/**
* Visits an anonymous method construction.
*/
<T> void visitCtLambda(CtLambda<T> lambda);
/**
* Visits a reference to an executable.
*/
<T, E extends CtExpression<?>> void visitCtExecutableReferenceExpression(
CtExecutableReferenceExpression<T, E> expression);
/**
* Visits an operator assignment.
*/
<T, A extends T> void visitCtOperatorAssignment(
CtOperatorAssignment<T, A> assignment);
/**
* Visits a package declaration.
*/
void visitCtPackage(CtPackage ctPackage);
/**
* Visits a reference to a package.
*/
void visitCtPackageReference(CtPackageReference reference);
/**
* Visits a parameter declaration.
*/
<T> void visitCtParameter(CtParameter<T> parameter);
/**
* Visits a reference to a parameter.
*/
<T> void visitCtParameterReference(CtParameterReference<T> reference);
/**
* Visits a <code>return</code> statement.
*/
<R> void visitCtReturn(CtReturn<R> returnStatement);
/**
* Visits a statement list.
*/
<R> void visitCtStatementList(CtStatementList statements);
/**
* Visits a <code>switch</code> statement.
*/
<S> void visitCtSwitch(CtSwitch<S> switchStatement);
/**
* Visits a <code>switch</code> expression.
*/
<T, S> void visitCtSwitchExpression(CtSwitchExpression<T, S> switchExpression);
/**
* Visits a <code>synchronized</code> modifier.
*/
void visitCtSynchronized(CtSynchronized synchro);
/**
* Visits a <code>throw</code> statement.
*/
void visitCtThrow(CtThrow throwStatement);
/**
* Visits a <code>try</code> statement.
*/
void visitCtTry(CtTry tryBlock);
/**
* Visits a <code>try</code> with resource statement.
*/
void visitCtTryWithResource(CtTryWithResource tryWithResource);
/**
* Visits a reference to a type parameter.
*/
void visitCtTypeParameterReference(CtTypeParameterReference ref);
/**
* Visits a reference to a wildcard.
*/
void visitCtWildcardReference(CtWildcardReference wildcardReference);
/**
* Visits an intersection type.
*/
<T> void visitCtIntersectionTypeReference(CtIntersectionTypeReference<T> reference);
/**
* Visits a reference to a type.
*/
<T> void visitCtTypeReference(CtTypeReference<T> reference);
/**
* Visits a type access.
*/
<T> void visitCtTypeAccess(CtTypeAccess<T> typeAccess);
/**
* Visits a unary operator.
*/
<T> void visitCtUnaryOperator(CtUnaryOperator<T> operator);
/**
* Visits a variable read access.
*/
<T> void visitCtVariableRead(CtVariableRead<T> variableRead);
/**
* Visits a variable write access.
*/
<T> void visitCtVariableWrite(CtVariableWrite<T> variableWrite);
/**
* Visits a <code>while</code> loop.
*/
void visitCtWhile(CtWhile whileLoop);
/**
* Visits a field of an annotation.
*/
<T> void visitCtAnnotationFieldAccess(CtAnnotationFieldAccess<T> annotationFieldAccess);
/**
* Visits a field read access.
*/
<T> void visitCtFieldRead(CtFieldRead<T> fieldRead);
/**
* Visits a field write access.
*/
<T> void visitCtFieldWrite(CtFieldWrite<T> fieldWrite);
/**
* Visits an access to a super invocation.
*/
<T> void visitCtSuperAccess(CtSuperAccess<T> f);
/**
* Visits a comment
*/
void visitCtComment(CtComment comment);
/**
* Visits a javadoc comment
*/
void visitCtJavaDoc(CtJavaDoc comment);
/**
* Visits a javadoc tag
*/
void visitCtJavaDocTag(CtJavaDocTag docTag);
/**
* Visits an import declaration
*/
void visitCtImport(CtImport ctImport);
/**
* Visits a module declaration
*/
void visitCtModule(CtModule module);
/**
* Visits a module reference
*/
void visitCtModuleReference(CtModuleReference moduleReference);
/**
* Visits a package export in a module declaration.
*/
void visitCtPackageExport(CtPackageExport moduleExport);
/**
* Visits a "require" directive in a module declaration.
*/
void visitCtModuleRequirement(CtModuleRequirement moduleRequirement);
/**
* Visits a "provides" directive in a module declaration.
*/
void visitCtProvidedService(CtProvidedService moduleProvidedService);
/**
* Visits a "uses" directive in a module declaration.
*/
void visitCtUsedService(CtUsedService usedService);
/**
* Visits a compilation unit
*/
void visitCtCompilationUnit(CtCompilationUnit compilationUnit);
/**
* Visits a package declaration
*/
void visitCtPackageDeclaration(CtPackageDeclaration packageDeclaration);
/**
* Visits an import wildcard static type member reference
*/
void visitCtTypeMemberWildcardImportReference(CtTypeMemberWildcardImportReference wildcardReference);
/**
* Visits a yield statement.
*/
void visitCtYieldStatement(CtYieldStatement statement);
/**
* Visits a pattern.
*
* @param pattern the pattern to visit.
*/
void visitCtTypePattern(CtTypePattern pattern);
/**
* Visits a record.
* @param recordType the record to visit.
*/
void visitCtRecord(CtRecord recordType);
/**
* Visits a record component.
* @param recordComponent the record component to visit.
*/
void visitCtRecordComponent(CtRecordComponent recordComponent);
/**
* Visits a case pattern
* @param casePattern the case pattern to visit.
*/
void visitCtCasePattern(CtCasePattern casePattern);
/**
* Visits a record pattern.
* @param recordPattern the record pattern to visit.
*/
void visitCtRecordPattern(CtRecordPattern recordPattern);
/**
* Visits a receiver parameter.
* @param receiverParameter the receiver parameter to visit.
*/
void visitCtReceiverParameter(CtReceiverParameter receiverParameter);
}