Skip to content

Commit 2171cd3

Browse files
committed
glayzzle#194 - add a setTrailingComments helper
1 parent a2adc22 commit 2171cd3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/ast.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
287287
node.apply(astNode, args);
288288
result.instance = astNode;
289289
if (result.trailingComments) {
290+
// buffer of trailingComments
290291
astNode.trailingComments = result.trailingComments;
291292
}
292293
return self.resolvePrecedence(astNode);
@@ -305,7 +306,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
305306
result.setTrailingComments = function(docs) {
306307
if (result.instance) {
307308
// already created
308-
result.instance.trailingComments = docs;
309+
result.instance.setTrailingComments(docs);
309310
} else {
310311
result.trailingComments = docs;
311312
}

src/ast/node.js

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ const Node = function Node(kind, docs, location) {
2323
}
2424
};
2525

26+
/**
27+
* Attach comments to current node
28+
* @param {*} docs
29+
*/
30+
Node.prototype.setTrailingComments = function(docs) {
31+
this.trailingComments = docs;
32+
};
33+
2634
/**
2735
* Includes current token position of the parser
2836
* @param {*} parser

0 commit comments

Comments
 (0)