diff options
author | Roel Spilker <r.spilker@gmail.com> | 2013-09-25 23:04:04 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2013-09-25 23:04:04 +0200 |
commit | 728dddbc81d9f9bfbbd3f8217b8c94f3f201c83d (patch) | |
tree | 0b9d9b2bd0ec50e37ed5a82a748b936123fa847b /src/core/lombok/javac | |
parent | 00a8b08226aa0daa2061d171607bf0d5369ed292 (diff) | |
download | lombok-728dddbc81d9f9bfbbd3f8217b8c94f3f201c83d.tar.gz lombok-728dddbc81d9f9bfbbd3f8217b8c94f3f201c83d.tar.bz2 lombok-728dddbc81d9f9bfbbd3f8217b8c94f3f201c83d.zip |
[jdk8support] ... and javadoc copying support is back for javac8. Also fixed some copyright headers.
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index f90bb60d..6d6426aa 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -50,6 +50,8 @@ import lombok.javac.JavacTreeMaker; import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.tree.DocCommentTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; @@ -217,6 +219,17 @@ public class JavacHandlerUtil { } /** + * Returns if a node is marked deprecated (as picked up on by the parser). + * @param node the node to check (type, method, or field decl). + */ + public static boolean nodeHasDeprecatedFlag(JCTree node) { + if (node instanceof JCVariableDecl) return (((JCVariableDecl) node).mods.flags & Flags.DEPRECATED) != 0; + if (node instanceof JCMethodDecl) return (((JCMethodDecl) node).mods.flags & Flags.DEPRECATED) != 0; + if (node instanceof JCClassDecl) return (((JCClassDecl) node).mods.flags & Flags.DEPRECATED) != 0; + return false; + } + + /** * Creates an instance of {@code AnnotationValues} for the provided AST Node. * * @param type An annotation class type, such as {@code lombok.Getter.class}. @@ -1325,7 +1338,36 @@ public class JavacHandlerUtil { 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)); + } } } catch (Exception ignore) {} } + + 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); + } + }; + } } |