aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok/javac
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2013-09-09 23:54:28 +0200
committerRoel Spilker <r.spilker@gmail.com>2013-09-09 23:54:28 +0200
commit6a02cb40137788e6f77919c762b72b3d5880d2da (patch)
tree3c0f1c1a2108f1c65c15bb187e8b09534c8e99cc /src/utils/lombok/javac
parentf2662518de40569e073991bc70a1629881ba655e (diff)
downloadlombok-6a02cb40137788e6f77919c762b72b3d5880d2da.tar.gz
lombok-6a02cb40137788e6f77919c762b72b3d5880d2da.tar.bz2
lombok-6a02cb40137788e6f77919c762b72b3d5880d2da.zip
[jdk8support] We now handle doc comments internally, alleviating the need to try and keep up with the complete rewrites of the doc comment parser from java6 to java7 to java8. Still doesn't actually work in jdk8, but only because of a last-mile issue. (we communicate the doc comment via compilationUnit.docComments but that changed types in jdk8, we just need to make a wrapper to make that work).
Diffstat (limited to 'src/utils/lombok/javac')
-rw-r--r--src/utils/lombok/javac/CommentCatcher.java13
-rw-r--r--src/utils/lombok/javac/Javac.java11
2 files changed, 22 insertions, 2 deletions
diff --git a/src/utils/lombok/javac/CommentCatcher.java b/src/utils/lombok/javac/CommentCatcher.java
index 48dd7e75..36d90e30 100644
--- a/src/utils/lombok/javac/CommentCatcher.java
+++ b/src/utils/lombok/javac/CommentCatcher.java
@@ -22,13 +22,14 @@
package lombok.javac;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
public class CommentCatcher {
private final JavaCompiler compiler;
@@ -56,9 +57,17 @@ public class CommentCatcher {
return compiler;
}
+ public void setComments(JCCompilationUnit ast, List<CommentInfo> comments) {
+ if (comments != null) {
+ commentsMap.put(ast, comments);
+ } else {
+ commentsMap.remove(ast);
+ }
+ }
+
public List<CommentInfo> getComments(JCCompilationUnit ast) {
List<CommentInfo> list = commentsMap.get(ast);
- return list == null ? List.<CommentInfo>nil() : list;
+ return list == null ? Collections.<CommentInfo>emptyList() : list;
}
private static void registerCommentsCollectingScannerFactory(Context context) {
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java
index c90b8611..2f3c9be4 100644
--- a/src/utils/lombok/javac/Javac.java
+++ b/src/utils/lombok/javac/Javac.java
@@ -27,6 +27,7 @@ import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.HashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -196,6 +197,16 @@ public class Javac {
}
}
+ public static void initDocComments(JCCompilationUnit cu) {
+ try {
+ JCCOMPILATIONUNIT_DOCCOMMENTS.set(cu, new HashMap<Object, String>());
+ } catch (IllegalArgumentException e) {
+ // That's fine - we're on JDK8, we'll fix that later.
+ } catch (IllegalAccessException e) {
+ throw sneakyThrow(e);
+ }
+ }
+
public static int getEndPosition(DiagnosticPosition pos, JCCompilationUnit top) {
try {
Object endPositions = JCCOMPILATIONUNIT_ENDPOSITIONS.get(top);