diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-14 22:52:29 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-14 22:52:29 +0100 |
commit | ae4864ebc3974b17a512849e7018556c4a3d1935 (patch) | |
tree | df83b317449f387493214770602fe4bba6f5ce64 | |
parent | 20ac40f20110aa363d2bdf4cc1a1407d2c84135a (diff) | |
download | lombok-ae4864ebc3974b17a512849e7018556c4a3d1935.tar.gz lombok-ae4864ebc3974b17a512849e7018556c4a3d1935.tar.bz2 lombok-ae4864ebc3974b17a512849e7018556c4a3d1935.zip |
[#626] introduction of formatting options triggered a longer standing bug about wonky timing on replacing Options with LombokOptions, causing javac to complain about not recognizing i.e. a Getter annotation when using it more than once in a file.
-rw-r--r-- | src/core/lombok/javac/LombokOptions.java | 15 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 1 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/core/lombok/javac/LombokOptions.java b/src/core/lombok/javac/LombokOptions.java index 60d0ce5e..034cbafd 100644 --- a/src/core/lombok/javac/LombokOptions.java +++ b/src/core/lombok/javac/LombokOptions.java @@ -25,13 +25,14 @@ import java.util.HashSet; import java.util.Set; import lombok.delombok.FormatPreferences; +import lombok.delombok.LombokOptionsFactory; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Options; public abstract class LombokOptions extends Options { - private boolean deleteLombokAnnotations = true; + private boolean deleteLombokAnnotations = false; private final Set<JCCompilationUnit> changed = new HashSet<JCCompilationUnit>(); private FormatPreferences formatPreferences = new FormatPreferences(null); @@ -48,13 +49,13 @@ public abstract class LombokOptions extends Options { } public static void markChanged(Context context, JCCompilationUnit ast) { - Options options = context.get(Options.optionsKey); - if (options instanceof LombokOptions) ((LombokOptions) options).changed.add(ast); + LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); + options.changed.add(ast); } public static boolean shouldDeleteLombokAnnotations(Context context) { - Options options = context.get(Options.optionsKey); - return (options instanceof LombokOptions) && ((LombokOptions) options).deleteLombokAnnotations; + LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); + return options.deleteLombokAnnotations; } protected LombokOptions(Context context) { @@ -62,4 +63,8 @@ public abstract class LombokOptions extends Options { } public abstract void putJavacOption(String optionName, String value); + + public void deleteLombokAnnotations() { + this.deleteLombokAnnotations = true; + } } diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 9cb78a82..f64e36a1 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -467,6 +467,7 @@ public class Delombok { public boolean delombok() throws IOException { LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); + options.deleteLombokAnnotations(); options.putJavacOption("ENCODING", charset.name()); if (classpath != null) options.putJavacOption("CLASSPATH", classpath); if (sourcepath != null) options.putJavacOption("SOURCEPATH", sourcepath); |