Example usage for org.eclipse.jdt.core.dom Comment setAlternateRoot

List of usage examples for org.eclipse.jdt.core.dom Comment setAlternateRoot

Introduction

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

Prototype

public final void setAlternateRoot(ASTNode root) 

Source Link

Document

Returns the root AST node that this comment occurs within, or null if none (or not recorded).

Usage

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

License:Open Source License

/**
 * @param compilationUnit/*from   w w  w .jav a2  s .c  om*/
 * @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);
}