diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-23 03:32:11 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-23 03:32:11 +0100 |
commit | 55bed99c90553d91b20c289629b62030bb286610 (patch) | |
tree | 8a170cc430a36deb65149e8b1c927b2857404729 /src/core/lombok/javac/apt | |
parent | f57e23bebb4c50a6a74014a245f14dba6aa24923 (diff) | |
download | lombok-55bed99c90553d91b20c289629b62030bb286610.tar.gz lombok-55bed99c90553d91b20c289629b62030bb286610.tar.bz2 lombok-55bed99c90553d91b20c289629b62030bb286610.zip |
generalized the annotation processor that lombok.jar represents into a main class that farms out the work to a specific implementation depending on environment; previously lombok.jar's annotation processor was javac specific.
Diffstat (limited to 'src/core/lombok/javac/apt')
-rw-r--r-- | src/core/lombok/javac/apt/Processor.java | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java index b779a680..31cedf03 100644 --- a/src/core/lombok/javac/apt/Processor.java +++ b/src/core/lombok/javac/apt/Processor.java @@ -32,7 +32,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; -import javax.tools.Diagnostic.Kind; import lombok.javac.JavacTransformer; @@ -55,47 +54,20 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; @SupportedAnnotationTypes("*") @SupportedSourceVersion(SourceVersion.RELEASE_6) public class Processor extends AbstractProcessor { - private ProcessingEnvironment rawProcessingEnv; private JavacProcessingEnvironment processingEnv; private JavacTransformer transformer; private Trees trees; - private String errorToShow; /** {@inheritDoc} */ @Override public void init(ProcessingEnvironment procEnv) { super.init(procEnv); - 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; - transformer = new JavacTransformer(procEnv.getMessager()); - trees = Trees.instance(procEnv); - this.errorToShow = null; - } + this.processingEnv = (JavacProcessingEnvironment) procEnv; + transformer = new JavacTransformer(procEnv.getMessager()); + trees = Trees.instance(procEnv); } /** {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { - 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()) { JCCompilationUnit unit = toUnit(element); |