chore(package.json): upgrade traceur to v0.0.87

Fix in source-map test to follow through the sourcemap chain.
This commit is contained in:
Caitlin Potter 2015-03-24 11:01:26 -04:00 committed by Rado Kirov
parent d304f41197
commit 9d21a6f40d
19 changed files with 52 additions and 56 deletions

View File

@ -34,13 +34,18 @@ module.exports = function atParser(AttachCommentTreeVisitor, SourceFile, Traceur
var sourceFile = new SourceFile(moduleName, fileInfo.content); var sourceFile = new SourceFile(moduleName, fileInfo.content);
var comments = []; var comments = [];
var moduleTree; var moduleTree;
var parser = new TraceurParser(sourceFile); var errorReporter = {
reportError: function(position, message) {
}
};
traceurOptions.setFromObject(service.traceurOptions);
var parser = new TraceurParser(sourceFile, errorReporter, traceurOptions);
// Configure the parser // Configure the parser
parser.handleComment = function(range) { parser.handleComment = function(range) {
comments.push({ range: range }); comments.push({ range: range });
}; };
traceurOptions.setFromObject(service.traceurOptions);
try { try {
// Parse the file as a module, attaching the comments // Parse the file as a module, attaching the comments

View File

@ -1,3 +1,4 @@
module.exports = function traceurOptions() { module.exports = function traceurOptions() {
return System.get(System.map.traceur + '/src/Options.js').options; var Options = System.get(System.map.traceur + "/src/Options.js").Options;
return new Options();
}; };

View File

@ -717,13 +717,13 @@ export class Decorator extends Directive {
compileChildren:boolean compileChildren:boolean
}={}) }={})
{ {
this.compileChildren = compileChildren;
super({ super({
selector: selector, selector: selector,
bind: bind, bind: bind,
events: events, events: events,
lifecycle: lifecycle lifecycle: lifecycle
}); });
this.compileChildren = compileChildren;
} }
} }

View File

@ -13,7 +13,6 @@ import {ListWrapper} from 'angular2/src/facade/collection';
export class For { export class For {
viewContainer: ViewContainer; viewContainer: ViewContainer;
constructor(viewContainer:ViewContainer) { constructor(viewContainer:ViewContainer) {
super();
this.viewContainer = viewContainer; this.viewContainer = viewContainer;
} }

View File

@ -22,7 +22,6 @@ export class DefaultValueAccessor {
onChange:Function; onChange:Function;
constructor(@PropertySetter('value') setValueProperty:Function) { constructor(@PropertySetter('value') setValueProperty:Function) {
super();
this._setValueProperty = setValueProperty; this._setValueProperty = setValueProperty;
this.onChange = (_) => {}; this.onChange = (_) => {};
} }
@ -44,7 +43,6 @@ export class CheckboxControlValueAccessor {
onChange:Function; onChange:Function;
constructor(cd:ControlDirective, @PropertySetter('checked') setCheckedProperty:Function) { constructor(cd:ControlDirective, @PropertySetter('checked') setCheckedProperty:Function) {
super();
this._setCheckedProperty = setCheckedProperty; this._setCheckedProperty = setCheckedProperty;
this.onChange = (_) => {}; this.onChange = (_) => {};
cd.valueAccessor = this; //ControlDirective should inject CheckboxControlDirective cd.valueAccessor = this; //ControlDirective should inject CheckboxControlDirective
@ -126,7 +124,6 @@ export class ControlGroupDirective {
_directives:List<ControlDirective>; _directives:List<ControlDirective>;
constructor(@Optional() @Ancestor() groupDirective:ControlGroupDirective) { constructor(@Optional() @Ancestor() groupDirective:ControlGroupDirective) {
super();
this._groupDirective = groupDirective; this._groupDirective = groupDirective;
this._directives = ListWrapper.create(); this._directives = ListWrapper.create();
} }

View File

@ -228,4 +228,4 @@ export class ControlArray extends AbstractControl {
this._errors = this.validator(this); this._errors = this.validator(this);
this._status = isPresent(this._errors) ? INVALID : VALID; this._status = isPresent(this._errors) ? INVALID : VALID;
} }
} }

View File

@ -415,7 +415,6 @@ class WrappedValue {
onChange:Function; onChange:Function;
constructor(cd:ControlDirective, @PropertySetter('value') setProperty:Function) { constructor(cd:ControlDirective, @PropertySetter('value') setProperty:Function) {
super();
this._setProperty = setProperty; this._setProperty = setProperty;
cd.valueAccessor = this; cd.valueAccessor = this;
} }

View File

@ -23,6 +23,7 @@ describe('sourcemaps', function () {
expect(errorLine).not.toBeNull(); expect(errorLine).not.toBeNull();
expect(errorColumn).not.toBeNull(); expect(errorColumn).not.toBeNull();
var sourceMapData = fs.readFileSync( var sourceMapData = fs.readFileSync(
'dist/js/prod/es5/examples/src/sourcemap/index.js.map'); 'dist/js/prod/es5/examples/src/sourcemap/index.js.map');
var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData)); var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData));
@ -32,9 +33,15 @@ describe('sourcemaps', function () {
column: errorColumn column: errorColumn
}); });
var finalMapData = fs.readFileSync(
'dist/js/prod/es6/examples/src/sourcemap/index.map');
var finalDecoder = new sourceMap.SourceMapConsumer(JSON.parse(finalMapData));
var finalPosition = finalDecoder.originalPositionFor(originalPosition);
var sourceCodeLines = fs.readFileSync('modules/examples/src/sourcemap/index.js', var sourceCodeLines = fs.readFileSync('modules/examples/src/sourcemap/index.js',
{encoding: 'UTF-8'}).split('\n'); {encoding: 'UTF-8'}).split('\n');
expect(sourceCodeLines[originalPosition.line - 1]) expect(sourceCodeLines[finalPosition.line - 1])
.toMatch(/throw new BaseException\(\'Sourcemap test\'\)/); .toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
}); });
}); });

