in lib/generator.js [1820:1853]
visitArray(ast, level) {
assert.equal(ast.type, 'array');
let arrayComments = DSL.comment.getBetweenComments(this.comments, ast.tokenRange[0], ast.tokenRange[1]);
if (ast.items.length === 0) {
this.emit('[ ');
if (arrayComments.length > 0) {
this.emit('\n');
this.visitComments(arrayComments, level + 1);
this.emit('', level);
}
this.emit(']');
return;
}
this.emit('[\n');
let item;
for (let i = 0; i < ast.items.length; i++) {
item = ast.items[i];
let comments = DSL.comment.getFrontComments(this.comments, item.tokenRange[0]);
this.visitComments(comments, level + 1);
this.emit('', level + 1);
this.visitExpr(item, level + 1);
if (i < ast.items.length - 1) {
this.emit(',');
}
this.emit('\n');
}
if (item) {
//find the last item's back comment
let comments = DSL.comment.getBetweenComments(this.comments, item.tokenRange[0], ast.tokenRange[1]);
this.visitComments(comments, level + 1);
}
this.emit(']', level);
}