KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > reflect > visitor > CtInheritanceScanner


1 package spoon.reflect.visitor;
2
3 import java.lang.annotation.Annotation JavaDoc;
4 import java.util.Collection JavaDoc;
5
6 import spoon.reflect.code.CtAbstractInvocation;
7 import spoon.reflect.code.CtArrayAccess;
8 import spoon.reflect.code.CtAssert;
9 import spoon.reflect.code.CtAssignment;
10 import spoon.reflect.code.CtBinaryOperator;
11 import spoon.reflect.code.CtBlock;
12 import spoon.reflect.code.CtBreak;
13 import spoon.reflect.code.CtCFlowBreak;
14 import spoon.reflect.code.CtCase;
15 import spoon.reflect.code.CtCatch;
16 import spoon.reflect.code.CtCodeElement;
17 import spoon.reflect.code.CtConditional;
18 import spoon.reflect.code.CtContinue;
19 import spoon.reflect.code.CtDo;
20 import spoon.reflect.code.CtExpression;
21 import spoon.reflect.code.CtFieldAccess;
22 import spoon.reflect.code.CtFor;
23 import spoon.reflect.code.CtForEach;
24 import spoon.reflect.code.CtIf;
25 import spoon.reflect.code.CtInvocation;
26 import spoon.reflect.code.CtLiteral;
27 import spoon.reflect.code.CtLocalVariable;
28 import spoon.reflect.code.CtLoop;
29 import spoon.reflect.code.CtNewArray;
30 import spoon.reflect.code.CtNewClass;
31 import spoon.reflect.code.CtOperatorAssignment;
32 import spoon.reflect.code.CtReturn;
33 import spoon.reflect.code.CtStatement;
34 import spoon.reflect.code.CtStatementList;
35 import spoon.reflect.code.CtSwitch;
36 import spoon.reflect.code.CtSynchronized;
37 import spoon.reflect.code.CtTargetedExpression;
38 import spoon.reflect.code.CtThrow;
39 import spoon.reflect.code.CtTry;
40 import spoon.reflect.code.CtUnaryOperator;
41 import spoon.reflect.code.CtVariableAccess;
42 import spoon.reflect.code.CtWhile;
43 import spoon.reflect.declaration.CtAnnotation;
44 import spoon.reflect.declaration.CtAnnotationType;
45 import spoon.reflect.declaration.CtAnonymousExecutable;
46 import spoon.reflect.declaration.CtClass;
47 import spoon.reflect.declaration.CtConstructor;
48 import spoon.reflect.declaration.CtElement;
49 import spoon.reflect.declaration.CtEnum;
50 import spoon.reflect.declaration.CtExecutable;
51 import spoon.reflect.declaration.CtField;
52 import spoon.reflect.declaration.CtGenericElement;
53 import spoon.reflect.declaration.CtInterface;
54 import spoon.reflect.declaration.CtMethod;
55 import spoon.reflect.declaration.CtModifiable;
56 import spoon.reflect.declaration.CtNamedElement;
57 import spoon.reflect.declaration.CtPackage;
58 import spoon.reflect.declaration.CtParameter;
59 import spoon.reflect.declaration.CtSimpleType;
60 import spoon.reflect.declaration.CtType;
61 import spoon.reflect.declaration.CtTypeParameter;
62 import spoon.reflect.declaration.CtTypedElement;
63 import spoon.reflect.declaration.CtVariable;
64 import spoon.reflect.declaration.ModifierKind;
65 import spoon.reflect.reference.CtArrayTypeReference;
66 import spoon.reflect.reference.CtExecutableReference;
67 import spoon.reflect.reference.CtFieldReference;
68 import spoon.reflect.reference.CtGenericElementReference;
69 import spoon.reflect.reference.CtLocalVariableReference;
70 import spoon.reflect.reference.CtPackageReference;
71 import spoon.reflect.reference.CtParameterReference;
72 import spoon.reflect.reference.CtReference;
73 import spoon.reflect.reference.CtTypeParameterReference;
74 import spoon.reflect.reference.CtTypeReference;
75 import spoon.reflect.reference.CtVariableReference;
76
77 /**
78  * This class provides an abstract implementation of the visitor that allows its
79  * subclasses to scans the metamodel elements by recursively using their
80  * (abstract) supertype scanning methods.
81  */

