aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-10-10 20:41:29 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-10-10 23:24:04 +0200
commit08961edcfeef9b181621351e36bbc267f9395415 (patch)
tree8aa4f4ae8e6af3247a547d01bb1dee5f8e66cdf4 /src/core
parent728dddbc81d9f9bfbbd3f8217b8c94f3f201c83d (diff)
downloadlombok-08961edcfeef9b181621351e36bbc267f9395415.tar.gz
lombok-08961edcfeef9b181621351e36bbc267f9395415.tar.bz2
lombok-08961edcfeef9b181621351e36bbc267f9395415.zip
Whoops, Classload errors running lombok on javac with backing JVM 7 or below; fixed.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java78
1 files changed, 44 insertions, 34 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 6d6426aa..50e80169 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1323,51 +1323,61 @@ public class JavacHandlerUtil {
*
* in 'SETTER' mode, stripping works similarly to 'GETTER' mode, except {@code param} are copied and stripped from the original and {@code @return} are skipped.
*/
- @SuppressWarnings("unchecked")
public static void copyJavadoc(JavacNode from, JCTree to, CopyJavadoc copyMode) {
if (copyMode == null) copyMode = CopyJavadoc.VERBATIM;
try {
JCCompilationUnit cu = ((JCCompilationUnit) from.top().get());
Object dc = Javac.getDocComments(cu);
if (dc instanceof Map) {
- Map<JCTree, String> docComments = (Map<JCTree, String>) dc;
- String javadoc = docComments.get(from.get());
-
- if (javadoc != null) {
- String[] filtered = copyMode.split(javadoc);
- docComments.put(to, filtered[0]);
- docComments.put(from.get(), filtered[1]);
- }
- } else if (dc instanceof DocCommentTable) {
- DocCommentTable dct = (DocCommentTable) dc;
- Comment javadoc = dct.getComment(from.get());
-
- if (javadoc != null) {
- String[] filtered = copyMode.split(javadoc.getText());
- dct.putComment(to, createJavadocComment(filtered[0], from));
- dct.putComment(from.get(), createJavadocComment(filtered[1], from));
- }
+ copyJavadoc_jdk6_7(from, to, copyMode, dc);
+ } else if (Javac.instanceOfDocCommentTable(dc)) {
+ CopyJavadoc_8.copyJavadoc(from, to, copyMode, dc);
}
} catch (Exception ignore) {}
}
- private static Comment createJavadocComment(final String text, final JavacNode field) {
- return new Comment() {
- @Override public String getText() {
- return text;
- }
+ private static class CopyJavadoc_8 {
+ static void copyJavadoc(JavacNode from, JCTree to, CopyJavadoc copyMode, Object dc) {
+ DocCommentTable dct = (DocCommentTable) dc;
+ Comment javadoc = dct.getComment(from.get());
- @Override public int getSourcePos(int index) {
- return -1;
+ if (javadoc != null) {
+ String[] filtered = copyMode.split(javadoc.getText());
+ dct.putComment(to, createJavadocComment(filtered[0], from));
+ dct.putComment(from.get(), createJavadocComment(filtered[1], from));
}
-
- @Override public CommentStyle getStyle() {
- return CommentStyle.JAVADOC;
- }
-
- @Override public boolean isDeprecated() {
- return text.contains("@deprecated") && field.getKind() == Kind.FIELD && isFieldDeprecated(field);
- }
- };
+ }
+
+ private static Comment createJavadocComment(final String text, final JavacNode field) {
+ return new Comment() {
+ @Override public String getText() {
+ return text;
+ }
+
+ @Override public int getSourcePos(int index) {
+ return -1;
+ }
+
+ @Override public CommentStyle getStyle() {
+ return CommentStyle.JAVADOC;
+ }
+
+ @Override public boolean isDeprecated() {
+ return text.contains("@deprecated") && field.getKind() == Kind.FIELD && isFieldDeprecated(field);
+ }
+ };
+ }
+ }
+
+ @SuppressWarnings({"unchecked", "all"})
+ private static void copyJavadoc_jdk6_7(JavacNode from, JCTree to, CopyJavadoc copyMode, Object dc) {
+ Map<JCTree, String> docComments = (Map<JCTree, String>) dc;
+ String javadoc = docComments.get(from.get());
+
+ if (javadoc != null) {
+ String[] filtered = copyMode.split(javadoc);
+ docComments.put(to, filtered[0]);
+ docComments.put(from.get(), filtered[1]);
+ }
}
}