aboutsummaryrefslogtreecommitdiff
path: root/src/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-11-24 05:38:54 +0100
committerReinier Zwitserloot <reinier@tipit.to>2009-11-24 05:38:54 +0100
commit66d4709855d57ae5703ab15fdf70d6ddce2d677d (patch)
tree9c5aca3914a66425e5e2a2fafcd2fda87e89ae1b /src/lombok
parent45de32ff6ddbe20b8d386f343ef291c57c5fae74 (diff)
downloadlombok-66d4709855d57ae5703ab15fdf70d6ddce2d677d.tar.gz
lombok-66d4709855d57ae5703ab15fdf70d6ddce2d677d.tar.bz2
lombok-66d4709855d57ae5703ab15fdf70d6ddce2d677d.zip
Added more thorough support for detecting we're running as an annotation processor on an unsupported platform, even giving useful suggestions about what you're doing wrong when we detect you're trying to do this on eclipse.
Fixes ticket #53
Diffstat (limited to 'src/lombok')
-rw-r--r--src/lombok/javac/apt/Processor.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/lombok/javac/apt/Processor.java b/src/lombok/javac/apt/Processor.java
index 1ff1ee88..9c851762 100644
--- a/src/lombok/javac/apt/Processor.java
+++ b/src/lombok/javac/apt/Processor.java
@@ -64,26 +64,46 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class Processor extends AbstractProcessor {
+ private ProcessingEnvironment rawProcessingEnv;
private JavacProcessingEnvironment processingEnv;
private HandlerLibrary handlers;
private Trees trees;
+ private String errorToShow;
/** {@inheritDoc} */
@Override public void init(ProcessingEnvironment procEnv) {
super.init(procEnv);
- if (!(procEnv instanceof JavacProcessingEnvironment)) {
- procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly.");
+ this.rawProcessingEnv = procEnv;
+ String className = procEnv.getClass().getName();
+ if (className.startsWith("org.eclipse.jdt.")) {
+ errorToShow = "You should not install lombok.jar as an annotation processor in eclipse. Instead, run lombok.jar as a java application and follow the instructions.";
+ procEnv.getMessager().printMessage(Kind.WARNING, errorToShow);
this.processingEnv = null;
+ } else if (!procEnv.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) {
+ procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so lombok will not work properly.\n" +
+ "Your processor class is: " + className);
+ this.processingEnv = null;
+ this.errorToShow = null;
} else {
this.processingEnv = (JavacProcessingEnvironment) procEnv;
handlers = HandlerLibrary.load(procEnv.getMessager());
trees = Trees.instance(procEnv);
+ this.errorToShow = null;
}
}
/** {@inheritDoc} */
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (processingEnv == null) return false;
+ if (processingEnv == null) {
+ if (errorToShow != null) {
+ Set<? extends Element> rootElements = roundEnv.getRootElements();
+ if (!rootElements.isEmpty()) {
+ rawProcessingEnv.getMessager().printMessage(Kind.WARNING, errorToShow, rootElements.iterator().next());
+ errorToShow = null;
+ }
+ }
+ return false;
+ }
IdentityHashMap<JCCompilationUnit, Void> units = new IdentityHashMap<JCCompilationUnit, Void>();
for (Element element : roundEnv.getRootElements()) {