feat(DartWriter): support string interpolation

This commit is contained in:
Chirayu Krishnappa 2014-10-01 16:56:44 -07:00
parent c85ab3a5a4
commit c7feaba1cb
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,9 @@
import {describe, it, expect} from 'test_lib/test_lib';
export function main() {
describe('lang', function() {
it('string interpolation', function() {
expect(`${123}-'${456}"`).toEqual('123-\'456"');
});
});
}

View File

@ -1,5 +1,6 @@
import {CONSTRUCTOR, FROM} from 'traceur/src/syntax/PredefinedName';
import {EQUAL_EQUAL_EQUAL, OPEN_PAREN, CLOSE_PAREN, IMPORT, SEMI_COLON, STAR, OPEN_CURLY, CLOSE_CURLY, COMMA, AT, EQUAL} from 'traceur/src/syntax/TokenType';
import {EQUAL_EQUAL_EQUAL, OPEN_PAREN, CLOSE_PAREN, IMPORT, SEMI_COLON, STAR, OPEN_CURLY, CLOSE_CURLY, COMMA, AT,
EQUAL, SINGLE_QUOTE} from 'traceur/src/syntax/TokenType';
import {ParseTreeWriter as JavaScriptParseTreeWriter} from 'traceur/src/outputgeneration/ParseTreeWriter';
@ -37,6 +38,17 @@ export class DartTreeWriter extends JavaScriptParseTreeWriter {
}
}
visitTemplateLiteralExpression(tree) {
if (tree.operand) {
this.visitAny(tree.operand);
this.writeSpace_();
}
this.writeRaw_(SINGLE_QUOTE);
this.visitList(tree.elements);
this.writeRaw_(SINGLE_QUOTE);
}
// FUNCTIONS
// - remove the "function" keyword
// - type annotation infront