|
15 | 15 | */ |
16 | 16 | package org.androidannotations.holder; |
17 | 17 |
|
18 | | -import com.sun.codemodel.*; |
19 | | -import org.androidannotations.process.ProcessHolder; |
| 18 | +import static com.sun.codemodel.JExpr.invoke; |
| 19 | +import static com.sun.codemodel.JMod.PRIVATE; |
| 20 | +import static com.sun.codemodel.JMod.PUBLIC; |
| 21 | +import static com.sun.codemodel.JMod.STATIC; |
| 22 | +import static javax.lang.model.element.ElementKind.CONSTRUCTOR; |
| 23 | + |
| 24 | +import java.util.ArrayList; |
| 25 | +import java.util.Collection; |
| 26 | +import java.util.List; |
20 | 27 |
|
21 | 28 | import javax.lang.model.element.Element; |
22 | 29 | import javax.lang.model.element.ExecutableElement; |
23 | 30 | import javax.lang.model.element.TypeElement; |
24 | 31 | import javax.lang.model.element.VariableElement; |
25 | | -import java.util.ArrayList; |
26 | | -import java.util.List; |
27 | 32 |
|
28 | | -import static com.sun.codemodel.JExpr.invoke; |
29 | | -import static com.sun.codemodel.JMod.*; |
30 | | -import static javax.lang.model.element.ElementKind.CONSTRUCTOR; |
| 33 | +import org.androidannotations.process.ProcessHolder; |
| 34 | + |
| 35 | +import com.sun.codemodel.JAnnotationArrayMember; |
| 36 | +import com.sun.codemodel.JAnnotationUse; |
| 37 | +import com.sun.codemodel.JBlock; |
| 38 | +import com.sun.codemodel.JClass; |
| 39 | +import com.sun.codemodel.JExpr; |
| 40 | +import com.sun.codemodel.JFieldVar; |
| 41 | +import com.sun.codemodel.JInvocation; |
| 42 | +import com.sun.codemodel.JMethod; |
| 43 | +import com.sun.codemodel.JType; |
| 44 | +import com.sun.codemodel.JVar; |
31 | 45 |
|
32 | 46 | public class EViewHolder extends EComponentWithViewSupportHolder { |
33 | 47 |
|
@@ -56,8 +70,25 @@ public EViewHolder(ProcessHolder processHolder, TypeElement annotatedElement) th |
56 | 70 | } |
57 | 71 |
|
58 | 72 | private void addSuppressWarning() { |
59 | | - generatedClass.annotate(SuppressWarnings.class).param("value", "unused"); |
60 | 73 | generatedClass.javadoc().append(SUPPRESS_WARNING_COMMENT); |
| 74 | + |
| 75 | + Collection<JAnnotationUse> annotations = getGeneratedClass().annotations(); |
| 76 | + for (JAnnotationUse annotationUse : annotations) { |
| 77 | + if (annotationUse.getAnnotationClass().fullName().equals(SuppressWarnings.class.getCanonicalName())) { |
| 78 | + JAnnotationArrayMember value = (JAnnotationArrayMember) annotationUse.getAnnotationMembers().get("value"); |
| 79 | + |
| 80 | + for (String v : getAnnotatedElement().getAnnotation(SuppressWarnings.class).value()) { |
| 81 | + if (v.equals("unused")) { |
| 82 | + return; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + value.param("unused"); |
| 87 | + return; |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + generatedClass.annotate(SuppressWarnings.class).param("value", "unused"); |
61 | 92 | } |
62 | 93 |
|
63 | 94 | private void createConstructorAndBuilder() { |
|
0 commit comments