Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Harley2007-03-13 23:45:22 +0000
committerWalter Harley2007-03-13 23:45:22 +0000
commit20a3b07578a2ebec2d9a0569764e78af37761eaf (patch)
tree7a6814dda14a85e03de27579f0ecbe459057815e
parent2c9dd93e9c18c0ff087f67042ebd4bb1ae99b3f1 (diff)
downloadeclipse.jdt.core-20a3b07578a2ebec2d9a0569764e78af37761eaf.tar.gz
eclipse.jdt.core-20a3b07578a2ebec2d9a0569764e78af37761eaf.tar.xz
eclipse.jdt.core-20a3b07578a2ebec2d9a0569764e78af37761eaf.zip
Processor and annotation to be used for discovering unexpected reconciles, like the one that Quick Outline does.
-rw-r--r--org.eclipse.jdt.apt.tests/plugin.xml1
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java20
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java57
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java38
4 files changed, 116 insertions, 0 deletions
diff --git a/org.eclipse.jdt.apt.tests/plugin.xml b/org.eclipse.jdt.apt.tests/plugin.xml
index a834b1682a..707a8c8d56 100644
--- a/org.eclipse.jdt.apt.tests/plugin.xml
+++ b/org.eclipse.jdt.apt.tests/plugin.xml
@@ -69,6 +69,7 @@
class="org.eclipse.jdt.apt.tests.annotations.exceptionhandling.ExceptionHandlingProcessorFactory">
</factory>
<factory class="org.eclipse.jdt.apt.tests.annotations.generic.GenericFactory"/>
+ <factory class="org.eclipse.jdt.apt.tests.annotations.pause.PauseAnnotationProcessorFactory"/>
</factories>
</extension>
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java
new file mode 100644
index 0000000000..0d9406f39c
--- /dev/null
+++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/Pause.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * wharley@bea.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.apt.tests.annotations.pause;
+
+/**
+ * Processing this annotation causes a delay proportional to the
+ * value specified.
+ */
+public @interface Pause {
+ int value() default 500;
+}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java
new file mode 100644
index 0000000000..335385b7c5
--- /dev/null
+++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessor.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * wharley@bea.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.apt.tests.annotations.pause;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.eclipse.jdt.apt.tests.annotations.BaseProcessor;
+
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.Declaration;
+
+/**
+ * Used to test performance in the IDE. Processing @Pause
+ * causes the processor to pause for a defined interval.
+ */
+public class PauseAnnotationProcessor extends BaseProcessor {
+
+ private final AnnotationTypeDeclaration _annotationDecl;
+
+ public PauseAnnotationProcessor(
+ Set<AnnotationTypeDeclaration> decls, AnnotationProcessorEnvironment env) {
+ super(env);
+ assert decls.size() == 1;
+ _annotationDecl = decls.iterator().next();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.mirror.apt.AnnotationProcessor#process()
+ */
+ public void process() {
+ String phase = _env.getOptions().get("phase");
+ Collection<Declaration> annotatedDecls = _env.getDeclarationsAnnotatedWith(_annotationDecl);
+ for (Declaration decl : annotatedDecls) {
+ Pause a = decl.getAnnotation(Pause.class);
+ int pause = a.value();
+ System.out.println(phase + " pausing for " + pause + " to process " + decl.getSimpleName() + "...");
+ // busy sleep
+ long end = System.currentTimeMillis() + pause;
+ while (System.currentTimeMillis() < end)
+ for (int i = 0; i < 100000; ++i)
+ ;
+ System.out.println(phase + " finished pausing");
+ }
+ }
+
+}
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java
new file mode 100644
index 0000000000..4d264f5895
--- /dev/null
+++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/annotations/pause/PauseAnnotationProcessorFactory.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 BEA Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * wharley@bea.com - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.apt.tests.annotations.pause;
+
+import java.util.Set;
+
+import org.eclipse.jdt.apt.tests.annotations.BaseFactory;
+
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+
+public class PauseAnnotationProcessorFactory extends BaseFactory {
+
+ private final static String annotationName = "org.eclipse.jdt.apt.tests.annotations.pause.Pause";
+ public PauseAnnotationProcessorFactory() {
+ super(annotationName);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.mirror.apt.AnnotationProcessorFactory#getProcessorFor(java.util.Set, com.sun.mirror.apt.AnnotationProcessorEnvironment)
+ */
+ public AnnotationProcessor getProcessorFor(
+ Set<AnnotationTypeDeclaration> decls,
+ AnnotationProcessorEnvironment env) {
+ return new PauseAnnotationProcessor(decls, env);
+ }
+
+}

Back to the top