]> source.dussan.org Git - aspectj.git/commitdiff
annotation removal tests
authoraclement <aclement>
Thu, 25 Nov 2010 21:45:54 +0000 (21:45 +0000)
committeraclement <aclement>
Thu, 25 Nov 2010 21:45:54 +0000 (21:45 +0000)
tests/multiIncremental/annoRemoval/base/a/Code.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java

diff --git a/tests/multiIncremental/annoRemoval/base/a/Code.java b/tests/multiIncremental/annoRemoval/base/a/Code.java
new file mode 100644 (file)
index 0000000..f776fac
--- /dev/null
@@ -0,0 +1,18 @@
+package a;
+import java.lang.annotation.*;
+
+aspect Remover{
+  declare @field: int Code.i: -@Anno;
+  declare @field: int Code.j: @Anno;
+}
+
+public class Code {
+
+  @Anno
+  public int i;
+
+  public int j;
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Anno {}
index 12dec55e0873036149083a84ddfa5e13681a7f7a..5e33fa63cce20cce23c2589b6a869e59500f43ce 100644 (file)
@@ -82,6 +82,27 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental
                assertContains("B.java:4:0::0 Unhandled exception type IOException", getErrorMessages(p).get(0));
        }
 
+       public void testDeclareFieldMinus() throws Exception {
+               String p = "annoRemoval";
+               initialiseProject(p);
+               build(p);
+               checkWasFullBuild();
+               AspectJElementHierarchy model = (AspectJElementHierarchy) getModelFor(p).getHierarchy();
+               IProgramElement ipe = null;
+               ipe = model.findElementForHandleOrCreate("=annoRemoval<a{Code.java'Remover`declare \\@field", false);
+               System.out.println(ipe);
+               assertTrue(ipe.isAnnotationRemover());
+               String[] annos = ipe.getRemovedAnnotationTypes();
+               assertEquals(1, annos.length);
+               assertEquals("a.Anno", annos[0]);
+               assertNull(ipe.getAnnotationType());
+               ipe = model.findElementForHandleOrCreate("=annoRemoval<a{Code.java'Remover`declare \\@field!2", false);
+               System.out.println(ipe);
+               assertFalse(ipe.isAnnotationRemover());
+               assertEquals("a.Anno", ipe.getAnnotationType());
+               assertNull(ipe.getRemovedAnnotationTypes());
+       }
+
        /**
         * Build a pair of files, then change the throws clause in the first one (change the type of the thrown exception). The second
         * file should now have a 'unhandled exception' error on it.