Example usage for org.eclipse.jdt.core.dom CompilationUnit setCommentTable

List of usage examples for org.eclipse.jdt.core.dom CompilationUnit setCommentTable

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom CompilationUnit setCommentTable.

Prototype

void setCommentTable(Comment[] commentTable) 

Source Link

Document

Sets the list of the comments encountered while parsing this compilation unit.

Usage

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

/**
 * @param compilationUnit//from w ww . j  a  v a  2  s  .c  o  m
 * @param comments
 */
void buildCommentsTable(CompilationUnit compilationUnit, int[][] comments) {
    // Build comment table
    this.commentsTable = new Comment[comments.length];
    int nbr = 0;
    for (int i = 0; i < comments.length; i++) {
        Comment comment = createComment(comments[i]);
        if (comment != null) {
            comment.setAlternateRoot(compilationUnit);
            this.commentsTable[nbr++] = comment;
        }
    }
    // Resize table if  necessary
    if (nbr < comments.length) {
        Comment[] newCommentsTable = new Comment[nbr];
        System.arraycopy(this.commentsTable, 0, newCommentsTable, 0, nbr);
        this.commentsTable = newCommentsTable;
    }
    compilationUnit.setCommentTable(this.commentsTable);
}