diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-06-05 23:45:43 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-06-05 23:45:43 +0200 |
commit | 1ce747178b8f24f29f94dd795f09f872aad9272f (patch) | |
tree | 76e66d528c56f22ac5782846df4758d75a8b55bd /src/utils/lombok/javac/java6/CommentCollectingParserFactory.java | |
parent | f30485c91fd3f9553fbcbc02d922e6221182c26e (diff) | |
download | lombok-1ce747178b8f24f29f94dd795f09f872aad9272f.tar.gz lombok-1ce747178b8f24f29f94dd795f09f872aad9272f.tar.bz2 lombok-1ce747178b8f24f29f94dd795f09f872aad9272f.zip |
Finished refactor of FieldAugment; there's no longer a separate variant for boolean and references, and the code no longer blows up with a bunch of NPEs if you try to use the reference variant (which is now the only variant) with a primitive type.
Should have zero effect on features or bugs, 100% refactor.
Diffstat (limited to 'src/utils/lombok/javac/java6/CommentCollectingParserFactory.java')
-rw-r--r-- | src/utils/lombok/javac/java6/CommentCollectingParserFactory.java | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java index 124a05f7..0cf8fdcd 100644 --- a/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java +++ b/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java @@ -23,43 +23,35 @@ package lombok.javac.java6; import java.lang.reflect.Field; -import lombok.core.ReferenceFieldAugment; -import lombok.javac.CommentInfo; - import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.parser.Lexer; import com.sun.tools.javac.parser.Parser; -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.List; public class CommentCollectingParserFactory extends Parser.Factory { - private final ReferenceFieldAugment<JCCompilationUnit, List<CommentInfo>> commentsField; - static Context.Key<Parser.Factory> key() { return parserFactoryKey; } - protected CommentCollectingParserFactory(Context context, ReferenceFieldAugment<JCCompilationUnit, List<CommentInfo>> commentsField) { + protected CommentCollectingParserFactory(Context context) { super(context); - this.commentsField = commentsField; } @Override public Parser newParser(Lexer S, boolean keepDocComments, boolean genEndPos) { - Object x = new CommentCollectingParser(this, S, true, commentsField); + Object x = new CommentCollectingParser(this, S, true); return (Parser) x; // CCP is based on a stub which extends nothing, but at runtime the stub is replaced with either //javac6's EndPosParser which extends Parser, or javac7's EndPosParser which implements Parser. //Either way this will work out. } - public static void setInCompiler(JavaCompiler compiler, Context context, ReferenceFieldAugment<JCCompilationUnit, List<CommentInfo>> commentsField) { + public static void setInCompiler(JavaCompiler compiler, Context context) { context.put(CommentCollectingParserFactory.key(), (Parser.Factory)null); Field field; try { field = JavaCompiler.class.getDeclaredField("parserFactory"); field.setAccessible(true); - field.set(compiler, new CommentCollectingParserFactory(context, commentsField)); + field.set(compiler, new CommentCollectingParserFactory(context)); } catch (Exception e) { throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e); } |