From b0072a17eba21cdc6f8ba51693bb39d1c9aba319 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 29 Nov 2010 22:43:44 +0100 Subject: lombok.val import now gets removed. Only adding lombok.val flags the compilation unit as changed. --- src/core/lombok/javac/DeleteLombokAnnotations.java | 35 ---------------- src/core/lombok/javac/JavacNode.java | 7 ++-- src/core/lombok/javac/JavacTransformer.java | 10 +++-- src/core/lombok/javac/LombokOptions.java | 47 ++++++++++++++++++++++ src/core/lombok/javac/TrackChangedAsts.java | 10 ----- src/delombok/lombok/delombok/Delombok.java | 16 +++----- 6 files changed, 62 insertions(+), 63 deletions(-) delete mode 100644 src/core/lombok/javac/DeleteLombokAnnotations.java create mode 100644 src/core/lombok/javac/LombokOptions.java delete mode 100644 src/core/lombok/javac/TrackChangedAsts.java (limited to 'src') diff --git a/src/core/lombok/javac/DeleteLombokAnnotations.java b/src/core/lombok/javac/DeleteLombokAnnotations.java deleted file mode 100644 index 425c4365..00000000 --- a/src/core/lombok/javac/DeleteLombokAnnotations.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2010 Reinier Zwitserloot and Roel Spilker. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.javac; - -/** Used as marker in javac's Context object when delombok is running to signal that all lombok annotations should be deleted as they are processed. */ -public class DeleteLombokAnnotations { - private final boolean deleteLombokAnnotations; - - public DeleteLombokAnnotations(boolean deleteLombokAnnotations) { - this.deleteLombokAnnotations = deleteLombokAnnotations; - } - - public boolean isDeleteLombokAnnotations() { - return deleteLombokAnnotations; - } -} diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java index 7dd49644..83eb9088 100644 --- a/src/core/lombok/javac/JavacNode.java +++ b/src/core/lombok/javac/JavacNode.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,6 +39,7 @@ import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; /** @@ -197,8 +198,8 @@ public class JavacNode extends lombok.core.LombokNode changed = new HashSet(); + + public static LombokOptions replaceWithDelombokOptions(Context context) { + Options options = Options.instance(context); + context.put(optionsKey, (Options)null); + LombokOptions result = new LombokOptions(context); + result.putAll(options); + return result; + } + + private LombokOptions(Context context) { + super(context); + } +} diff --git a/src/core/lombok/javac/TrackChangedAsts.java b/src/core/lombok/javac/TrackChangedAsts.java deleted file mode 100644 index fa6c0f18..00000000 --- a/src/core/lombok/javac/TrackChangedAsts.java +++ /dev/null @@ -1,10 +0,0 @@ -package lombok.javac; - -import java.util.HashSet; -import java.util.Set; - -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; - -public class TrackChangedAsts { - public final Set changed = new HashSet(); -} \ No newline at end of file diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index f3069c25..0bc60877 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -44,14 +44,12 @@ import java.util.Map; import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; -import lombok.javac.DeleteLombokAnnotations; -import lombok.javac.TrackChangedAsts; +import lombok.javac.LombokOptions; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.main.OptionName; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Options; import com.zwitserloot.cmdreader.CmdReader; import com.zwitserloot.cmdreader.Description; import com.zwitserloot.cmdreader.Excludes; @@ -70,7 +68,7 @@ public class Delombok { } public Delombok() { - context.put(DeleteLombokAnnotations.class, new DeleteLombokAnnotations(true)); +// context.put(DeleteLombokAnnotations.class, new DeleteLombokAnnotations(true)); } private PrintStream feedback = System.err; @@ -349,7 +347,7 @@ public class Delombok { } public boolean delombok() throws IOException { - Options options = Options.instance(context); + LombokOptions options = LombokOptions.replaceWithDelombokOptions(context); options.put(OptionName.ENCODING, charset.name()); if (classpath != null) options.put(OptionName.CLASSPATH, classpath); if (sourcepath != null) options.put(OptionName.SOURCEPATH, sourcepath); @@ -383,13 +381,9 @@ public class Delombok { return false; } - TrackChangedAsts tca = new TrackChangedAsts(); - - context.put(TrackChangedAsts.class, tca); - JavaCompiler delegate = compiler.processAnnotations(compiler.enterTrees(toJavacList(roots))); for (JCCompilationUnit unit : roots) { - DelombokResult result = new DelombokResult(commentsMap.get(unit).comments.toList(), unit, force || tca.changed.contains(unit)); + DelombokResult result = new DelombokResult(commentsMap.get(unit).comments.toList(), unit, force || options.changed.contains(unit)); if (verbose) feedback.printf("File: %s [%s]\n", unit.sourcefile.getName(), result.isChanged() ? "delomboked" : "unchanged"); Writer rawWriter; if (presetWriter != null) rawWriter = presetWriter; -- cgit