use of com.google.devtools.j2objc.ast.LineComment in project j2objc by google.
the class TreeConverter method convertAssociatedComment.
private Comment convertAssociatedComment(JCTree node, Element element) {
boolean docCommentsEnabled = newUnit.getEnv().options().docCommentsEnabled();
DocCommentTable docComments = unit.docComments;
if (!docCommentsEnabled || docComments == null || !docComments.hasComment(node)) {
return null;
}
com.sun.tools.javac.parser.Tokens.Comment javacComment = docComments.getComment(node);
Comment comment;
switch(javacComment.getStyle()) {
case BLOCK:
comment = new BlockComment();
break;
case JAVADOC:
comment = docCommentsEnabled ? convertJavadocComment(element) : new Javadoc();
break;
case LINE:
comment = new LineComment();
break;
default:
throw new AssertionError("unknown comment type");
}
int startPos = javacComment.getSourcePos(0);
int endPos = startPos + javacComment.getText().length();
comment.setSourceRange(startPos, endPos);
comment.setLineNumber(unit.getLineMap().getLineNumber(startPos));
return comment;
}
Aggregations