Fix babylon misplacing comments (#3441)

* Fix comments in class method args

* Fix comments in obj property
master
Lucas Duailibe 2017-12-09 15:43:19 -02:00 committed by GitHub
parent 4f24892e53
commit 934e4d3027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 19 deletions

View File

@ -207,7 +207,6 @@ function attach(comments, ast, text, options) {
comment
) ||
handleImportSpecifierComments(enclosingNode, comment) ||
handleObjectPropertyComments(enclosingNode, comment) ||
handleForComments(enclosingNode, precedingNode, comment) ||
handleUnionTypeComments(
precedingNode,
@ -273,7 +272,6 @@ function attach(comments, ast, text, options) {
handlePropertyComments(enclosingNode, comment) ||
handleExportNamedDeclarationComments(enclosingNode, comment) ||
handleOnlyComments(enclosingNode, ast, comment, isLastComment) ||
handleClassMethodComments(enclosingNode, comment) ||
handleTypeAliasComments(enclosingNode, followingNode, comment) ||
handleVariableDeclaratorComments(enclosingNode, followingNode, comment)
) {
@ -756,14 +754,6 @@ function handleImportSpecifierComments(enclosingNode, comment) {
return false;
}
function handleObjectPropertyComments(enclosingNode, comment) {
if (enclosingNode && enclosingNode.type === "ObjectProperty") {
addLeadingComment(enclosingNode, comment);
return true;
}
return false;
}
function handleLabeledStatementComments(enclosingNode, comment) {
if (enclosingNode && enclosingNode.type === "LabeledStatement") {
addLeadingComment(enclosingNode, comment);
@ -887,14 +877,6 @@ function handleAssignmentPatternComments(enclosingNode, comment) {
return false;
}
function handleClassMethodComments(enclosingNode, comment) {
if (enclosingNode && enclosingNode.type === "ClassMethod") {
addTrailingComment(enclosingNode, comment);
return true;
}
return false;
}
function handleTypeAliasComments(enclosingNode, followingNode, comment) {
if (enclosingNode && enclosingNode.type === "TypeAlias") {
addLeadingComment(enclosingNode, comment);

View File

@ -41,6 +41,14 @@ class X {
'<div class="ag-large-textarea"></div>' +
'</div>';
}
export class SnapshotLogger {
constructor(
retentionPeriod: number = 5 * 60 * 1000, // retain past five minutes
snapshotInterval: number = 30 * 1000, // snapshot no more than every 30s
) {
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A // comment 1
// comment 2
@ -87,4 +95,11 @@ class X {
"</div>";
}
export class SnapshotLogger {
constructor(
retentionPeriod: number = 5 * 60 * 1000, // retain past five minutes
snapshotInterval: number = 30 * 1000 // snapshot no more than every 30s
) {}
}
`;

View File

@ -38,3 +38,11 @@ class X {
'<div class="ag-large-textarea"></div>' +
'</div>';
}
export class SnapshotLogger {
constructor(
retentionPeriod: number = 5 * 60 * 1000, // retain past five minutes
snapshotInterval: number = 30 * 1000, // snapshot no more than every 30s
) {
}
}

View File

@ -1 +1 @@
run_spec(__dirname, ["flow"]);
run_spec(__dirname, ["flow", "babylon"]);