mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-13 12:07:08 +00:00
Fix for: Track comments will take the comment after the next token instead of the current. Also do "delete" of property instead of setting it to null for cleaner AST tree.
This commit is contained in:
1 parent
85481225a3
commit
a652fdf8d2
1 file changed
+6
-5
@@ -156,7 +156,7 @@ if (!exports.acorn) {
|
||||
// These are used to hold arrays of comments when
|
||||
// `options.trackComments` is true.
|
||||
|
||||
var tokCommentsBefore, tokCommentsAfter;
|
||||
var tokCommentsBefore, tokCommentsAfter, lastTokCommentsAfter;
|
||||
|
||||
// These are used to hold arrays of spaces when
|
||||
// `options.trackSpaces` is true.
|
||||
@@ -505,6 +505,7 @@ if (!exports.acorn) {
|
||||
tokType = type;
|
||||
skipSpace();
|
||||
tokVal = val;
|
||||
lastTokCommentsAfter = tokCommentsAfter;
|
||||
tokCommentsAfter = tokComments;
|
||||
tokSpacesAfter = tokSpaces;
|
||||
tokRegexpAllowed = type.beforeExpr;
|
||||
@@ -1056,7 +1057,7 @@ if (!exports.acorn) {
|
||||
node.start = other.start;
|
||||
if (other.commentsBefore) {
|
||||
node.commentsBefore = other.commentsBefore;
|
||||
other.commentsBefore = null;
|
||||
delete other.commentsBefore;
|
||||
}
|
||||
if (options.locations) {
|
||||
node.loc = new node_loc_t();
|
||||
@@ -1083,13 +1084,13 @@ if (!exports.acorn) {
|
||||
node.type = type;
|
||||
node.end = lastEnd;
|
||||
if (options.trackComments) {
|
||||
if (tokCommentsAfter) {
|
||||
node.commentsAfter = tokCommentsAfter;
|
||||
if (lastTokCommentsAfter) {
|
||||
node.commentsAfter = lastTokCommentsAfter;
|
||||
tokCommentsAfter = null;
|
||||
} else if (lastFinishedNode && lastFinishedNode.end === lastEnd &&
|
||||
lastFinishedNode.commentsAfter) {
|
||||
node.commentsAfter = lastFinishedNode.commentsAfter;
|
||||
lastFinishedNode.commentsAfter = null;
|
||||
delete lastFinishedNode.commentsAfter;
|
||||
}
|
||||
if (!options.trackSpaces)
|
||||
lastFinishedNode = node;
|
||||
|
||||
Reference in new issue
Block a user