View File

@ -26,8 +26,8 @@
"dependencies": { "dependencies": {
"es6-module-loader": "^0.9.2", "es6-module-loader": "^0.9.2",
"systemjs": "^0.9.1", "systemjs": "^0.9.1",
"traceur": "0.0.82",
"rx": "2.4.6", "rx": "2.4.6",
"traceur": "0.0.87",
"which": "~1", "which": "~1",
"zone.js": "0.4.0", "zone.js": "0.4.0",
"googleapis": "1.0.x", "googleapis": "1.0.x",
@ -54,7 +54,7 @@
"gulp-shell": "^0.2.10", "gulp-shell": "^0.2.10",
"gulp-sourcemaps": "1.3.*", "gulp-sourcemaps": "1.3.*",
"gulp-template": "^3.0.0", "gulp-template": "^3.0.0",
"gulp-traceur": "0.16.*", "gulp-traceur": "0.17.*",
"gulp-ts2dart": "^1.0.0", "gulp-ts2dart": "^1.0.0",
"gulp-webserver": "^0.8.7", "gulp-webserver": "^0.8.7",
"js-yaml": "^3.2.7", "js-yaml": "^3.2.7",

View File

@ -40,12 +40,9 @@ exports.compile = function compile(options, paths, source, reloadTraceur) {
moduleName = moduleName || inputPath; moduleName = moduleName || inputPath;
moduleName = moduleName.replace(/\.\w*$/, ''); moduleName = moduleName.replace(/\.\w*$/, '');
var localOptions = extend(options, {
moduleName: moduleName
});
var CompilerCls = System.get('transpiler/src/compiler').Compiler; var CompilerCls = System.get('transpiler/src/compiler').Compiler;
var compiler = new CompilerCls(localOptions); var compiler = new CompilerCls(options, moduleName);
var result = { var result = {
js: compiler.compile(source, inputPath, outputPath), js: compiler.compile(source, inputPath, outputPath),
sourceMap: null sourceMap: null
@ -56,7 +53,7 @@ exports.compile = function compile(options, paths, source, reloadTraceur) {
result.sourceMap = JSON.parse(sourceMapString); result.sourceMap = JSON.parse(sourceMapString);
} }
if (localOptions.outputLanguage === 'es6' && source.indexOf('$traceurRuntime') === -1) { if (options.outputLanguage === 'es6' && source.indexOf('$traceurRuntime') === -1) {
assert(result.js.indexOf('$traceurRuntime') === -1, assert(result.js.indexOf('$traceurRuntime') === -1,
'Transpile to ES6 must not add references to $traceurRuntime, ' 'Transpile to ES6 must not add references to $traceurRuntime, '
+ inputPath + ' is transpiled to:\n' + result.js); + inputPath + ' is transpiled to:\n' + result.js);
@ -94,7 +91,6 @@ function reloadCompiler(reloadTraceur) {
useRttsAssertModuleForConvertingTypesToExpressions(); useRttsAssertModuleForConvertingTypesToExpressions();
supportSuperCallsInEs6Patch(); supportSuperCallsInEs6Patch();
convertTypesToExpressionsInEs6Patch(); convertTypesToExpressionsInEs6Patch();
removeNonStaticFieldDeclarationsInEs6Patch();
disableGetterSetterAssertionPatch(); disableGetterSetterAssertionPatch();
patchCommonJSModuleTransformerToSupportExportStar(); patchCommonJSModuleTransformerToSupportExportStar();
} }
@ -111,9 +107,7 @@ function loadModule(filepath, transpile) {
.replace(__dirname, 'transpiler') .replace(__dirname, 'transpiler')
.replace(/\\/g, '/') .replace(/\\/g, '/')
.replace(/\.\w*$/, ''); .replace(/\.\w*$/, '');
data = (new traceur.NodeCompiler( data = traceur.compile(data, SELF_COMPILE_OPTIONS, moduleName);
extend(SELF_COMPILE_OPTIONS, { moduleName: moduleName } )
)).compile(data, filepath, filepath);
} }
('global', eval)(data); ('global', eval)(data);
@ -157,30 +151,15 @@ function convertTypesToExpressionsInEs6Patch() {
PureES6Transformer.prototype.transform = function() { PureES6Transformer.prototype.transform = function() {
if (!this._patched) { if (!this._patched) {
this._patched = true; this._patched = true;
var self = this;
this.treeTransformers_.splice(0,0, function(tree) { this.treeTransformers_.splice(0,0, function(tree) {
return new TypeToExpressionTransformer(new UniqueIdentifierGenerator(), this.reporter_).transformAny(tree); return new TypeToExpressionTransformer(new UniqueIdentifierGenerator(), self.reporter_, self.options_).transformAny(tree);
}); });
} }
return _transform.apply(this, arguments); return _transform.apply(this, arguments);
}; };
} }
// TODO(tbosch): Don't write field declarations in classes when we output to ES6.
// This just patches the writer and does not support moving initializers to the constructor.
// See src/codegeneration/ClassTransformer.js for how to support initializers as well.
// see https://github.com/google/traceur-compiler/issues/1708
function removeNonStaticFieldDeclarationsInEs6Patch() {
var traceurVersion = System.map['traceur'];
var ParseTreeWriter = System.get(traceurVersion+'/src/outputgeneration/ParseTreeWriter').ParseTreeWriter;
var options = System.get(traceurVersion + "/src/Options.js").options;
var _visitPropertyVariableDeclaration = ParseTreeWriter.prototype.visitPropertyVariableDeclaration;
ParseTreeWriter.prototype.visitPropertyVariableDeclaration = function() {
if (options.outputLanguage !== 'es6') {
return _visitPropertyVariableDeclaration.apply(this, arguments);
}
};
}
// TODO(tbosch): Disable getter/setters for assertions until traceur has a flag // TODO(tbosch): Disable getter/setters for assertions until traceur has a flag
// that allows to disable them while keeping assertions and member fields enabled. // that allows to disable them while keeping assertions and member fields enabled.
// see https://github.com/google/traceur-compiler/issues/1625 // see https://github.com/google/traceur-compiler/issues/1625

View File

@ -19,8 +19,8 @@ class SubFoo extends Foo {
c; c;
constructor(a, b) { constructor(a, b) {
this.c = 3;
super(a, b); super(a, b);
this.c = 3;
} }
} }

View File

@ -38,6 +38,7 @@ import {
*/ */
export class ClassTransformer extends ParseTreeTransformer { export class ClassTransformer extends ParseTreeTransformer {
constructor(idGenerator, reporter) { constructor(idGenerator, reporter) {
super(idGenerator);
this.reporter_ = reporter; this.reporter_ = reporter;
} }

View File

@ -16,8 +16,9 @@ import {DestructuringTransformer} from './DestructuringTransformer';
* Transforms ES6 + annotations to Dart code. * Transforms ES6 + annotations to Dart code.
*/ */
export class DartTransformer extends MultiTransformer { export class DartTransformer extends MultiTransformer {
constructor(reporter, idGenerator = new UniqueIdentifierGenerator()) { constructor(reporter, options) {
super(reporter, options.validate); super(reporter, options.validate);
let idGenerator = new UniqueIdentifierGenerator();
var append = (transformer) => { var append = (transformer) => {
this.append((tree) => { this.append((tree) => {

View File

@ -51,6 +51,7 @@ function getIndexOfFirstNonImportStatement(items) {
*/ */
export class ExportTransformer extends ParseTreeTransformer { export class ExportTransformer extends ParseTreeTransformer {
constructor(idGenerator, reporter) { constructor(idGenerator, reporter) {
super(idGenerator);
this.reporter_ = reporter; this.reporter_ = reporter;
this.importedVars_ = null; this.importedVars_ = null;
this.collectedExports_ = null; this.collectedExports_ = null;

View File

@ -4,20 +4,19 @@ import {DartParseTreeWriter} from './outputgeneration/DartParseTreeWriter';
import {CollectingErrorReporter} from 'traceur/src/util/CollectingErrorReporter'; import {CollectingErrorReporter} from 'traceur/src/util/CollectingErrorReporter';
import {Parser} from './parser'; import {Parser} from './parser';
import {SourceFile} from 'traceur/src/syntax/SourceFile'; import {SourceFile} from 'traceur/src/syntax/SourceFile';
import { import {Options} from 'traceur/src/Options';
options as traceurOptions
} from 'traceur/src/Options';
export class Compiler extends TraceurCompiler { export class Compiler extends TraceurCompiler {
constructor(options, sourceRoot) { constructor(options, sourceRoot) {
super(options, sourceRoot); super(options, sourceRoot);
this.moduleName_ = sourceRoot;
} }
transform(tree, moduleName = undefined) { transform(tree, moduleName = undefined) {
if (this.options_.outputLanguage.toLowerCase() === 'dart') { if (this.options_.outputLanguage.toLowerCase() === 'dart') {
var errorReporter = new CollectingErrorReporter(); var errorReporter = new CollectingErrorReporter();
var transformer = new DartTransformer(errorReporter); var transformer = new DartTransformer(errorReporter, this.options_);
var transformedTree = transformer.transform(tree); var transformedTree = transformer.transform(tree);
this.throwIfErrors(errorReporter); this.throwIfErrors(errorReporter);
return transformedTree; return transformedTree;
@ -28,7 +27,7 @@ export class Compiler extends TraceurCompiler {
write(tree, outputName = undefined, sourceRoot = undefined) { write(tree, outputName = undefined, sourceRoot = undefined) {
if (this.options_.outputLanguage.toLowerCase() === 'dart') { if (this.options_.outputLanguage.toLowerCase() === 'dart') {
var writer = new DartParseTreeWriter(this.options_.moduleName, outputName); var writer = new DartParseTreeWriter(this.moduleName_, outputName);
writer.visitAny(tree); writer.visitAny(tree);
return writer.toString(); return writer.toString();
} else { } else {
@ -45,13 +44,14 @@ export class Compiler extends TraceurCompiler {
} }
this.sourceMapGenerator_ = null; this.sourceMapGenerator_ = null;
var traceurOptions = new Options();
// Here we mutate the global/module options object to be used in parsing. // Here we mutate the global/module options object to be used in parsing.
traceurOptions.setFromObject(this.options_); traceurOptions.setFromObject(this.options_);
var errorReporter = new CollectingErrorReporter(); var errorReporter = new CollectingErrorReporter();
sourceName = this.sourceName(sourceName); sourceName = this.sourceName(sourceName);
var sourceFile = new SourceFile(sourceName, content); var sourceFile = new SourceFile(sourceName, content);
var parser = new Parser(sourceFile, errorReporter); var parser = new Parser(sourceFile, errorReporter, this.options_);
var tree = var tree =
this.options_.script ? parser.parseScript() : parser.parseModule(); this.options_.script ? parser.parseScript() : parser.parseModule();
this.throwIfErrors(errorReporter); this.throwIfErrors(errorReporter);

View File

@ -4,8 +4,8 @@ import {TypeName, ImportSpecifier, ImportedBinding, BindingIdentifier} from 'tra
import {PERIOD, IMPORT, STAR, AS, FROM, CLOSE_ANGLE, OPEN_ANGLE, COMMA, OPEN_CURLY, CLOSE_CURLY, COLON} from 'traceur/src/syntax/TokenType'; import {PERIOD, IMPORT, STAR, AS, FROM, CLOSE_ANGLE, OPEN_ANGLE, COMMA, OPEN_CURLY, CLOSE_CURLY, COLON} from 'traceur/src/syntax/TokenType';
export class Parser extends TraceurParser { export class Parser extends TraceurParser {
constructor(file, errorReporter = new SyntaxErrorReporter()) { constructor(file, errorReporter = new SyntaxErrorReporter(), options) {
super(file, errorReporter); super(file, errorReporter, options);
} }
// TODO: add support for object type literals to traceur! // TODO: add support for object type literals to traceur!

View File

@ -16,6 +16,10 @@ import {
} from 'traceur/src/codegeneration/PlaceholderParser.js'; } from 'traceur/src/codegeneration/PlaceholderParser.js';
export class TypeToExpressionTransformer extends ParseTreeTransformer { export class TypeToExpressionTransformer extends ParseTreeTransformer {
constructor(idGenerator, reporter, options) {
super(idGenerator, reporter);
this.options_ = options;
}
transformTypeName(tree) { transformTypeName(tree) {
if (tree.moduleName) { if (tree.moduleName) {

View File

@ -63,7 +63,7 @@ export class NamedParameterList extends ParseTree {
* @param {Array.<ParseTree>} parameterNameAndValues * @param {Array.<ParseTree>} parameterNameAndValues
*/ */
constructor(location, parameterNameAndValues) { constructor(location, parameterNameAndValues) {
this.location = location; super(location);
this.parameterNameAndValues = parameterNameAndValues; this.parameterNameAndValues = parameterNameAndValues;
} }
@ -105,7 +105,7 @@ export class ObjectPatternBindingElement extends ParseTree {
* @param {ParseTree} initializer * @param {ParseTree} initializer
*/ */
constructor(location, binding, initializer) { constructor(location, binding, initializer) {
this.location = location; super(location);
this.binding = binding; this.binding = binding;
this.initializer = initializer; this.initializer = initializer;
} }
@ -144,7 +144,7 @@ export class ImplementsDeclaration extends ParseTree {
* @param {Array.<ParseTree>} interfaces * @param {Array.<ParseTree>} interfaces
*/ */
constructor(location, interfaces) { constructor(location, interfaces) {
this.location = location; super(location);
this.interfaces = interfaces; this.interfaces = interfaces;
} }

View File

@ -111,15 +111,17 @@ describe('transpile to es6', function() {
it('should allow super() calls when transpiling to ES6 with source maps', function() { it('should allow super() calls when transpiling to ES6 with source maps', function() {
options = merge(options, {sourceMaps: true}); options = merge(options, {sourceMaps: true});
var result = compiler.compile(options, "test.js", var result = compiler.compile(options, "test.js",
"class Test {" + "class Base {}\n" +
"class Test extends Base {" +
" constructor() { super(); }" + " constructor() { super(); }" +
"}"); "}");
expect(result.js).toBe("class Test {\n" + expect(result.js).toBe("class Base {}\n" +
"class Test extends Base {\n" +
" constructor() {\n"+ " constructor() {\n"+
" super();\n"+ " super();\n"+
" }\n"+ " }\n"+
"}\n\n"+ "}\n"+
"//# sourceMappingURL=test.map\n"); "//# sourceMappingURL=test.js.map\n");
}); });
it('should convert types to expressions', function() { it('should convert types to expressions', function() {