From f60422a2c923674af783b28a1a8d357b4c46d789 Mon Sep 17 00:00:00 2001 From: Henry Coles Date: Fri, 12 May 2023 12:47:04 +0100 Subject: [PATCH] allow removal of class annotations --- pitest-maven-verification/pom.xml | 2 +- .../mutationtest/engine/gregor/MethodMutatorFactory.java | 4 ++++ .../mutationtest/engine/gregor/MutatingClassVisitor.java | 7 ++++++- pom.xml | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pitest-maven-verification/pom.xml b/pitest-maven-verification/pom.xml index f45948185..cb6e25969 100644 --- a/pitest-maven-verification/pom.xml +++ b/pitest-maven-verification/pom.xml @@ -106,7 +106,7 @@ org.pitest pitest-entry - 1.0.0-SNAPSHOT + ${project.version} test-jar test diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java index d374b1753..3ca0d07ec 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MethodMutatorFactory.java @@ -50,6 +50,10 @@ default AnnotationVisitor createForAnnotation(NoMethodContext context, Annotatio return null; } + default boolean skipAnnotation(NoMethodContext nonMethodContext, AnnotationInfo annotationInfo) { + return false; + } + default FieldVisitor createForField(NoMethodContext context, FieldInfo fieldInfo, FieldVisitor fieldVisitor) { return null; } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java index 2dc2a2661..749cedb84 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java @@ -60,8 +60,13 @@ public void visitSource(final String source, final String debug) { @Override public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) { - AnnotationVisitor next = super.visitAnnotation(descriptor, visible); AnnotationInfo annotationInfo = new AnnotationInfo(descriptor, visible); + for (final MethodMutatorFactory each : this.mutators) { + if (each.skipAnnotation(this.nonMethodContext, annotationInfo)) { + return null; + } + } + AnnotationVisitor next = super.visitAnnotation(descriptor, visible); for (final MethodMutatorFactory each : this.mutators) { AnnotationVisitor fv = each.createForAnnotation(this.nonMethodContext, annotationInfo, next); if (fv != null) { diff --git a/pom.xml b/pom.xml index fcab202a4..bef644939 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ are used for few artifacts --> - 1.0.0-SNAPSHOT + dev-SNAPSHOT UTF-8 UTF-8