Permalink
Browse files

add method annotations to MethodInfo

  • Loading branch information...
1 parent b9497bc commit 590684a1e0789a84d74daf06a65921c73c540a40 @mebigfatguy mebigfatguy committed Oct 21, 2011
@@ -17,13 +17,17 @@
*/
package com.mebigfatguy.deadmethods;
+import java.util.HashSet;
+import java.util.Set;
+
import org.objectweb.asm.Opcodes;
public class MethodInfo {
private final String methodName;
private final String methodSignature;
private final int methodAccess;
+ private Set<String> annotations;
private boolean isTest;
public MethodInfo(String name, String signature, int access) {
@@ -56,6 +60,17 @@ public boolean isTest() {
public void setTest(boolean test) {
isTest = test;
}
+
+ public void addAnnotation(String annotation) {
+ if (annotations == null) {
+ annotations = new HashSet<String>();
+ }
+ annotations.add(annotation);
+ }
+
+ public boolean hasAnnotation(String annotation) {
+ return (annotations != null) && annotations.contains(annotation);
+ }
@Override
public int hashCode() {
@@ -37,6 +37,9 @@ public AnnotationVisitor visitAnnotation(final String desc, final boolean visibl
|| "Lorg/junit/After;".equals(desc)) {
methodInfo.setTest(true);
}
+
+ String annotationName = desc.substring(1, desc.length() - 1).replaceAll("/", ".");
+ methodInfo.addAnnotation(annotationName);
return null;
}

0 comments on commit 590684a

Please sign in to comment.