aboutsummaryrefslogtreecommitdiffstats
path: root/tests/multiIncremental
diff options
context:
space:
mode:
authorAndy Clement <aclement@gopivotal.com>2014-08-20 08:00:10 -0700
committerAndy Clement <aclement@gopivotal.com>2014-08-20 08:00:10 -0700
commit1e2744d37cd2ac3438f8f1e6b8aae7c4a6c6b8d6 (patch)
tree5516c617e821bc56fb2e77a64553fcfc69e3794c /tests/multiIncremental
parent1da68158a802f47b42194dcb040be47526703ed6 (diff)
downloadaspectj-1e2744d37cd2ac3438f8f1e6b8aae7c4a6c6b8d6.tar.gz
aspectj-1e2744d37cd2ac3438f8f1e6b8aae7c4a6c6b8d6.zip
enabling AJDT to use annotation processors
Diffstat (limited to 'tests/multiIncremental')
-rw-r--r--tests/multiIncremental/ProcessorConsumer1/base/src/Code.java26
-rw-r--r--tests/multiIncremental/ProcessorConsumer2/base/src/Code.java26
-rw-r--r--tests/multiIncremental/ProcessorProject/base/src/DemoProcessor.java47
-rw-r--r--tests/multiIncremental/ProcessorProject2/base/src/DemoProcessor.java47
-rw-r--r--tests/multiIncremental/ProcessorProject2/base/src/META-INF/services/javax.annotation.processing.Processor1
-rw-r--r--tests/multiIncremental/ProcessorProject2/base/src/proc.jarbin0 -> 1289 bytes
-rw-r--r--tests/multiIncremental/ProcessorProject3/base/src/DemoProcessor2.java47
-rw-r--r--tests/multiIncremental/ProcessorProject3/base/src/META-INF/services/javax.annotation.processing.Processor1
8 files changed, 195 insertions, 0 deletions
diff --git a/tests/multiIncremental/ProcessorConsumer1/base/src/Code.java b/tests/multiIncremental/ProcessorConsumer1/base/src/Code.java
new file mode 100644
index 000000000..72efafcfa
--- /dev/null
+++ b/tests/multiIncremental/ProcessorConsumer1/base/src/Code.java
@@ -0,0 +1,26 @@
+public class Code {
+ public static void main(String []argv) {
+ new Code().run();
+ }
+
+ public static void runner() {
+ new Code().run();
+ }
+
+ public void run() {
+ aaa();
+ bbb();
+ ccc();
+ ddd();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void aaa() {}
+
+ public void bbb() {}
+
+ @SuppressWarnings("rawtypes")
+ public void ccc() {}
+
+ public void ddd() {}
+}
diff --git a/tests/multiIncremental/ProcessorConsumer2/base/src/Code.java b/tests/multiIncremental/ProcessorConsumer2/base/src/Code.java
new file mode 100644
index 000000000..72efafcfa
--- /dev/null
+++ b/tests/multiIncremental/ProcessorConsumer2/base/src/Code.java
@@ -0,0 +1,26 @@
+public class Code {
+ public static void main(String []argv) {
+ new Code().run();
+ }
+
+ public static void runner() {
+ new Code().run();
+ }
+
+ public void run() {
+ aaa();
+ bbb();
+ ccc();
+ ddd();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void aaa() {}
+
+ public void bbb() {}
+
+ @SuppressWarnings("rawtypes")
+ public void ccc() {}
+
+ public void ddd() {}
+}
diff --git a/tests/multiIncremental/ProcessorProject/base/src/DemoProcessor.java b/tests/multiIncremental/ProcessorProject/base/src/DemoProcessor.java
new file mode 100644
index 000000000..05ff20107
--- /dev/null
+++ b/tests/multiIncremental/ProcessorProject/base/src/DemoProcessor.java
@@ -0,0 +1,47 @@
+import java.io.*;
+import javax.tools.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+@SupportedAnnotationTypes(value= {"*"})
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class DemoProcessor extends AbstractProcessor {
+
+ private Filer filer;
+
+ @Override
+ public void init(ProcessingEnvironment env) {
+ filer = env.getFiler();
+ }
+
+ @Override
+ public boolean process(Set elements, RoundEnvironment env) {
+System.out.println("Processor running");
+ // Discover anything marked with @SuppressWarnings
+ for (Element element: env.getElementsAnnotatedWith(SuppressWarnings.class)) {
+ if (element.getKind() == ElementKind.METHOD) {
+ // For any methods we find, create an aspect:
+ String methodName = element.getSimpleName().toString();
+ String aspectText =
+ "public aspect Advise_"+methodName+" {\n"+
+ " before(): execution(* "+methodName+"(..)) {\n"+
+ " System.out.println(\""+methodName+" running\");\n"+
+ " }\n"+
+ "}\n";
+ try {
+ JavaFileObject file = filer.createSourceFile("Advise_"+methodName, element);
+ file.openWriter().append(aspectText).close();
+ System.out.println("Generated aspect to advise "+element.getSimpleName());
+ } catch (IOException ioe) {
+ // already creates message can appear if processor runs more than once
+ if (!ioe.getMessage().contains("already created")) {
+ ioe.printStackTrace();
+ }
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/tests/multiIncremental/ProcessorProject2/base/src/DemoProcessor.java b/tests/multiIncremental/ProcessorProject2/base/src/DemoProcessor.java
new file mode 100644
index 000000000..05ff20107
--- /dev/null
+++ b/tests/multiIncremental/ProcessorProject2/base/src/DemoProcessor.java
@@ -0,0 +1,47 @@
+import java.io.*;
+import javax.tools.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+@SupportedAnnotationTypes(value= {"*"})
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class DemoProcessor extends AbstractProcessor {
+
+ private Filer filer;
+
+ @Override
+ public void init(ProcessingEnvironment env) {
+ filer = env.getFiler();
+ }
+
+ @Override
+ public boolean process(Set elements, RoundEnvironment env) {
+System.out.println("Processor running");
+ // Discover anything marked with @SuppressWarnings
+ for (Element element: env.getElementsAnnotatedWith(SuppressWarnings.class)) {
+ if (element.getKind() == ElementKind.METHOD) {
+ // For any methods we find, create an aspect:
+ String methodName = element.getSimpleName().toString();
+ String aspectText =
+ "public aspect Advise_"+methodName+" {\n"+
+ " before(): execution(* "+methodName+"(..)) {\n"+
+ " System.out.println(\""+methodName+" running\");\n"+
+ " }\n"+
+ "}\n";
+ try {
+ JavaFileObject file = filer.createSourceFile("Advise_"+methodName, element);
+ file.openWriter().append(aspectText).close();
+ System.out.println("Generated aspect to advise "+element.getSimpleName());
+ } catch (IOException ioe) {
+ // already creates message can appear if processor runs more than once
+ if (!ioe.getMessage().contains("already created")) {
+ ioe.printStackTrace();
+ }
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/tests/multiIncremental/ProcessorProject2/base/src/META-INF/services/javax.annotation.processing.Processor b/tests/multiIncremental/ProcessorProject2/base/src/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 000000000..3c594a8be
--- /dev/null
+++ b/tests/multiIncremental/ProcessorProject2/base/src/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+DemoProcessor
diff --git a/tests/multiIncremental/ProcessorProject2/base/src/proc.jar b/tests/multiIncremental/ProcessorProject2/base/src/proc.jar
new file mode 100644
index 000000000..be2dd1e85
--- /dev/null
+++ b/tests/multiIncremental/ProcessorProject2/base/src/proc.jar
Binary files differ
diff --git a/tests/multiIncremental/ProcessorProject3/base/src/DemoProcessor2.java b/tests/multiIncremental/ProcessorProject3/base/src/DemoProcessor2.java
new file mode 100644
index 000000000..e55e665bc
--- /dev/null
+++ b/tests/multiIncremental/ProcessorProject3/base/src/DemoProcessor2.java
@@ -0,0 +1,47 @@
+import java.io.*;
+import javax.tools.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+@SupportedAnnotationTypes(value= {"java.lang.SuppressWarnings"})
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class DemoProcessor2 extends AbstractProcessor {
+
+ private Filer filer;
+
+ @Override
+ public void init(ProcessingEnvironment env) {
+ filer = env.getFiler();
+ }
+
+ @Override
+ public boolean process(Set elements, RoundEnvironment env) {
+System.out.println("Processor (around) running");
+ // Discover anything marked with @SuppressWarnings
+ for (Element element: env.getElementsAnnotatedWith(SuppressWarnings.class)) {
+ if (element.getKind() == ElementKind.METHOD) {
+ // For any methods we find, create an aspect:
+ String methodName = element.getSimpleName().toString();
+ String aspectText =
+ "public aspect AroundAdvise_"+methodName+" {\n"+
+ " void around(): execution(* "+methodName+"(..)) {\n"+
+ " System.out.println(\"Around advice on "+methodName+" running\");\n"+
+ " }\n"+
+ "}\n";
+ try {
+ JavaFileObject file = filer.createSourceFile("AroundAdvise_"+methodName, element);
+ file.openWriter().append(aspectText).close();
+ System.out.println("Generated aspect with around advice to advise "+element.getSimpleName());
+ } catch (IOException ioe) {
+ // already creates message can appear if processor runs more than once
+ if (!ioe.getMessage().contains("already created")) {
+ ioe.printStackTrace();
+ }
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/tests/multiIncremental/ProcessorProject3/base/src/META-INF/services/javax.annotation.processing.Processor b/tests/multiIncremental/ProcessorProject3/base/src/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 000000000..62e145eb6
--- /dev/null
+++ b/tests/multiIncremental/ProcessorProject3/base/src/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+DemoProcessor2