aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java42
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);
+ }
+ };
+ }
}