Class Comments
- Author:
- andrewrice@google.com (Andrew Rice)
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableList
<Commented<com.sun.source.tree.ExpressionTree>> findCommentsForArguments
(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state) Attach comments to nodes on arguments of method calls.static com.google.common.collect.ImmutableList
<Commented<com.sun.source.tree.ExpressionTree>> findCommentsForArguments
(com.sun.source.tree.NewClassTree newClassTree, VisitorState state) Attach comments to nodes on arguments of constructor calls.static String
getTextFromComment
(ErrorProneComment comment) Extract the text body from a comment.
-
Method Details
-
findCommentsForArguments
public static com.google.common.collect.ImmutableList<Commented<com.sun.source.tree.ExpressionTree>> findCommentsForArguments(com.sun.source.tree.NewClassTree newClassTree, VisitorState state) Attach comments to nodes on arguments of constructor calls. Calls such asnew Test( param1 /* c1 */, /* c2 */ param2)
will attach the comment c1 toparam1
and the comment c2 toparam2
.Warning: this is expensive to compute as it involves re-tokenizing the source for this node.
Currently this method will only tokenize the source code of the method call itself. However, the source positions in the returned
Comment
objects are adjusted so that they are relative to the whole file. -
findCommentsForArguments
public static com.google.common.collect.ImmutableList<Commented<com.sun.source.tree.ExpressionTree>> findCommentsForArguments(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state) Attach comments to nodes on arguments of method calls. Calls such astest(param1 /* c1 */, /* c2 */ param2)
will attach the comment c1 toparam1
and the comment c2 toparam2
.Warning: this is expensive to compute as it involves re-tokenizing the source for this node
Currently this method will only tokenize the source code of the method call itself. However, the source positions in the returned
Comment
objects are adjusted so that they are relative to the whole file. -
getTextFromComment
Extract the text body from a comment.This currently includes asterisks that start lines in the body of block comments. Do not rely on this behaviour.
TODO(andrewrice) Update this method to handle block comments properly if we find the need
-