82 public abstract class CtInheritanceScanner implements CtVisitor {
83
84     /**
85      * Default constructor.
86      */

87     public CtInheritanceScanner() {
88     }
89
90     /**
91      * Generically scans a collection of meta-model elements.
92      */

93     public void scan(Collection JavaDoc<? extends CtElement> elements) {
94         if (elements != null) {
95             for (CtElement e : elements) {
96                 scan(e);
97             }
98         }
99     }
100
101     /**
102      * Generically scans a meta-model element.
103      */

104     public void scan(CtElement element) {
105         if (element != null)
106             element.accept(this);
107     }
108
109     /**
110      * Generically scans a meta-model element reference.
111      */

112     public void scan(CtReference reference) {
113         if (reference != null)
114             reference.accept(this);
115     }
116
117     /**
118      * Scans an abstract invocation.
119      */

120     public <T> void scanCtAbstractInvocation(CtAbstractInvocation<T> a) {
121     }
122
123     /**
124      * Scans an abstract control flow break.
125      */

126     public void scanCtCFlowBreak(CtCFlowBreak flowBreak) {
127         scanCtCodeElement(flowBreak);
128     }
129
130     /**
131      * Scans an abstract code element.
132      */

133     public void scanCtCodeElement(CtCodeElement e) {
134         scanCtElement(e);
135     }
136
137     /**
138      * Scans an abstract element.
139      */

140     public void scanCtElement(CtElement e) {
141     }
142
143     /**
144      * Scans an abstract executable.
145      */

146     public <R> void scanCtExecutable(CtExecutable<R> e) {
147         scanCtGenericElement(e);
148         scanCtNamedElement(e);
149     }
150
151     /**
152      * Scans an abstract expression.
153      */

154     public <T> void scanCtExpression(CtExpression<T> expression) {
155         scanCtCodeElement(expression);
156         scanCtTypedElement(expression);
157     }
158
159     /**
160      * Scans an abstract generic element.
161      */

162     public void scanCtGenericElement(CtGenericElement e) {
163         scanCtElement(e);
164     }
165
166     /**
167      * Scans an abstract generic element reference.
168      */

169     public void scanCtGenericElementReference(
170             CtGenericElementReference reference) {
171     }
172
173     /**
174      * Scans an abstract loop.
175      */

176     public void scanCtLoop(CtLoop loop) {
177         scanCtStatement(loop);
178     }
179
180     /**
181      * Scans an abstract modifiable element.
182      */

183     public void scanCtModifiable(CtModifiable m) {
184         for (ModifierKind modifier : m.getModifiers()) {
185             scanCtModifier(modifier);
186         }
187     }
188
189     /**
190      * Scans a modifier (enumeration).
191      */

192     public void scanCtModifier(ModifierKind m) {
193     }
194
195     /**
196      * Scans an abstract named element.
197      */

198     public void scanCtNamedElement(CtNamedElement e) {
199         scanCtElement(e);
200         scanCtModifiable(e);
201     }
202
203     /**
204      * Scans an abstract reference.
205      */

206     public void scanCtReference(CtReference reference) {
207
208     }
209
210     /**
211      * Scans an abstract simple type.
212      */

213     public <T> void scanCtSimpleType(CtSimpleType<T> t) {
214         scanCtNamedElement(t);
215     }
216
217     /**
218      * Scans an abstract statement.
219      */

220     public void scanCtStatement(CtStatement s) {
221         scanCtCodeElement(s);
222     }
223
224     /**
225      * Scans an abstract targeted expression.
226      */

227     public <T, E extends CtExpression<?>> void scanCtTargetedExpression(
228             CtTargetedExpression<T, E> targetedExpression) {
229         scanCtExpression(targetedExpression);
230     }
231
232     /**
233      * Scans an abstract type.
234      */

235     public <T> void scanCtType(CtType<T> type) {
236         scanCtSimpleType(type);
237         scanCtGenericElement(type);
238     }
239
240     /**
241      * Scans an abstract typed element.
242      */

243     public <T> void scanCtTypedElement(CtTypedElement<T> e) {
244     }
245
246     /**
247      * Scans an abstract variable declaration.
248      */

249     public <T> void scanCtVariable(CtVariable<T> v) {
250         scanCtNamedElement(v);
251         scanCtTypedElement(v);
252     }
253
254     /**
255      * Scans an abstract variable reference.
256      */

257     public <T> void scanCtVariableReference(CtVariableReference<T> reference) {
258         scanCtReference(reference);
259     }
260
261     /**
262      * Generically scans a collection of meta-model references.
263      */

264     public void scanReferences(Collection JavaDoc<? extends CtReference> references) {
265         if (references != null) {
266             for (CtReference r : references) {
267                 scan(r);
268             }
269         }
270     }
271
272     public <A extends Annotation JavaDoc> void visitCtAnnotation(
273             CtAnnotation<A> annotation) {
274         scanCtElement(annotation);
275     }
276
277     public <A extends Annotation JavaDoc> void visitCtAnnotationType(
278             CtAnnotationType<A> annotationType) {
279         scanCtSimpleType(annotationType);
280     }
281
282     public void visitCtAnonymousExecutable(CtAnonymousExecutable e) {
283         scanCtElement(e);
284         scanCtModifiable(e);
285     }
286
287     public <T, E extends CtExpression<?>> void visitCtArrayAccess(
288             CtArrayAccess<T, E> arrayAccess) {
289         scanCtTargetedExpression(arrayAccess);
290     }
291
292     public <T> void visitCtArrayTypeReference(CtArrayTypeReference<T> reference) {
293         visitCtTypeReference(reference);
294     }
295
296     public <T> void visitCtAssert(CtAssert<T> asserted) {
297         scanCtStatement(asserted);
298     }
299
300     public <T, A extends T> void visitCtAssignment(
301             CtAssignment<T, A> assignement) {
302         scanCtExpression(assignement);
303         scanCtStatement(assignement);
304     }
305
306     public <T> void visitCtBinaryOperator(CtBinaryOperator<T> operator) {
307         scanCtExpression(operator);
308     }
309
310     public <R> void visitCtBlock(CtBlock<R> block) {
311         scanCtStatement(block);
312     }
313
314     public void visitCtBreak(CtBreak breakStatement) {
315         scanCtCFlowBreak(breakStatement);
316     }
317
318     public <E> void visitCtCase(CtCase<E> caseStatement) {
319         scanCtStatement(caseStatement);
320     }
321
322     public void visitCtCatch(CtCatch catchBlock) {
323         scanCtCodeElement(catchBlock);
324     }
325
326     public <T> void visitCtClass(CtClass<T> ctClass) {
327         scanCtType(ctClass);
328     }
329
330     public <T> void visitCtConditional(CtConditional<T> conditional) {
331         scanCtExpression(conditional);
332     }
333
334     public <T> void visitCtConstructor(CtConstructor<T> c) {
335         scanCtExecutable(c);
336     }
337
338     public void visitCtContinue(CtContinue continueStatement) {
339         scanCtCFlowBreak(continueStatement);
340     }
341
342     public void visitCtDo(CtDo doLoop) {
343         scanCtLoop(doLoop);
344     }
345
346     public <T extends Enum JavaDoc> void visitCtEnum(CtEnum<T> ctEnum) {
347         scanCtSimpleType(ctEnum);
348     }
349
350     public <T> void visitCtExecutableReference(
351             CtExecutableReference<T> reference) {
352         scanCtReference(reference);
353         scanCtGenericElementReference(reference);
354     }
355
356     public <T> void visitCtField(CtField<T> f) {
357         scanCtNamedElement(f);
358         scanCtVariable(f);
359     }
360
361     public <T> void visitCtFieldAccess(CtFieldAccess<T> fieldAccess) {
362         scanCtTargetedExpression(fieldAccess);
363         visitCtVariableAccess(fieldAccess);
364     }
365
366     public <T> void visitCtFieldReference(CtFieldReference<T> reference) {
367         scanCtVariableReference(reference);
368     }
369
370     public void visitCtFor(CtFor forLoop) {
371         scanCtLoop(forLoop);
372     }
373
374     public void visitCtForEach(CtForEach foreach) {
375         scanCtLoop(foreach);
376     }
377
378     public void visitCtIf(CtIf ifElement) {
379         scanCtStatement(ifElement);
380     }
381
382     public <T> void visitCtInterface(CtInterface<T> intrface) {
383         scanCtType(intrface);
384     }
385
386     public <T> void visitCtInvocation(CtInvocation<T> invocation) {
387         scanCtTargetedExpression(invocation);
388         scanCtStatement(invocation);
389         scanCtAbstractInvocation(invocation);
390     }
391
392     public <T> void visitCtLiteral(CtLiteral<T> literal) {
393         scanCtExpression(literal);
394     }
395
396     public <T> void visitCtLocalVariable(CtLocalVariable<T> localVariable) {
397         scanCtVariable(localVariable);
398         scanCtStatement(localVariable);
399     }
400
401     public <T> void visitCtLocalVariableReference(
402             CtLocalVariableReference<T> reference) {
403         scanCtVariableReference(reference);
404     }
405
406     public <T> void visitCtMethod(CtMethod<T> m) {
407         scanCtExecutable(m);
408         scanCtTypedElement(m);
409     }
410
411     public <T> void visitCtNewArray(CtNewArray<T> newArray) {
412         scanCtExpression(newArray);
413     }
414
415     public <T> void visitCtNewClass(CtNewClass<T> newClass) {
416         scanCtAbstractInvocation(newClass);
417         scanCtTypedElement(newClass);
418         scanCtTargetedExpression(newClass);
419     }
420
421     public <T, A extends T> void visitCtOperatorAssignement(
422             CtOperatorAssignment<T, A> assignment) {
423         visitCtAssignment(assignment);
424     }
425
426     public void visitCtPackage(CtPackage ctPackage) {
427         scanCtNamedElement(ctPackage);
428     }
429
430     public void visitCtPackageReference(CtPackageReference reference) {
431         scanCtReference(reference);
432     }
433
434     public <T> void visitCtParameter(CtParameter<T> parameter) {
435         scanCtNamedElement(parameter);
436         scanCtVariable(parameter);
437     }
438
439     public <T> void visitCtParameterReference(CtParameterReference<T> reference) {
440         scanCtVariableReference(reference);
441     }
442
443     public <R> void visitCtReturn(CtReturn<R> returnStatement) {
444         scanCtCFlowBreak(returnStatement);
445     }
446
447     public <R> void visitCtStatementList(CtStatementList<R> statements) {
448         scanCtCodeElement(statements);
449     }
450
451     public <E> void visitCtSwitch(CtSwitch<E> switchStatement) {
452         scanCtStatement(switchStatement);
453     }
454
455     public void visitCtSynchronized(CtSynchronized synchro) {
456         scanCtStatement(synchro);
457     }
458
459     public void visitCtThrow(CtThrow throwStatement) {
460         scanCtCFlowBreak(throwStatement);
461     }
462
463     public void visitCtTry(CtTry tryBlock) {
464         scanCtStatement(tryBlock);
465     }
466
467     public void visitCtTypeParameter(CtTypeParameter typeParameter) {
468         scanCtElement(typeParameter);
469     }
470
471     public void visitCtTypeParameterReference(CtTypeParameterReference ref) {
472         visitCtTypeReference(ref);
473     }
474
475     public <T> void visitCtTypeReference(CtTypeReference<T> reference) {
476         scanCtGenericElementReference(reference);
477         scanCtReference(reference);
478     }
479
480     public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) {
481         scanCtExpression(operator);
482     }
483
484     public <T> void visitCtVariableAccess(CtVariableAccess<T> variableAccess) {
485         scanCtExpression(variableAccess);
486     }
487
488     public void visitCtWhile(CtWhile whileLoop) {
489         scanCtLoop(whileLoop);
490     }
491
492 }
493
Popular Tags