From 8b8c490ff6b5cd89cee0d9049c733e6bbba1a719 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 8 Feb 2017 13:36:19 -0800 Subject: [PATCH] Address code review: fix indentation --- src/compiler/emitter.ts | 2 ++ .../reference/amdImportAsPrimaryExpression.js | 2 +- tests/baselines/reference/argsInScope.js | 2 +- .../reference/commentLeadingCloseBrace.js | 2 +- .../commonJSImportAsPrimaryExpression.js | 2 +- .../reference/duplicateLocalVariable1.js | 2 +- .../jsFileCompilationLetBeingRenamed.js | 2 +- .../narrowExceptionVariableInCatchClause.js | 2 +- tests/baselines/reference/noCatchBlock.js | 4 +-- tests/baselines/reference/noCatchBlock.js.map | 2 +- .../reference/noCatchBlock.sourcemap.txt | 28 +++++++++---------- tests/baselines/reference/objectRestForOf.js | 2 +- .../baselines/reference/parserRealSource14.js | 2 +- tests/baselines/reference/recursiveReturns.js | 2 +- .../reference/sourceMap-SkippedNode.js | 4 +-- .../reference/sourceMap-SkippedNode.js.map | 2 +- .../sourceMap-SkippedNode.sourcemap.txt | 28 +++++++++---------- 17 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fcb3fb826c..03804dfeeb 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1348,7 +1348,9 @@ namespace ts { writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); emitBlockStatements(node); // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); } } diff --git a/tests/baselines/reference/amdImportAsPrimaryExpression.js b/tests/baselines/reference/amdImportAsPrimaryExpression.js index 25f390c0b3..6ff3216fb5 100644 --- a/tests/baselines/reference/amdImportAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportAsPrimaryExpression.js @@ -26,6 +26,6 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "./foo_0"], function (require, exports, foo) { "use strict"; if (foo.E1.A === 0) { - // Should cause runtime import - interesting optimization possibility, as gets inlined to 0. + // Should cause runtime import - interesting optimization possibility, as gets inlined to 0. } }); diff --git a/tests/baselines/reference/argsInScope.js b/tests/baselines/reference/argsInScope.js index 27405a47d8..a38bc77803 100644 --- a/tests/baselines/reference/argsInScope.js +++ b/tests/baselines/reference/argsInScope.js @@ -17,7 +17,7 @@ var C = (function () { } C.prototype.P = function (ii, j, k) { for (var i = 0; i < arguments.length; i++) { - // WScript.Echo("param: " + arguments[i]); + // WScript.Echo("param: " + arguments[i]); } }; return C; diff --git a/tests/baselines/reference/commentLeadingCloseBrace.js b/tests/baselines/reference/commentLeadingCloseBrace.js index 9fc696219e..d5f5afbb88 100644 --- a/tests/baselines/reference/commentLeadingCloseBrace.js +++ b/tests/baselines/reference/commentLeadingCloseBrace.js @@ -16,7 +16,7 @@ function ifelse() { if (commentedParameters(1, 2)) { /*comment1*/ commentedParameters(3, 4); - /*comment2*/ + /*comment2*/ } else { commentedParameters(5, 6); diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js index 1eb7b5ff21..0cbb7470df 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js @@ -27,5 +27,5 @@ exports.C1 = C1; "use strict"; var foo = require("./foo_0"); if (foo.C1.s1) { -// Should cause runtime import + // Should cause runtime import } diff --git a/tests/baselines/reference/duplicateLocalVariable1.js b/tests/baselines/reference/duplicateLocalVariable1.js index 432830d85b..39848b3bb6 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.js +++ b/tests/baselines/reference/duplicateLocalVariable1.js @@ -391,7 +391,7 @@ var TestRunner = (function () { } } if (testResult === false) { - //console.log(e.message); + //console.log(e.message); } } if ((testcase.errorMessageRegEx !== undefined) && !exception) { diff --git a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js index bb2aa10dc9..a87dad3c91 100644 --- a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js +++ b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.js @@ -9,6 +9,6 @@ function foo(a) { //// [out.js] function foo(a) { for (var a_1 = 0; a_1 < 10; a_1++) { - // do something + // do something } } diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.js b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js index 18344df599..b7dbf717e3 100644 --- a/tests/baselines/reference/narrowExceptionVariableInCatchClause.js +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js @@ -27,7 +27,7 @@ function tryCatch() { //// [narrowExceptionVariableInCatchClause.js] function tryCatch() { try { - // do stuff... + // do stuff... } catch (err) { if (isFooError(err)) { diff --git a/tests/baselines/reference/noCatchBlock.js b/tests/baselines/reference/noCatchBlock.js index 158ac1257f..ecc9c7f8c7 100644 --- a/tests/baselines/reference/noCatchBlock.js +++ b/tests/baselines/reference/noCatchBlock.js @@ -8,9 +8,9 @@ try { //// [noCatchBlock.js] try { -// ... + // ... } finally { -// N.B. No 'catch' block + // N.B. No 'catch' block } //# sourceMappingURL=noCatchBlock.js.map \ No newline at end of file diff --git a/tests/baselines/reference/noCatchBlock.js.map b/tests/baselines/reference/noCatchBlock.js.map index ddac2894e0..392ec58810 100644 --- a/tests/baselines/reference/noCatchBlock.js.map +++ b/tests/baselines/reference/noCatchBlock.js.map @@ -1,2 +1,2 @@ //// [noCatchBlock.js.map] -{"version":3,"file":"noCatchBlock.js","sourceRoot":"","sources":["noCatchBlock.ts"],"names":[],"mappings":"AACA,IAAI,CAAC;AACJ,MAAM;AACP,CAAC;QAAS,CAAC;AACV,wBAAwB;AACzB,CAAC"} \ No newline at end of file +{"version":3,"file":"noCatchBlock.js","sourceRoot":"","sources":["noCatchBlock.ts"],"names":[],"mappings":"AACA,IAAI,CAAC;IACJ,MAAM;AACP,CAAC;QAAS,CAAC;IACV,wBAAwB;AACzB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/noCatchBlock.sourcemap.txt b/tests/baselines/reference/noCatchBlock.sourcemap.txt index a75c119ca9..5210f12d73 100644 --- a/tests/baselines/reference/noCatchBlock.sourcemap.txt +++ b/tests/baselines/reference/noCatchBlock.sourcemap.txt @@ -12,7 +12,7 @@ sourceFile:noCatchBlock.ts 1 > 2 >^^^^ 3 > ^ -4 > ^^-> +4 > ^^^^^^-> 1 > > 2 >try @@ -21,14 +21,14 @@ sourceFile:noCatchBlock.ts 2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0) 3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0) --- ->>>// ... -1-> -2 >^^^^^^ +>>> // ... +1->^^^^ +2 > ^^^^^^ 1-> > -2 >// ... -1->Emitted(2, 1) Source(3, 2) + SourceIndex(0) -2 >Emitted(2, 7) Source(3, 8) + SourceIndex(0) +2 > // ... +1->Emitted(2, 5) Source(3, 2) + SourceIndex(0) +2 >Emitted(2, 11) Source(3, 8) + SourceIndex(0) --- >>>} 1 > @@ -43,20 +43,20 @@ sourceFile:noCatchBlock.ts >>>finally { 1->^^^^^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^-> 1-> finally 2 > { 1->Emitted(4, 9) Source(4, 11) + SourceIndex(0) 2 >Emitted(4, 10) Source(4, 12) + SourceIndex(0) --- ->>>// N.B. No 'catch' block -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^ +>>> // N.B. No 'catch' block +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > -2 >// N.B. No 'catch' block -1->Emitted(5, 1) Source(5, 2) + SourceIndex(0) -2 >Emitted(5, 25) Source(5, 26) + SourceIndex(0) +2 > // N.B. No 'catch' block +1->Emitted(5, 5) Source(5, 2) + SourceIndex(0) +2 >Emitted(5, 29) Source(5, 26) + SourceIndex(0) --- >>>} 1 > diff --git a/tests/baselines/reference/objectRestForOf.js b/tests/baselines/reference/objectRestForOf.js index 5f0399b2df..7ff72db06e 100644 --- a/tests/baselines/reference/objectRestForOf.js +++ b/tests/baselines/reference/objectRestForOf.js @@ -37,5 +37,5 @@ for (let _b of array) { } for (const norest of array.map(a => (Object.assign({}, a, { x: 'a string' })))) { [norest.x, norest.y]; -// x is now a string. who knows why. + // x is now a string. who knows why. } diff --git a/tests/baselines/reference/parserRealSource14.js b/tests/baselines/reference/parserRealSource14.js index 4e4e23e81c..635d122db0 100644 --- a/tests/baselines/reference/parserRealSource14.js +++ b/tests/baselines/reference/parserRealSource14.js @@ -1011,7 +1011,7 @@ var TypeScript; ctx.path.push(cur); } else { - //logger.log("TODO: Ignoring node because minChar, limChar not better than previous node in stack"); + //logger.log("TODO: Ignoring node because minChar, limChar not better than previous node in stack"); } } // The AST walker skips comments, but we might be in one, so check the pre/post comments for this node manually diff --git a/tests/baselines/reference/recursiveReturns.js b/tests/baselines/reference/recursiveReturns.js index 56762a9ad2..d2619e1879 100644 --- a/tests/baselines/reference/recursiveReturns.js +++ b/tests/baselines/reference/recursiveReturns.js @@ -23,7 +23,7 @@ function R1() { function R2() { R2(); } function R3(n) { if (n == 0) { - //return; + //return; } else { R3(n--); diff --git a/tests/baselines/reference/sourceMap-SkippedNode.js b/tests/baselines/reference/sourceMap-SkippedNode.js index daac27cf49..f25c0d75c8 100644 --- a/tests/baselines/reference/sourceMap-SkippedNode.js +++ b/tests/baselines/reference/sourceMap-SkippedNode.js @@ -7,9 +7,9 @@ try { //// [sourceMap-SkippedNode.js] try { -// ... + // ... } finally { -// N.B. No 'catch' block + // N.B. No 'catch' block } //# sourceMappingURL=sourceMap-SkippedNode.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-SkippedNode.js.map b/tests/baselines/reference/sourceMap-SkippedNode.js.map index b86b3905a7..f3444919d4 100644 --- a/tests/baselines/reference/sourceMap-SkippedNode.js.map +++ b/tests/baselines/reference/sourceMap-SkippedNode.js.map @@ -1,2 +1,2 @@ //// [sourceMap-SkippedNode.js.map] -{"version":3,"file":"sourceMap-SkippedNode.js","sourceRoot":"","sources":["sourceMap-SkippedNode.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC;AACL,MAAM;AACN,CAAC;QAAS,CAAC;AACX,wBAAwB;AACxB,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMap-SkippedNode.js","sourceRoot":"","sources":["sourceMap-SkippedNode.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC;IACL,MAAM;AACN,CAAC;QAAS,CAAC;IACX,wBAAwB;AACxB,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt b/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt index b48a5f09f4..c54676a697 100644 --- a/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-SkippedNode.sourcemap.txt @@ -12,7 +12,7 @@ sourceFile:sourceMap-SkippedNode.ts 1 > 2 >^^^^ 3 > ^ -4 > ^^-> +4 > ^^^^^^-> 1 > 2 >try 3 > { @@ -20,14 +20,14 @@ sourceFile:sourceMap-SkippedNode.ts 2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) 3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0) --- ->>>// ... -1-> -2 >^^^^^^ +>>> // ... +1->^^^^ +2 > ^^^^^^ 1-> > -2 >// ... -1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(2, 7) Source(2, 7) + SourceIndex(0) +2 > // ... +1->Emitted(2, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 11) Source(2, 7) + SourceIndex(0) --- >>>} 1 > @@ -42,20 +42,20 @@ sourceFile:sourceMap-SkippedNode.ts >>>finally { 1->^^^^^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^-> 1-> finally 2 > { 1->Emitted(4, 9) Source(3, 11) + SourceIndex(0) 2 >Emitted(4, 10) Source(3, 12) + SourceIndex(0) --- ->>>// N.B. No 'catch' block -1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^ +>>> // N.B. No 'catch' block +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > -2 >// N.B. No 'catch' block -1->Emitted(5, 1) Source(4, 1) + SourceIndex(0) -2 >Emitted(5, 25) Source(4, 25) + SourceIndex(0) +2 > // N.B. No 'catch' block +1->Emitted(5, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(5, 29) Source(4, 25) + SourceIndex(0) --- >>>} 1 >