reformat
diff --git a/lib/src/codegen/module_builder.dart b/lib/src/codegen/module_builder.dart index 4a3359f..66019ef 100644 --- a/lib/src/codegen/module_builder.dart +++ b/lib/src/codegen/module_builder.dart
@@ -17,7 +17,8 @@ ModuleBuilder._(this._jsPath, this._jsModuleValue, this._exportsVar); - factory ModuleBuilder(String jsPath, String _jsModuleValue, JS.Identifier _exportsVar, ModuleFormat format) { + factory ModuleBuilder(String jsPath, String _jsModuleValue, + JS.Identifier _exportsVar, ModuleFormat format) { switch (format) { case ModuleFormat.dart: return new DartModuleBuilder(jsPath, _jsModuleValue, _exportsVar); @@ -31,6 +32,7 @@ void addExport(String name) { _exports.add(name); } + void addImport(String name, JS.Identifier libVar, {bool isLazy: false}) { _imports.add(new _ModuleImport(name, libVar, isLazy)); } @@ -47,7 +49,6 @@ /// Generates modules for with DDC's `dart_library.js` loading mechanism. class DartModuleBuilder extends ModuleBuilder { - DartModuleBuilder(jsPath, _jsModuleValue, _exportsVar) : super._(jsPath, _jsModuleValue, _exportsVar); @@ -74,7 +75,8 @@ moduleStatements.add(js.comment('Exports:')); // TODO(jmesserly): make these immutable in JS? for (var name in _exports) { - moduleStatements.add(js.statement('#.# = #;', [_exportsVar, name, name])); + moduleStatements + .add(js.statement('#.# = #;', [_exportsVar, name, name])); } } @@ -98,7 +100,6 @@ /// /// TODO(ochafik): Break strong dep cycles to accommodate the Closure Compiler. class ES6ModuleBuilder extends ModuleBuilder { - ES6ModuleBuilder(jsPath, _jsModuleValue, _exportsVar) : super._(jsPath, _jsModuleValue, _exportsVar); @@ -115,8 +116,7 @@ for (var i in _imports) { // TODO(ochafik): laziness, late binding, etc, to support Closure... moduleStatements.add(new JS.ImportDeclaration( - defaultBinding: i.libVar, - from: js.string(i.name))); + defaultBinding: i.libVar, from: js.string(i.name))); } moduleStatements.addAll(_flattenBlocks(moduleItems)); @@ -125,9 +125,11 @@ moduleStatements.add(js.comment('Exports:')); // TODO(jmesserly): make these immutable in JS? for (var name in _exports) { - moduleStatements.add(js.statement('#.# = #;', [_exportsVar, name, name])); + moduleStatements + .add(js.statement('#.# = #;', [_exportsVar, name, name])); } - moduleStatements.add(new JS.ExportDeclaration(_exportsVar, isDefault: true)); + moduleStatements + .add(new JS.ExportDeclaration(_exportsVar, isDefault: true)); } // TODO(ochafik): What to do of _jsModuleValue? return moduleStatements; @@ -135,4 +137,4 @@ } Iterable<JS.ModuleItem> _flattenBlocks(List<JS.ModuleItem> stats) => - stats.expand((item) => item is JS.Block ? item.statements : [item]); + stats.expand((item) => item is JS.Block ? item.statements : [item]);
diff --git a/lib/src/options.dart b/lib/src/options.dart index d9980e8..ca6e1c7 100644 --- a/lib/src/options.dart +++ b/lib/src/options.dart
@@ -56,9 +56,7 @@ this.useImplicitHtml: false}); } -enum ModuleFormat { - es6, dart -} +enum ModuleFormat { es6, dart } ModuleFormat parseModuleFormat(String s) => ModuleFormat.values.firstWhere((v) => s == '$v'.split('.')[1]);
diff --git a/test/codegen_test.dart b/test/codegen_test.dart index 4c791d6..5f15993 100644 --- a/test/codegen_test.dart +++ b/test/codegen_test.dart
@@ -65,8 +65,10 @@ var expectDir = path.join(inputDir, 'expect'); BatchCompiler createCompiler(AnalysisContext context, - {bool checkSdk: false, bool sourceMaps: false, bool closure: false, - ModuleFormat moduleFormat: ModuleFormat.dart}) { + {bool checkSdk: false, + bool sourceMaps: false, + bool closure: false, + ModuleFormat moduleFormat: ModuleFormat.dart}) { // TODO(jmesserly): add a way to specify flags in the test file, so // they're more self-contained. var runtimeDir = path.join(path.dirname(testDirectory), 'lib', 'runtime'); @@ -149,17 +151,19 @@ // We need a more comprehensive strategy to test them. var sourceMaps = filename == 'map_keys'; var closure = filename == 'closure'; - var moduleFormat = filename == 'es6_modules' - ? ModuleFormat.es6 : ModuleFormat.dart; + var moduleFormat = + filename == 'es6_modules' ? ModuleFormat.es6 : ModuleFormat.dart; var success; // TODO(vsm): Is it okay to reuse the same context here? If there is // overlap between test files, we may need separate ones for each // compiler. - var compiler = (sourceMaps || closure || moduleFormat != ModuleFormat.dart) - ? createCompiler(realSdkContext, - sourceMaps: sourceMaps, closure: closure, - moduleFormat: moduleFormat) - : batchCompiler; + var compiler = + (sourceMaps || closure || moduleFormat != ModuleFormat.dart) + ? createCompiler(realSdkContext, + sourceMaps: sourceMaps, + closure: closure, + moduleFormat: moduleFormat) + : batchCompiler; success = compile(compiler, filePath); var outFile = new File(path.join(outDir.path, '$filename.js'));