Do not attach comments to EmptyStatements in try/catch (#763)
We skip EmptyStatement when generating the list of preceding/enclosing/following nodes but didn't do the same for the exceptions. Fixes #695master
parent
9c558bfe71
commit
0241d97b77
|
@ -291,10 +291,11 @@ function addTrailingComment(node, comment) {
|
|||
}
|
||||
|
||||
function addBlockStatementFirstComment(node, comment) {
|
||||
if (node.body.length === 0) {
|
||||
const body = node.body.filter(n => n.type !== "EmptyStatement");
|
||||
if (body.length === 0) {
|
||||
addDanglingComment(node, comment);
|
||||
} else {
|
||||
addLeadingComment(node.body[0], comment);
|
||||
addLeadingComment(body[0], comment);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`try.js 1`] = `
|
||||
"try
|
||||
/* missing comment */
|
||||
{;}
|
||||
finally {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
try {
|
||||
/* missing comment */
|
||||
} finally {
|
||||
}
|
||||
"
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname);
|
|
@ -0,0 +1,4 @@
|
|||
try
|
||||
/* missing comment */
|
||||
{;}
|
||||
finally {}
|
Loading…
Reference in New Issue