001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 *  Unless required by applicable law or agreed to in writing, software
012 *  distributed under the License is distributed on an "AS IS" BASIS,
013 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 *  See the License for the specific language governing permissions and
015 *  limitations under the License.
016 */
017package org.apache.xbean.asm9.original.commons;
018
019import org.objectweb.asm.AnnotationVisitor;
020import org.objectweb.asm.Attribute;
021import org.objectweb.asm.ClassVisitor;
022import org.objectweb.asm.FieldVisitor;
023import org.objectweb.asm.Handle;
024import org.objectweb.asm.Label;
025import org.objectweb.asm.MethodVisitor;
026import org.objectweb.asm.TypePath;
027
028import static org.apache.xbean.asm9.original.commons.AsmConstants.ASM_VERSION;
029
030public class EmptyVisitor extends ClassVisitor {
031    protected final AnnotationVisitor av = new AnnotationVisitor(ASM_VERSION) {
032        @Override
033        public void visit(String name, Object value) {
034            EmptyVisitor.this.visit(name, value);
035        }
036
037        @Override
038        public void visitEnum(String name, String desc, String value) {
039            EmptyVisitor.this.visitEnum(name, desc, value);
040        }
041
042        @Override
043        public AnnotationVisitor visitAnnotation(String name, String desc) {
044            return EmptyVisitor.this.visitAnnotation(name, desc);
045        }
046
047        @Override
048        public AnnotationVisitor visitArray(String name) {
049            return EmptyVisitor.this.visitArray(name);
050        }
051
052        @Override
053        public void visitEnd() {
054            EmptyVisitor.this.visitEnd();
055        }
056    };
057
058    protected final FieldVisitor fv = new FieldVisitor(ASM_VERSION) {
059        @Override
060        public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
061            return EmptyVisitor.this.visitAnnotation(desc, visible);
062        }
063
064        @Override
065        public void visitAttribute(Attribute attribute) {
066            EmptyVisitor.this.visitAttribute(attribute);
067        }
068
069        @Override
070        public void visitEnd() {
071            EmptyVisitor.this.visitEnd();
072        }
073    };
074    protected final MethodVisitor mv = new MethodVisitor(ASM_VERSION) {
075        @Override
076        public AnnotationVisitor visitAnnotationDefault() {
077            return EmptyVisitor.this.visitAnnotationDefault();
078        }
079
080        @Override
081        public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
082            return EmptyVisitor.this.visitAnnotation(desc, visible);
083        }
084
085        @Override
086        public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
087            return EmptyVisitor.this.visitMethodParameterAnnotation(parameter, desc, visible);
088        }
089
090        @Override
091        public void visitAttribute(Attribute attribute) {
092            EmptyVisitor.this.visitAttribute(attribute);
093        }
094
095        @Override
096        public void visitCode() {
097            EmptyVisitor.this.visitCode();
098        }
099
100        @Override
101        public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
102            EmptyVisitor.this.visitFrame(type, nLocal, local, nStack, stack);
103        }
104
105        @Override
106        public void visitInsn(int opcode) {
107            EmptyVisitor.this.visitInsn(opcode);
108        }
109
110        @Override
111        public void visitJumpInsn(int i, Label label) {
112            EmptyVisitor.this.visitJumpInsn(i, label);
113        }
114
115        @Override
116        public void visitLabel(Label label) {
117            EmptyVisitor.this.visitLabel(label);
118        }
119
120        @Override
121        public void visitLdcInsn(Object cst) {
122            EmptyVisitor.this.visitLdcInsn(cst);
123        }
124
125        @Override
126        public void visitIincInsn(int var, int increment) {
127            EmptyVisitor.this.visitIincInsn(var, increment);
128        }
129
130        @Override
131        public void visitTableSwitchInsn(int i, int i2, Label label, Label... labels) {
132            EmptyVisitor.this.visitTableSwitchInsn(i, i2, label, labels);
133        }
134
135        @Override
136        public void visitLookupSwitchInsn(Label label, int[] ints, Label[] labels) {
137            EmptyVisitor.this.visitLookupSwitchInsn(label, ints, labels);
138        }
139
140        @Override
141        public void visitMultiANewArrayInsn(String desc, int dims) {
142            EmptyVisitor.this.visitMultiANewArrayInsn(desc, dims);
143        }
144
145        @Override
146        public void visitTryCatchBlock(Label label, Label label2, Label label3, String s) {
147            EmptyVisitor.this.visitTryCatchBlock(label, label2, label3, s);
148        }
149
150        @Override
151        public void visitLocalVariable(String s, String s2, String s3, Label label, Label label2, int i) {
152            EmptyVisitor.this.visitLocalVariable(s, s2, s3, label, label2, i);
153        }
154
155        @Override
156        public void visitLineNumber(int i, Label label) {
157            EmptyVisitor.this.visitLineNumber(i, label);
158        }
159
160        @Override
161        public void visitMaxs(int maxStack, int maxLocals) {
162            EmptyVisitor.this.visitMaxs(maxStack, maxLocals);
163        }
164
165        @Override
166        public void visitEnd() {
167            EmptyVisitor.this.visitEnd();
168        }
169
170        @Override
171        public void visitIntInsn(int opcode, int operand) {
172            EmptyVisitor.this.visitIntInsn(opcode, operand);
173        }
174
175        @Override
176        public void visitVarInsn(int opcode, int var) {
177            EmptyVisitor.this.visitVarInsn(opcode, var);
178        }
179
180        @Override
181        public void visitTypeInsn(int opcode, String type) {
182            EmptyVisitor.this.visitTypeInsn(opcode, type);
183        }
184
185        @Override
186        public void visitFieldInsn(int opcode, String owner, String name, String desc) {
187            EmptyVisitor.this.visitFieldInsn(opcode, owner, name, desc);
188        }
189
190        @Override
191        public void visitMethodInsn(int opcode, String owner, String name, String desc) {
192            EmptyVisitor.this.visitMethodInsn(opcode, owner, name, desc);
193        }
194
195        @Override
196        public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
197            EmptyVisitor.this.visitMethodInsn(opcode, owner, name, desc);
198        }
199
200        @Override
201        public void visitInvokeDynamicInsn(String s, String s2, Handle handle, Object... objects) {
202            EmptyVisitor.this.visitInvokeDynamicInsn(s, s2, handle, objects);
203        }
204    };
205
206    public EmptyVisitor() {
207        super(ASM_VERSION);
208    }
209
210    protected AnnotationVisitor visitAnnotationDefault() {
211        return av;
212    }
213
214    protected AnnotationVisitor visitArray(String name) {
215        return av;
216    }
217
218    protected AnnotationVisitor visitAnnotation(String name, String desc) {
219        return av;
220    }
221
222    protected void visitEnum(String name, String desc, String value) {
223        // no-op
224    }
225
226    protected void visit(String name, Object value) {
227        // no-op
228    }
229
230    protected void visitVarInsn(int opcode, int var) {
231        // no-op
232    }
233
234    protected void visitTypeInsn(int opcode, String type) {
235        // no-op
236    }
237
238    protected void visitFieldInsn(int opcode, String owner, String name, String desc) {
239        // no-op
240    }
241
242    protected void visitMethodInsn(int opcode, String owner, String name, String desc) {
243        // no-op
244    }
245
246    protected void visitInvokeDynamicInsn(String s, String s2, Handle handle, Object[] objects) {
247        // no-op
248    }
249
250    protected void visitIntInsn(int opcode, int operand) {
251        // no-op
252    }
253
254    protected void visitJumpInsn(int i, Label label) {
255        // no-op
256    }
257
258    protected void visitLabel(Label label) {
259        // no-op
260    }
261
262    protected void visitLdcInsn(Object cst) {
263        // no-op
264    }
265
266    protected void visitIincInsn(int var, int increment) {
267        // no-op
268    }
269
270    protected void visitTableSwitchInsn(int i, int i2, Label label, Label[] labels) {
271        // no-op
272    }
273
274    protected void visitLookupSwitchInsn(Label label, int[] ints, Label[] labels) {
275        // no-op
276    }
277
278    protected void visitMultiANewArrayInsn(String desc, int dims) {
279        // no-op
280    }
281
282    protected void visitTryCatchBlock(Label label, Label label2, Label label3, String s) {
283        // no-op
284    }
285
286    protected void visitLocalVariable(String s, String s2, String s3, Label label, Label label2, int i) {
287        // no-op
288    }
289
290    protected void visitLineNumber(int i, Label label) {
291        // no-op
292    }
293
294    protected void visitMaxs(int maxStack, int maxLocals) {
295        // no-op
296    }
297
298    protected void visitInsn(int opcode) {
299        // no-op
300    }
301
302    protected void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
303        // no-op
304    }
305
306    protected void visitCode() {
307        // no-op
308    }
309
310    protected AnnotationVisitor visitMethodParameterAnnotation(int parameter, String desc, boolean visible) {
311        return av;
312    }
313
314    protected AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
315        return av;
316    }
317
318    @Override
319    public void visit(int version, int access, String name, String signature,
320                      String superName, String[] interfaces) {
321        if (cv != null) {
322            cv.visit(version, access, name, signature, superName, interfaces);
323        }
324    }
325
326    @Override
327    public void visitSource(String source, String debug) {
328        if (cv != null) {
329            cv.visitSource(source, debug);
330        }
331    }
332
333    @Override
334    public void visitOuterClass(String owner, String name, String desc) {
335        if (cv != null) {
336            cv.visitOuterClass(owner, name, desc);
337        }
338    }
339
340    @Override
341    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
342        return av;
343    }
344
345    @Override
346    public void visitAttribute(Attribute attr) {
347        if (cv != null) {
348            cv.visitAttribute(attr);
349        }
350    }
351
352    @Override
353    public void visitInnerClass(String name, String outerName,
354                                String innerName, int access) {
355        if (cv != null) {
356            cv.visitInnerClass(name, outerName, innerName, access);
357        }
358    }
359
360    @Override
361    public FieldVisitor visitField(int access, String name, String desc,
362                                   String signature, Object value) {
363        return fv;
364    }
365
366    @Override
367    public MethodVisitor visitMethod(int access, String name, String desc,
368                                     String signature, String[] exceptions) {
369        return mv;
370    }
371
372    @Override
373    public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
374        return av;
375    }
376
377    @Override
378    public void visitEnd() {
379        if (cv != null) {
380            cv.visitEnd();
381        }
382    }
383
384    public AnnotationVisitor annotationVisitor() {
385        return av;
386    }
387
388    public FieldVisitor fieldVisitor() {
389        return fv;
390    }
391
392    public MethodVisitor methodVisitor() {
393        return mv;
394    }
395}