aboutsummaryrefslogtreecommitdiffstats
path: root/tests/multiIncremental/ProcessorProject3
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/ProcessorProject3
parent1da68158a802f47b42194dcb040be47526703ed6 (diff)
downloadaspectj-1e2744d37cd2ac3438f8f1e6b8aae7c4a6c6b8d6.tar.gz
aspectj-1e2744d37cd2ac3438f8f1e6b8aae7c4a6c6b8d6.zip
enabling AJDT to use annotation processors
Diffstat (limited to 'tests/multiIncremental/ProcessorProject3')
-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
2 files changed, 48 insertions, 0 deletions
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