Emit comments for if statement

This commit is contained in:
Sheetal Nandi 2014-08-15 15:32:43 -07:00
parent 6036c92784
commit 0a75cc2926
6 changed files with 5 additions and 5 deletions

View file

@ -924,10 +924,6 @@ module ts {
} }
function emitIfStatement(node: IfStatement) { function emitIfStatement(node: IfStatement) {
// emit comments only if this is not else if statement as else if will take care of emitting the leading/trailing comments
if (node.parent.kind !== SyntaxKind.IfStatement || (<IfStatement>node.parent).elseStatement !== node) {
emitLeadingComments(node);
}
emitLeadingComments(node); emitLeadingComments(node);
var endPos = emitToken(SyntaxKind.IfKeyword, node.pos); var endPos = emitToken(SyntaxKind.IfKeyword, node.pos);
write(" "); write(" ");
@ -937,7 +933,6 @@ module ts {
emitEmbeddedStatement(node.thenStatement); emitEmbeddedStatement(node.thenStatement);
if (node.elseStatement) { if (node.elseStatement) {
writeLine(); writeLine();
emitLeadingComments(node.elseStatement);
emitToken(SyntaxKind.ElseKeyword, node.thenStatement.end); emitToken(SyntaxKind.ElseKeyword, node.thenStatement.end);
if (node.elseStatement.kind === SyntaxKind.IfStatement) { if (node.elseStatement.kind === SyntaxKind.IfStatement) {
write(" "); write(" ");

View file

@ -5,5 +5,6 @@ if (true) {
} }
//// [commentOnIfStatement1.js] //// [commentOnIfStatement1.js]
// Test
if (true) { if (true) {
} }

View file

@ -218,6 +218,7 @@ var N;
} }
N.F2 = F2; N.F2 = F2;
})(N || (N = {})); })(N || (N = {}));
// literals
if (true) { if (true) {
} }
while (true) { while (true) {

View file

@ -20,6 +20,7 @@ var foo;
})(foo || (foo = {})); })(foo || (foo = {}));
//// [foo_1.js] //// [foo_1.js]
define(["require", "exports", "./foo_0"], function (require, exports, foo) { define(["require", "exports", "./foo_0"], function (require, exports, foo) {
// Import should fail. foo_0 not an external module
if (foo.answer === 42) { if (foo.answer === 42) {
} }
}); });

View file

@ -19,5 +19,6 @@ var s = (null);
var b = (n); var b = (n);
function isVoid() { function isVoid() {
} }
// Expected error: Values of type null and void cannot be compared
if (null === isVoid()) { if (null === isVoid()) {
} }

View file

@ -12,5 +12,6 @@ if (!null !== true) {
//// [voidAsOperator.js] //// [voidAsOperator.js]
if (!void 0 !== true) { if (!void 0 !== true) {
} }
//CHECK#2
if (!null !== true) { if (!null !== true) {
} }