diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-07-22 23:23:46 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-07-22 23:23:46 +0200 |
commit | 45697b50816df79475a8bb69dc89ff68747fbfe6 (patch) | |
tree | 25cb023eec1f74baf5063cc5a58a5351ee43d6f0 /src/utils/lombok/javac/CommentCatcher.java | |
parent | 4c03e3d220900431085897878d4888bf530b31ec (diff) | |
parent | deed98be16e5099af52d951fc611f86a82a42858 (diff) | |
download | lombok-45697b50816df79475a8bb69dc89ff68747fbfe6.tar.gz lombok-45697b50816df79475a8bb69dc89ff68747fbfe6.tar.bz2 lombok-45697b50816df79475a8bb69dc89ff68747fbfe6.zip |
Merge branch 'master' into jdk8. Also added some major fixes whilst merging.
Conflicts:
src/core/lombok/javac/handlers/JavacHandlerUtil.java
src/utils/lombok/javac/CommentCatcher.java
src/utils/lombok/javac/Javac.java
Diffstat (limited to 'src/utils/lombok/javac/CommentCatcher.java')
-rw-r--r-- | src/utils/lombok/javac/CommentCatcher.java | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/utils/lombok/javac/CommentCatcher.java b/src/utils/lombok/javac/CommentCatcher.java index e3754627..8d1e71c0 100644 --- a/src/utils/lombok/javac/CommentCatcher.java +++ b/src/utils/lombok/javac/CommentCatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Project Lombok Authors. + * Copyright (C) 2011-2013 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,9 +21,12 @@ */ package lombok.javac; +import java.lang.reflect.InvocationTargetException; import java.util.Map; import java.util.WeakHashMap; +import lombok.Lombok; + import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; @@ -62,36 +65,33 @@ public class CommentCatcher { private static void registerCommentsCollectingScannerFactory(Context context) { try { - if (JavaCompiler.version().startsWith("1.6")) { - Class.forName("lombok.javac.java6.CommentCollectingScannerFactory").getMethod("preRegister", Context.class).invoke(null, context); - } else if (JavaCompiler.version().startsWith("1.7") || JavaCompiler.version().startsWith("1.8")) { - Class.forName("lombok.javac.java7.CommentCollectingScannerFactory").getMethod("preRegister", Context.class).invoke(null, context); + Class<?> scannerFactory; + if (Javac.getJavaCompilerVersion() <= 6) { + scannerFactory = Class.forName("lombok.javac.java6.CommentCollectingScannerFactory"); } else { - throw new IllegalStateException("No comments parser for compiler version " + JavaCompiler.version()); + scannerFactory = Class.forName("lombok.javac.java7.CommentCollectingScannerFactory"); } + scannerFactory.getMethod("preRegister", Context.class).invoke(null, context); + } catch (InvocationTargetException e) { + throw Lombok.sneakyThrow(e.getCause()); } catch (Exception e) { - if (e instanceof RuntimeException) throw (RuntimeException)e; - throw new RuntimeException(e); + throw Lombok.sneakyThrow(e); } } private static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) { - try { - if (JavaCompiler.version().startsWith("1.6")) { - Class<?> parserFactory = Class.forName("lombok.javac.java6.CommentCollectingParserFactory"); - parserFactory.getMethod("setInCompiler",JavaCompiler.class, Context.class, Map.class).invoke(null, compiler, context, commentsMap); - } else if (JavaCompiler.version().startsWith("1.7") || JavaCompiler.version().startsWith("1.8")) { - Class<?> parserFactory = Class.forName("lombok.javac.java7.CommentCollectingParserFactory"); - parserFactory.getMethod("setInCompiler",JavaCompiler.class, Context.class, Map.class).invoke(null, compiler, context, commentsMap); + Class<?> parserFactory; + if (Javac.getJavaCompilerVersion() <= 6) { + parserFactory = Class.forName("lombok.javac.java6.CommentCollectingParserFactory"); } else { - throw new IllegalStateException("No comments parser for compiler version " + JavaCompiler.version()); + parserFactory = Class.forName("lombok.javac.java7.CommentCollectingParserFactory"); } - + parserFactory.getMethod("setInCompiler", JavaCompiler.class, Context.class, Map.class).invoke(null, compiler, context, commentsMap); + } catch (InvocationTargetException e) { + throw Lombok.sneakyThrow(e.getCause()); } catch (Exception e) { - if (e instanceof RuntimeException) throw (RuntimeException)e; - throw new RuntimeException(e); + throw Lombok.sneakyThrow(e); } } - } |