diff options
Diffstat (limited to 'src/delombok')
-rw-r--r-- | src/delombok/lombok/delombok/CommentPreservingParser.java | 10 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/DeleteLombokAnnotations.java | 35 | ||||
-rw-r--r-- | src/delombok/lombok/delombok/Delombok.java | 7 |
3 files changed, 49 insertions, 3 deletions
diff --git a/src/delombok/lombok/delombok/CommentPreservingParser.java b/src/delombok/lombok/delombok/CommentPreservingParser.java index 186d70b0..8536075d 100644 --- a/src/delombok/lombok/delombok/CommentPreservingParser.java +++ b/src/delombok/lombok/delombok/CommentPreservingParser.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-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 @@ -44,6 +44,7 @@ import com.sun.tools.javac.util.Options; public class CommentPreservingParser { private final String encoding; + private boolean deleteLombokAnnotations = false; public CommentPreservingParser() { this("utf-8"); @@ -53,6 +54,10 @@ public class CommentPreservingParser { this.encoding = encoding; } + public void setDeleteLombokAnnotations(boolean deleteLombokAnnotations) { + this.deleteLombokAnnotations = deleteLombokAnnotations; + } + public ParseResult parse(JavaFileObject source, boolean forceProcessing) throws IOException { return doParse(source, forceProcessing); } @@ -78,7 +83,8 @@ public class CommentPreservingParser { Comments comments = new Comments(); context.put(Comments.class, comments); - + if (deleteLombokAnnotations) context.put(DeleteLombokAnnotations.class, new DeleteLombokAnnotations(true)); + comments.comments = List.nil(); JCCompilationUnit cu; diff --git a/src/delombok/lombok/delombok/DeleteLombokAnnotations.java b/src/delombok/lombok/delombok/DeleteLombokAnnotations.java new file mode 100644 index 00000000..335cf6e9 --- /dev/null +++ b/src/delombok/lombok/delombok/DeleteLombokAnnotations.java @@ -0,0 +1,35 @@ +/* + * 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.delombok; + +/** 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/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index b38d3ef5..4ec5e270 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -1,5 +1,5 @@ /* - * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * Copyright © 2009-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 @@ -50,6 +50,11 @@ import com.zwitserloot.cmdreader.Shorthand; public class Delombok { private Charset charset = Charset.defaultCharset(); private CommentPreservingParser parser = new CommentPreservingParser(); + + { + parser.setDeleteLombokAnnotations(true); + } + private PrintStream feedback = System.err; private boolean verbose; private boolean noCopy; |