1 | |
package org.apache.maven.tools.plugin.annotations.scanner.visitors; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.tools.plugin.annotations.scanner.MojoAnnotationsScanner; |
23 | |
import org.codehaus.plexus.logging.Logger; |
24 | |
import org.objectweb.asm.AnnotationVisitor; |
25 | |
import org.objectweb.asm.Attribute; |
26 | |
import org.objectweb.asm.FieldVisitor; |
27 | |
import org.objectweb.asm.Type; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public class MojoFieldVisitor |
34 | |
implements FieldVisitor |
35 | |
{ |
36 | |
private Logger logger; |
37 | |
|
38 | |
private String fieldName; |
39 | |
|
40 | |
private MojoAnnotationVisitor mojoAnnotationVisitor; |
41 | |
|
42 | |
private String className; |
43 | |
|
44 | |
MojoFieldVisitor( Logger logger, String fieldName, String className ) |
45 | 4 | { |
46 | 4 | this.logger = logger; |
47 | 4 | this.fieldName = fieldName; |
48 | 4 | this.className = className; |
49 | 4 | } |
50 | |
|
51 | |
public MojoAnnotationVisitor getMojoAnnotationVisitor() |
52 | |
{ |
53 | 16 | return mojoAnnotationVisitor; |
54 | |
} |
55 | |
|
56 | |
public String getFieldName() |
57 | |
{ |
58 | 4 | return fieldName; |
59 | |
} |
60 | |
|
61 | |
public AnnotationVisitor visitAnnotation( String desc, boolean visible ) |
62 | |
{ |
63 | 4 | logger.debug( "MojoFieldVisitor#visitAnnotation:" + desc ); |
64 | 4 | String annotationClassName = Type.getType( desc ).getClassName(); |
65 | 4 | if ( !MojoAnnotationsScanner.FIELD_LEVEL_ANNOTATIONS.contains( annotationClassName ) ) |
66 | |
{ |
67 | 0 | return null; |
68 | |
} |
69 | 4 | mojoAnnotationVisitor = new MojoAnnotationVisitor( logger, annotationClassName ); |
70 | 4 | return mojoAnnotationVisitor; |
71 | |
} |
72 | |
|
73 | |
public void visitAttribute( Attribute attribute ) |
74 | |
{ |
75 | |
|
76 | 0 | } |
77 | |
|
78 | |
public void visitEnd() |
79 | |
{ |
80 | |
|
81 | 4 | } |
82 | |
|
83 | |
public String getClassName() |
84 | |
{ |
85 | 3 | return className; |
86 | |
} |
87 | |
|
88 | |
public void setClassName( String className ) |
89 | |
{ |
90 | 0 | this.className = className; |
91 | 0 | } |
92 | |
} |