Handle ContinueStatement and BreakStatement comments (#4279)
parent
4bc80d8c64
commit
f3626611a3
|
@ -135,7 +135,8 @@ function handleRemainingComment(comment, text, options, ast, isLastComment) {
|
|||
precedingNode,
|
||||
comment,
|
||||
options
|
||||
)
|
||||
) ||
|
||||
handleBreakAndContinueStatementComments(enclosingNode, comment)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
@ -553,6 +554,19 @@ function handleLabeledStatementComments(enclosingNode, comment) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function handleBreakAndContinueStatementComments(enclosingNode, comment) {
|
||||
if (
|
||||
enclosingNode &&
|
||||
(enclosingNode.type === "ContinueStatement" ||
|
||||
enclosingNode.type === "BreakStatement") &&
|
||||
!enclosingNode.label
|
||||
) {
|
||||
addTrailingComment(enclosingNode, comment);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
|
||||
if (
|
||||
enclosingNode &&
|
||||
|
|
|
@ -82,6 +82,33 @@ exports[`blank.js 1`] = `
|
|||
|
||||
`;
|
||||
|
||||
exports[`break-continue-statements.js 1`] = `
|
||||
for (;;) {
|
||||
break /* comment */;
|
||||
continue /* comment */;
|
||||
}
|
||||
|
||||
loop: for (;;) {
|
||||
break /* comment */ loop;
|
||||
break loop /* comment */;
|
||||
continue /* comment */ loop;
|
||||
continue loop /* comment */;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
for (;;) {
|
||||
break; /* comment */
|
||||
continue; /* comment */
|
||||
}
|
||||
|
||||
loop: for (;;) {
|
||||
break /* comment */ loop;
|
||||
break loop /* comment */;
|
||||
continue /* comment */ loop;
|
||||
continue loop /* comment */;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`call_comment.js 1`] = `
|
||||
render( // Warm any cache
|
||||
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
for (;;) {
|
||||
break /* comment */;
|
||||
continue /* comment */;
|
||||
}
|
||||
|
||||
loop: for (;;) {
|
||||
break /* comment */ loop;
|
||||
break loop /* comment */;
|
||||
continue /* comment */ loop;
|
||||
continue loop /* comment */;
|
||||
}
|
Loading…
Reference in New Issue