Search in sources :

Example 1 with DocCommentTable

use of com.sun.tools.javac.tree.DocCommentTable 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;
}
Also used : LineComment(com.google.devtools.j2objc.ast.LineComment) BlockComment(com.google.devtools.j2objc.ast.BlockComment) Comment(com.google.devtools.j2objc.ast.Comment) BlockComment(com.google.devtools.j2objc.ast.BlockComment) DocCommentTable(com.sun.tools.javac.tree.DocCommentTable) Javadoc(com.google.devtools.j2objc.ast.Javadoc) LineComment(com.google.devtools.j2objc.ast.LineComment)

Aggregations

BlockComment (com.google.devtools.j2objc.ast.BlockComment)1 Comment (com.google.devtools.j2objc.ast.Comment)1 Javadoc (com.google.devtools.j2objc.ast.Javadoc)1 LineComment (com.google.devtools.j2objc.ast.LineComment)1 DocCommentTable (com.sun.tools.javac.tree.DocCommentTable)1