diff --git a/modules/angular2/globals.dart b/modules/angular2/globals.dart index 225a45bff6..f82dcc2f5d 100644 --- a/modules/angular2/globals.dart +++ b/modules/angular2/globals.dart @@ -1,3 +1,3 @@ // Globals are provided by lang.dart in Dart. // This file exists to prevent global.ts from being transpiled. -library angular2.globals; +library angular2.globals; diff --git a/modules/angular2/src/change_detection/change_detection_jit_generator.dart b/modules/angular2/src/change_detection/change_detection_jit_generator.dart index 6dbc791f0f..4147fda658 100644 --- a/modules/angular2/src/change_detection/change_detection_jit_generator.dart +++ b/modules/angular2/src/change_detection/change_detection_jit_generator.dart @@ -1,10 +1,9 @@ library change_detectoin.change_detection_jit_generator; class ChangeDetectorJITGenerator { - ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) { - } + ChangeDetectorJITGenerator(typeName, strategy, records, directiveMementos) {} generate() { throw "Jit Change Detection is not supported in Dart"; } -} \ No newline at end of file +} diff --git a/modules/angular2/src/core/compiler/base_query_list.dart b/modules/angular2/src/core/compiler/base_query_list.dart index 71b01849ce..a8084da2ba 100644 --- a/modules/angular2/src/core/compiler/base_query_list.dart +++ b/modules/angular2/src/core/compiler/base_query_list.dart @@ -15,7 +15,10 @@ class BaseQueryList extends Object with IterableMixin { List _callbacks; bool _dirty; - BaseQueryList(): _results = [], _callbacks = [], _dirty = false; + BaseQueryList() + : _results = [], + _callbacks = [], + _dirty = false; Iterator get iterator => _results.iterator; diff --git a/modules/angular2/src/core/testability/get_testability.dart b/modules/angular2/src/core/testability/get_testability.dart index 9ea1fae5ce..b94dd223b0 100644 --- a/modules/angular2/src/core/testability/get_testability.dart +++ b/modules/angular2/src/core/testability/get_testability.dart @@ -10,16 +10,14 @@ import 'dart:js' as js; // Proxies a Dart function that accepts up to 10 parameters. js.JsFunction _jsFunction(Function fn) { const Object X = __varargSentinel; - return new js.JsFunction.withThis( - (thisArg, [o1=X, o2=X, o3=X, o4=X, o5=X, o6=X, o7=X, o8=X, o9=X, o10=X]) { - return __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10); - }); + return new js.JsFunction.withThis((thisArg, [o1 = X, o2 = X, o3 = X, o4 = X, + o5 = X, o6 = X, o7 = X, o8 = X, o9 = X, o10 = X]) { + return __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10); + }); } - const Object __varargSentinel = const Object(); - __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) { var args = [o1, o2, o3, o4, o5, o6, o7, o8, o9, o10]; while (args.length > 0 && identical(args.last, __varargSentinel)) { @@ -28,7 +26,6 @@ __invokeFn(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) { return _jsify(Function.apply(fn, args)); } - // Helper function to JSify a Dart object. While this is *required* to JSify // the result of a scope.eval(), other uses are not required and are used to // work around http://dartbug.com/17752 in a convenient way (that bug affects @@ -44,8 +41,9 @@ _jsify(var obj) { return _jsFunction(obj); } if ((obj is Map) || (obj is Iterable)) { - var mappedObj = (obj is Map) ? - new Map.fromIterables(obj.keys, obj.values.map(_jsify)) : obj.map(_jsify); + var mappedObj = (obj is Map) + ? new Map.fromIterables(obj.keys, obj.values.map(_jsify)) + : obj.map(_jsify); if (obj is List) { return new js.JsArray.from(mappedObj); } else { @@ -75,10 +73,9 @@ class PublicTestability implements _JsObjectProxyable { js.JsObject _toJsObject() { return _jsify({ - 'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) => - findBindings(bindingString, exactMatch, allowNonElementNodes), - 'whenStable': (callback) => - whenStable(() => callback.apply([])), + 'findBindings': (bindingString, [exactMatch, allowNonElementNodes]) => + findBindings(bindingString, exactMatch, allowNonElementNodes), + 'whenStable': (callback) => whenStable(() => callback.apply([])), })..['_dart_'] = this; } } @@ -86,8 +83,8 @@ class PublicTestability implements _JsObjectProxyable { class GetTestability { static addToWindow(TestabilityRegistry registry) { js.context['getAngularTestability'] = _jsify((Element elem) { - Testability testability = registry.findTestabilityInTree(elem); - return _jsify(new PublicTestability(testability)); - }); + Testability testability = registry.findTestabilityInTree(elem); + return _jsify(new PublicTestability(testability)); + }); } } diff --git a/modules/angular2/src/core/zone/vm_turn_zone.dart b/modules/angular2/src/core/zone/vm_turn_zone.dart index ee8d6f6fdd..a1c787fb4e 100644 --- a/modules/angular2/src/core/zone/vm_turn_zone.dart +++ b/modules/angular2/src/core/zone/vm_turn_zone.dart @@ -52,7 +52,8 @@ class VmTurnZone { * @param {Function} onScheduleMicrotask * @param {Function} onErrorHandler called when an exception is thrown by a macro or micro task */ - initCallbacks({Function onTurnStart, Function onTurnDone, Function onScheduleMicrotask, Function onErrorHandler}) { + initCallbacks({Function onTurnStart, Function onTurnDone, + Function onScheduleMicrotask, Function onErrorHandler}) { this._onTurnStart = onTurnStart; this._onTurnDone = onTurnDone; this._onScheduleMicrotask = onScheduleMicrotask; @@ -111,17 +112,19 @@ class VmTurnZone { } async.Zone _createInnerZone(async.Zone zone) { - return zone.fork(specification: new async.ZoneSpecification( - run: _onRun, - runUnary: _onRunUnary, - scheduleMicrotask: _onMicrotask - )); + return zone.fork( + specification: new async.ZoneSpecification( + run: _onRun, + runUnary: _onRunUnary, + scheduleMicrotask: _onMicrotask)); } - dynamic _onRunBase(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) { + dynamic _onRunBase( + async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) { _nestedRunCounter++; try { - if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run(zone, _onTurnStart); + if (_nestedRunCounter == 1 && _onTurnStart != null) delegate.run( + zone, _onTurnStart); return fn(); } catch (e, s) { if (_onErrorHandler != null && _nestedRunCounter == 1) { @@ -131,21 +134,24 @@ class VmTurnZone { } } finally { _nestedRunCounter--; - if (_nestedRunCounter == 0 && _onTurnDone != null) _finishTurn(zone, delegate); + if (_nestedRunCounter == 0 && _onTurnDone != null) _finishTurn( + zone, delegate); } } - dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn()) => - _onRunBase(self, delegate, zone, () => delegate.run(zone, fn)); + dynamic _onRun(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, + fn()) => _onRunBase(self, delegate, zone, () => delegate.run(zone, fn)); - dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn(args), args) => + dynamic _onRunUnary(async.Zone self, async.ZoneDelegate delegate, + async.Zone zone, fn(args), args) => _onRunBase(self, delegate, zone, () => delegate.runUnary(zone, fn, args)); void _finishTurn(zone, delegate) { delegate.run(zone, _onTurnDone); } - _onMicrotask(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn) { + _onMicrotask( + async.Zone self, async.ZoneDelegate delegate, async.Zone zone, fn) { if (this._onScheduleMicrotask != null) { _onScheduleMicrotask(fn); } else { diff --git a/modules/angular2/src/di/decorators.dart b/modules/angular2/src/di/decorators.dart index d4f3a4b5d1..ef271560c2 100644 --- a/modules/angular2/src/di/decorators.dart +++ b/modules/angular2/src/di/decorators.dart @@ -2,4 +2,4 @@ library angular2.di.decorators; /* This file is empty because, Dart does not have decorators. */ -export 'annotations.dart'; \ No newline at end of file +export 'annotations.dart'; diff --git a/modules/angular2/src/facade/async.dart b/modules/angular2/src/facade/async.dart index 5b35448966..f30ac08902 100644 --- a/modules/angular2/src/facade/async.dart +++ b/modules/angular2/src/facade/async.dart @@ -33,8 +33,10 @@ class PromiseWrapper { } class ObservableWrapper { - static StreamSubscription subscribe(Stream s, Function onNext, [onError, onComplete]) { - return s.listen(onNext, onError: onError, onDone: onComplete, cancelOnError: true); + static StreamSubscription subscribe(Stream s, Function onNext, + [onError, onComplete]) { + return s.listen(onNext, + onError: onError, onDone: onComplete, cancelOnError: true); } static bool isObservable(obs) { @@ -65,14 +67,10 @@ class EventEmitter extends Stream { _controller = new StreamController.broadcast(); } - StreamSubscription listen(void onData(String line), { - void onError(Error error), - void onDone(), - bool cancelOnError }) { + StreamSubscription listen(void onData(String line), + {void onError(Error error), void onDone(), bool cancelOnError}) { return _controller.stream.listen(onData, - onError: onError, - onDone: onDone, - cancelOnError: cancelOnError); + onError: onError, onDone: onDone, cancelOnError: cancelOnError); } void add(value) { @@ -88,7 +86,6 @@ class EventEmitter extends Stream { } } - class _Completer { final Completer c; diff --git a/modules/angular2/src/facade/browser.dart b/modules/angular2/src/facade/browser.dart index f389e2fe34..05ff40ef66 100644 --- a/modules/angular2/src/facade/browser.dart +++ b/modules/angular2/src/facade/browser.dart @@ -6,15 +6,16 @@ library angular2.src.facade.browser; import 'dart:js' show context; -export 'dart:html' show - document, - location, - window, - Element, - Node, - MouseEvent, - KeyboardEvent, - Event; +export 'dart:html' + show + document, + location, + window, + Element, + Node, + MouseEvent, + KeyboardEvent, + Event; final _gc = context['gc']; diff --git a/modules/angular2/src/facade/collection.dart b/modules/angular2/src/facade/collection.dart index 92236bd658..f32c8bc593 100644 --- a/modules/angular2/src/facade/collection.dart +++ b/modules/angular2/src/facade/collection.dart @@ -70,7 +70,7 @@ class StringMapWrapper { map[key] = value; } static void delete(Map m, k) { - m.remove(k); + m.remove(k); } static void forEach(Map m, fn(v, k)) { m.forEach((k, v) => fn(v, k)); @@ -96,7 +96,8 @@ class ListWrapper { static bool contains(List m, k) => m.contains(k); static List map(list, fn(item)) => list.map(fn).toList(); static List filter(List list, bool fn(item)) => list.where(fn).toList(); - static int indexOf(List list, value, [int startIndex = 0]) => list.indexOf(value, startIndex); + static int indexOf(List list, value, [int startIndex = 0]) => + list.indexOf(value, startIndex); static int lastIndexOf(List list, value, [int startIndex = null]) => list.lastIndexOf(value, startIndex == null ? list.length : startIndex); static find(List list, bool fn(item)) => @@ -115,7 +116,9 @@ class ListWrapper { l.add(e); } static List concat(List a, List b) { - return []..addAll(a)..addAll(b); + return [] + ..addAll(a) + ..addAll(b); } static bool isList(l) => l is List; static void insert(List l, int index, value) { @@ -154,7 +157,7 @@ class ListWrapper { l.removeRange(from, to); return sub; } - static void sort(List l, compareFn(a,b)) { + static void sort(List l, compareFn(a, b)) { l.sort(compareFn); } diff --git a/modules/angular2/src/facade/lang.dart b/modules/angular2/src/facade/lang.dart index 288157ac99..a797945ca4 100644 --- a/modules/angular2/src/facade/lang.dart +++ b/modules/angular2/src/facade/lang.dart @@ -123,7 +123,8 @@ class RegExpWrapper { static RegExp create(regExpStr, [String flags = '']) { bool multiLine = flags.contains('m'); bool caseSensitive = !flags.contains('i'); - return new RegExp(regExpStr, multiLine: multiLine, caseSensitive: caseSensitive); + return new RegExp(regExpStr, + multiLine: multiLine, caseSensitive: caseSensitive); } static Match firstMatch(RegExp regExp, String input) { return regExp.firstMatch(input); @@ -147,7 +148,7 @@ class _JSLikeMatch { _JSLikeMatch(this._m); - String operator[](index) => _m[index]; + String operator [](index) => _m[index]; int get index => _m.start; int get length => _m.groupCount + 1; } diff --git a/modules/angular2/src/render/dom/events/hammer_gestures.dart b/modules/angular2/src/render/dom/events/hammer_gestures.dart index 3dcab94e4c..b66f700606 100644 --- a/modules/angular2/src/render/dom/events/hammer_gestures.dart +++ b/modules/angular2/src/render/dom/events/hammer_gestures.dart @@ -11,14 +11,17 @@ class HammerGesturesPlugin extends HammerGesturesPluginCommon { if (!super.supports(eventName)) return false; if (!js.context.hasProperty('Hammer')) { - throw new BaseException('Hammer.js is not loaded, can not bind ${eventName} event'); + throw new BaseException( + 'Hammer.js is not loaded, can not bind ${eventName} event'); } return true; } - addEventListener(Element element, String eventName, Function handler, bool shouldSupportBubble) { - if (shouldSupportBubble) throw new BaseException('Hammer.js plugin does not support bubbling gestures.'); + addEventListener(Element element, String eventName, Function handler, + bool shouldSupportBubble) { + if (shouldSupportBubble) throw new BaseException( + 'Hammer.js plugin does not support bubbling gestures.'); var zone = this.manager.getZone(); eventName = eventName.toLowerCase(); diff --git a/modules/angular2/src/services/xhr_impl.dart b/modules/angular2/src/services/xhr_impl.dart index 2997d71cc9..b5feb06b75 100644 --- a/modules/angular2/src/services/xhr_impl.dart +++ b/modules/angular2/src/services/xhr_impl.dart @@ -1,4 +1,4 @@ -library angular2.src.services.xhr_impl; +library angular2.src.services.xhr_impl; import 'dart:async'; import 'dart:html'; @@ -9,8 +9,7 @@ import './xhr.dart' show XHR; class XHRImpl extends XHR { Future get(String url) { return HttpRequest.request(url).then( - (HttpRequest request) => request.responseText, - onError: (Error e) => throw 'Failed to load $url' - ); + (HttpRequest request) => request.responseText, + onError: (Error e) => throw 'Failed to load $url'); } } diff --git a/modules/angular2/src/test_lib/test_lib.dart b/modules/angular2/src/test_lib/test_lib.dart index 68fd1bfa08..889508f652 100644 --- a/modules/angular2/src/test_lib/test_lib.dart +++ b/modules/angular2/src/test_lib/test_lib.dart @@ -1,7 +1,8 @@ library test_lib.test_lib; import 'package:guinness/guinness.dart' as gns; -export 'package:guinness/guinness.dart' hide Expect, expect, NotExpect, beforeEach, it, iit, xit; +export 'package:guinness/guinness.dart' + hide Expect, expect, NotExpect, beforeEach, it, iit, xit; import 'package:unittest/unittest.dart' hide expect; import 'dart:async'; @@ -42,12 +43,9 @@ void testSetup() { // - Priority 2: collect the bindings before each test, see beforeEachBindings(), // - Priority 1: create the test injector to be used in beforeEach() and it() - gns.beforeEach( - () { - _testBindings.clear(); - }, - priority: 3 - ); + gns.beforeEach(() { + _testBindings.clear(); + }, priority: 3); var completerBinding = bind(AsyncTestCompleter).toFactory(() { // Mark the test as async when an AsyncTestCompleter is injected in an it(), @@ -56,14 +54,11 @@ void testSetup() { return new AsyncTestCompleter(); }); - gns.beforeEach( - () { - _isCurrentTestAsync = false; - _testBindings.add(completerBinding); - _injector = createTestInjector(_testBindings); - }, - priority: 1 - ); + gns.beforeEach(() { + _isCurrentTestAsync = false; + _testBindings.add(completerBinding); + _injector = createTestInjector(_testBindings); + }, priority: 1); } Expect expect(actual, [matcher]) { @@ -80,13 +75,14 @@ class Expect extends gns.Expect { NotExpect get not => new NotExpect(actual); void toEqual(expected) => toHaveSameProps(expected); - void toThrowError([message=""]) => toThrowWith(message: message); + void toThrowError([message = ""]) => toThrowWith(message: message); void toBePromise() => _expect(actual is Future, equals(true)); void toImplement(expected) => toBeA(expected); void toBeNaN() => _expect(double.NAN.compareTo(actual) == 0, equals(true)); void toHaveText(expected) => _expect(elementText(actual), expected); void toHaveBeenCalledWith([a = _u, b = _u, c = _u, d = _u, e = _u, f = _u]) => - _expect(_argsMatch(actual, a, b, c, d, e, f), true, reason: 'method invoked with correct arguments'); + _expect(_argsMatch(actual, a, b, c, d, e, f), true, + reason: 'method invoked with correct arguments'); Function get _expect => gns.guinness.matchers.expect; // TODO(tbosch): move this hack into Guinness @@ -97,7 +93,7 @@ class Expect extends gns.Expect { return false; } else { gns.SamePropsMatcher matcher = new gns.SamePropsMatcher(toMatch); - for (var i=0; i Actual: '. // For hacking this is good: @@ -141,13 +137,10 @@ void beforeEach(fn) { * ]); */ void beforeEachBindings(Function fn) { - gns.beforeEach( - () { - var bindings = fn(); - if (bindings != null) _testBindings.addAll(bindings); - }, - priority: 2 - ); + gns.beforeEach(() { + var bindings = fn(); + if (bindings != null) _testBindings.addAll(bindings); + }, priority: 2); } void _it(gnsFn, name, fn) { @@ -160,7 +153,6 @@ void _it(gnsFn, name, fn) { }); } - void it(name, fn) { _it(gns.it, name, fn); } @@ -174,7 +166,7 @@ void xit(name, fn) { } class SpyFunction extends gns.SpyFunction { - SpyFunction(String name): super(name); + SpyFunction(String name) : super(name); // TODO: vsavkin move to guinness andReturn(value) { @@ -185,10 +177,10 @@ class SpyFunction extends gns.SpyFunction { class SpyObject extends gns.SpyObject { final Map _spyFuncs = {}; - SpyObject([arg]){} + SpyObject([arg]) {} SpyFunction spy(String funcName) => - _spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName)); + _spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName)); static stub([object = null, config = null, overrides = null]) { if (object is! SpyObject) { @@ -198,15 +190,13 @@ class SpyObject extends gns.SpyObject { } var m = StringMapWrapper.merge(config, overrides); - StringMapWrapper.forEach(m, (value, key){ + StringMapWrapper.forEach(m, (value, key) { object.spy(key).andReturn(value); }); return object; } } - - String elementText(n) { hasNodes(n) { var children = DOM.childNodes(n); diff --git a/modules/angular2/src/util/decorators.dart b/modules/angular2/src/util/decorators.dart index 82699d8dc3..e26022dc05 100644 --- a/modules/angular2/src/util/decorators.dart +++ b/modules/angular2/src/util/decorators.dart @@ -1 +1 @@ -library util_decorators; \ No newline at end of file +library util_decorators; diff --git a/modules/angular2/test/services/rectangle_mock.dart b/modules/angular2/test/services/rectangle_mock.dart index fca577c569..62356a364b 100644 --- a/modules/angular2/test/services/rectangle_mock.dart +++ b/modules/angular2/test/services/rectangle_mock.dart @@ -3,4 +3,3 @@ import 'dart:html'; Rectangle createRectangle(left, top, width, height) { return new Rectangle(left, top, width, height); } - diff --git a/modules/benchmarks_external/src/compiler/compiler_benchmark.dart b/modules/benchmarks_external/src/compiler/compiler_benchmark.dart index e8b1fab154..5fd61ba6cf 100644 --- a/modules/benchmarks_external/src/compiler/compiler_benchmark.dart +++ b/modules/benchmarks_external/src/compiler/compiler_benchmark.dart @@ -7,7 +7,6 @@ import 'dart:html'; import 'package:angular2/src/test_lib/benchmark_util.dart'; main() { - var count = getIntParameter('elements'); var m = new Module() @@ -36,13 +35,12 @@ main() { bindAction('#compileWithBindings', compileWithBindings); bindAction('#compileNoBindings', compileNoBindings); - } loadTemplate(templateId, repeatCount) { String result = ''; var content = document.querySelector("#${templateId}").innerHtml; - for (var i=0; iprop' - } -) +@Directive(selector: '[dir0]', map: const {'attr0': '=>prop'}) class Dir0 { Object prop; } -@Directive( - selector: '[dir1]', - map: const { - 'attr1': '=>prop' - } -) +@Directive(selector: '[dir1]', map: const {'attr1': '=>prop'}) class Dir1 { Object prop; - constructor(Dir0 dir0) { - } + constructor(Dir0 dir0) {} } -@Directive( - selector: '[dir2]', - map: const { - 'attr2': '=>prop' - } -) +@Directive(selector: '[dir2]', map: const {'attr2': '=>prop'}) class Dir2 { Object prop; - constructor(Dir1 dir1) { - } + constructor(Dir1 dir1) {} } -@Directive( - selector: '[dir3]', - map: const { - 'attr3': '=>prop' - } -) +@Directive(selector: '[dir3]', map: const {'attr3': '=>prop'}) class Dir3 { Object prop; - constructor(Dir2 dir2) { - } + constructor(Dir2 dir2) {} } -@Directive( - selector: '[dir4]', - map: const { - 'attr4': '=>prop' - } -) +@Directive(selector: '[dir4]', map: const {'attr4': '=>prop'}) class Dir4 { Object prop; - constructor(Dir3 dir3) { - } -} \ No newline at end of file + constructor(Dir3 dir3) {} +} diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/app.dart b/modules/benchmarks_external/src/naive_infinite_scroll/app.dart index 5cc9b34541..6a09e61630 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/app.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/app.dart @@ -5,9 +5,7 @@ import 'dart:html'; import 'package:angular/angular.dart'; import 'package:angular2/src/test_lib/benchmark_util.dart'; -@Component( - selector: 'scroll-app', - template: ''' +@Component(selector: 'scroll-app', template: '''
@@ -29,7 +27,7 @@ class App implements ShadowRootAware { int appSize = getIntParameter('appSize'); iterationCount = getIntParameter('iterationCount'); scrollIncrement = getIntParameter('scrollIncrement'); - appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table + appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table scrollAreas = new List.generate(appSize, (i) => i); } diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/cells.dart b/modules/benchmarks_external/src/naive_infinite_scroll/cells.dart index 62dc070a8c..2047361075 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/cells.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/cells.dart @@ -3,43 +3,25 @@ library cells; import 'package:angular/angular.dart'; import 'common.dart'; -@Component( - selector: 'company-name', - template: ''' +@Component(selector: 'company-name', template: '''
{{company.name}}
- ''', - map: const { - 'company': '=>company', - 'cell-width': '=>width', - }) + ''', map: const {'company': '=>company', 'cell-width': '=>width',}) class CompanyNameComponent { String width; Company company; } -@Component( - selector: 'opportunity-name', - template: ''' +@Component(selector: 'opportunity-name', template: '''
{{opportunity.name}}
- ''', - map: const { - 'opportunity': '=>opportunity', - 'cell-width': '=>width', - }) + ''', map: const {'opportunity': '=>opportunity', 'cell-width': '=>width',}) class OpportunityNameComponent { String width; Opportunity opportunity; } -@Component( - selector: 'offering-name', - template: ''' +@Component(selector: 'offering-name', template: '''
{{offering.name}}
- ''', - map: const { - 'offering': '=>offering', - 'cell-width': '=>width', - }) + ''', map: const {'offering': '=>offering', 'cell-width': '=>width',}) class OfferingNameComponent { String width; Offering offering; @@ -52,15 +34,11 @@ class Stage { Function apply; String get styleString => style != null - ? style.keys - .map((prop) => '$prop: ${style[prop]}') - .join(';') - : ''; + ? style.keys.map((prop) => '$prop: ${style[prop]}').join(';') + : ''; } -@Component( - selector: 'stage-buttons', - template: ''' +@Component(selector: 'stage-buttons', template: '''
- ''', - map: const { - 'offering': '=>offering', - 'cell-width': '=>width', - }) + ''', map: const {'offering': '=>offering', 'cell-width': '=>width',}) class StageButtonsComponent { Offering _offering; List stages; @@ -92,42 +66,30 @@ class StageButtonsComponent { _computeStageButtons() { bool disabled = true; - stages = STATUS_LIST - .map((String status) { + stages = STATUS_LIST.map((String status) { bool isCurrent = offering.status == status; var stage = new Stage(); stage ..name = status ..isDisabled = disabled ..style = { - 'background-color': disabled - ? '#DDD' - : isCurrent - ? '#DDF' - : '#FDD' - }; + 'background-color': disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD' + }; if (isCurrent) { disabled = false; } return stage; - }) - .toList(); + }).toList(); } } -@Component( - selector: 'account-cell', - template: ''' +@Component(selector: 'account-cell', template: ''' - ''', - map: const { - 'account': '=>account', - 'cell-width': '=>width', - }) + ''', map: const {'account': '=>account', 'cell-width': '=>width',}) class AccountCellComponent { Account account; String width; @@ -136,10 +98,7 @@ class AccountCellComponent { @Component( selector: 'formatted-cell', template: '''
{{formattedValue}}
''', - map: const { - 'value': '=>value', - 'cell-width': '=>width', - }) + map: const {'value': '=>value', 'cell-width': '=>width',}) class FormattedCellComponent { String formattedValue; String width; diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/common.dart b/modules/benchmarks_external/src/naive_infinite_scroll/common.dart index 6b48e2c61e..dd27e5a30a 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/common.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/common.dart @@ -23,32 +23,25 @@ const DUE_DATE_WIDTH = 100; const END_DATE_WIDTH = 100; const AAT_STATUS_WIDTH = 100; const ROW_WIDTH = COMPANY_NAME_WIDTH + - OPPORTUNITY_NAME_WIDTH + - OFFERING_NAME_WIDTH + - ACCOUNT_CELL_WIDTH + - BASE_POINTS_WIDTH + - KICKER_POINTS_WIDTH + - STAGE_BUTTONS_WIDTH + - BUNDLES_WIDTH + - DUE_DATE_WIDTH + - END_DATE_WIDTH + - AAT_STATUS_WIDTH; + OPPORTUNITY_NAME_WIDTH + + OFFERING_NAME_WIDTH + + ACCOUNT_CELL_WIDTH + + BASE_POINTS_WIDTH + + KICKER_POINTS_WIDTH + + STAGE_BUTTONS_WIDTH + + BUNDLES_WIDTH + + DUE_DATE_WIDTH + + END_DATE_WIDTH + + AAT_STATUS_WIDTH; -const STATUS_LIST = const [ - 'Planned', 'Pitched', 'Won', 'Lost' -]; +const STATUS_LIST = const ['Planned', 'Pitched', 'Won', 'Lost']; -const AAT_STATUS_LIST = const [ - 'Active', 'Passive', 'Abandoned' -]; +const AAT_STATUS_LIST = const ['Active', 'Passive', 'Abandoned']; // Imitate Streamy entities. -class RawEntity -extends Object -with MapMixin -implements ObservableMap { - +class RawEntity extends Object with MapMixin + implements ObservableMap { ObservableMap _data = new ObservableMap(); @override @@ -60,7 +53,7 @@ implements ObservableMap { } @override - operator[](String key) { + operator [](String key) { if (!key.contains('.')) { return _data[key]; } @@ -74,7 +67,7 @@ implements ObservableMap { } @override - operator[]=(String key, value) { + operator []=(String key, value) { if (!key.contains('.')) { _data[key] = value; return; @@ -115,7 +108,7 @@ implements ObservableMap { bool deliverChanges() => _data.deliverChanges(); @override notifyPropertyChange(Symbol field, Object oldValue, Object newValue) => - _data.notifyPropertyChange(field, oldValue, newValue); + _data.notifyPropertyChange(field, oldValue, newValue); @override void notifyChange(ChangeRecord record) { _data.notifyChange(record); @@ -199,7 +192,6 @@ class Opportunity extends RawEntity { set name(String val) { this['name'] = val; } - } class Account extends RawEntity { diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/index.dart b/modules/benchmarks_external/src/naive_infinite_scroll/index.dart index b8a9df4070..e20afdc602 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/index.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/index.dart @@ -9,7 +9,8 @@ import 'cells.dart'; class MyAppModule extends Module { MyAppModule() { - bind(ResourceResolverConfig, toValue: new ResourceResolverConfig.resolveRelativeUrls(false)); + bind(ResourceResolverConfig, + toValue: new ResourceResolverConfig.resolveRelativeUrls(false)); bind(App); bind(ScrollAreaComponent); bind(ScrollItemComponent); @@ -23,7 +24,5 @@ class MyAppModule extends Module { } void main() { - applicationFactory() - .addModule(new MyAppModule()) - .run(); + applicationFactory().addModule(new MyAppModule()).run(); } diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/random_data.dart b/modules/benchmarks_external/src/naive_infinite_scroll/random_data.dart index ea980a97d7..2a1c00ce1d 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/random_data.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/random_data.dart @@ -3,7 +3,7 @@ library random_data; import 'common.dart'; List generateOfferings(int count) => - new List.generate(count, generateOffering); + new List.generate(count, generateOffering); Offering generateOffering(int seed) { final res = new Offering(); @@ -22,24 +22,32 @@ Offering generateOffering(int seed) { } Company generateCompany(int seed) { - return new Company() - ..name = generateName(seed); + return new Company()..name = generateName(seed); } Opportunity generateOpportunity(int seed) { - return new Opportunity() - ..name = generateName(seed); + return new Opportunity()..name = generateName(seed); } Account generateAccount(int seed) { - return new Account() - ..accountId = seed; + return new Account()..accountId = seed; } String generateName(int seed) { const names = const [ - 'Foo', 'Bar', 'Baz', 'Qux', 'Quux', 'Garply', 'Waldo', 'Fred', 'Plugh', - 'Xyzzy', 'Thud', 'Cruft', 'Stuff' + 'Foo', + 'Bar', + 'Baz', + 'Qux', + 'Quux', + 'Garply', + 'Waldo', + 'Fred', + 'Plugh', + 'Xyzzy', + 'Thud', + 'Cruft', + 'Stuff' ]; return names[seed % names.length]; } @@ -49,13 +57,17 @@ DateTime randomDate(int seed, {DateTime minDate}) { minDate = new DateTime.now(); } - const offsets = const[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + const offsets = const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; return minDate.add(new Duration(days: offsets[seed % offsets.length])); } String randomString(int seed) { - return new String.fromCharCodes(new List.generate( - const[5, 7, 9, 11, 13][seed % 5], - (i) => 'a'.codeUnitAt(0) + const[0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i - )); + return new String.fromCharCodes(new List.generate(const [ + 5, + 7, + 9, + 11, + 13 + ][seed % 5], (i) => + 'a'.codeUnitAt(0) + const [0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i)); } diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/scroll_area.dart b/modules/benchmarks_external/src/naive_infinite_scroll/scroll_area.dart index 1a5bc61588..efc9414c72 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/scroll_area.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/scroll_area.dart @@ -9,9 +9,7 @@ import 'random_data.dart'; @Component( selector: 'scroll-area', templateUrl: 'scroll_area.html', - map: const { - 'scroll-top': '=>scrollTop', - }) + map: const {'scroll-top': '=>scrollTop',}) class ScrollAreaComponent implements ShadowRootAware { Element scrollDiv; List _fullList; @@ -32,10 +30,10 @@ class ScrollAreaComponent implements ShadowRootAware { scrollDiv = shadowRoot.querySelector('#scrollDiv'); onScroll(); scrollDivStyle.addAll({ - 'height': '${VIEW_PORT_HEIGHT}px', - 'width': '1000px', - 'border': '1px solid #000', - 'overflow': 'scroll', + 'height': '${VIEW_PORT_HEIGHT}px', + 'width': '1000px', + 'border': '1px solid #000', + 'overflow': 'scroll', }); innerStyle['width'] = '${ROW_WIDTH}px'; } @@ -52,7 +50,8 @@ class ScrollAreaComponent implements ShadowRootAware { int padding = iStart * ITEM_HEIGHT; innerStyle['height'] = '${HEIGHT - padding}px'; paddingStyle['height'] = '${padding}px'; - visibleItems..clear()..addAll(_fullList.getRange(iStart, iEnd)); + visibleItems + ..clear() + ..addAll(_fullList.getRange(iStart, iEnd)); } - } diff --git a/modules/benchmarks_external/src/naive_infinite_scroll/scroll_item.dart b/modules/benchmarks_external/src/naive_infinite_scroll/scroll_item.dart index 73fa539190..732a4c6eb2 100644 --- a/modules/benchmarks_external/src/naive_infinite_scroll/scroll_item.dart +++ b/modules/benchmarks_external/src/naive_infinite_scroll/scroll_item.dart @@ -6,36 +6,33 @@ import 'common.dart'; @Component( selector: 'scroll-item', templateUrl: 'scroll_item.html', - map: const { - 'offering': '=>offering', - }) + map: const {'offering': '=>offering',}) class ScrollItemComponent implements ShadowRootAware { + Offering offering; - Offering offering; + // Init empty maps and populate later. There seems to be a bug in Angular + // that makes it choke on pre-populated style maps. + Map itemStyle = {}; - // Init empty maps and populate later. There seems to be a bug in Angular - // that makes it choke on pre-populated style maps. - Map itemStyle = {}; - - @override - void onShadowRoot(_) { - itemStyle.addAll({ - 'height': '${ITEM_HEIGHT}px', - 'line-height': '${ITEM_HEIGHT}px', - 'font-size': '18px', - 'display': 'flex', - 'justify-content': 'space-between', - }); - } - get companyNameWidth => '${COMPANY_NAME_WIDTH}px'; - get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px'; - get offeringNameWidth => '${OFFERING_NAME_WIDTH}px'; - get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px'; - get basePointsWidth => '${BASE_POINTS_WIDTH}px'; - get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px'; - get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px'; - get bundlesWidth => '${BUNDLES_WIDTH}px'; - get dueDateWidth => '${DUE_DATE_WIDTH}px'; - get endDateWidth => '${END_DATE_WIDTH}px'; - get aatStatusWidth => '${AAT_STATUS_WIDTH}px'; + @override + void onShadowRoot(_) { + itemStyle.addAll({ + 'height': '${ITEM_HEIGHT}px', + 'line-height': '${ITEM_HEIGHT}px', + 'font-size': '18px', + 'display': 'flex', + 'justify-content': 'space-between', + }); + } + get companyNameWidth => '${COMPANY_NAME_WIDTH}px'; + get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px'; + get offeringNameWidth => '${OFFERING_NAME_WIDTH}px'; + get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px'; + get basePointsWidth => '${BASE_POINTS_WIDTH}px'; + get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px'; + get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px'; + get bundlesWidth => '${BUNDLES_WIDTH}px'; + get dueDateWidth => '${DUE_DATE_WIDTH}px'; + get endDateWidth => '${END_DATE_WIDTH}px'; + get aatStatusWidth => '${AAT_STATUS_WIDTH}px'; } diff --git a/modules/benchmarks_external/src/tree/tree_benchmark.dart b/modules/benchmarks_external/src/tree/tree_benchmark.dart index 09f005417b..f29adbb598 100644 --- a/modules/benchmarks_external/src/tree/tree_benchmark.dart +++ b/modules/benchmarks_external/src/tree/tree_benchmark.dart @@ -6,10 +6,11 @@ import 'package:angular/application_factory.dart'; import 'package:angular2/src/test_lib/benchmark_util.dart'; setup() { - var m = new Module() - ..bind(CompilerConfig, toValue: new CompilerConfig.withOptions(elementProbeEnabled: false)) - ..bind(ScopeDigestTTL, toFactory: () => new ScopeDigestTTL.value(15), inject: []) + ..bind(CompilerConfig, + toValue: new CompilerConfig.withOptions(elementProbeEnabled: false)) + ..bind(ScopeDigestTTL, + toFactory: () => new ScopeDigestTTL.value(15), inject: []) ..bind(TreeComponent); final injector = applicationFactory().addModule(m).run(); @@ -33,9 +34,9 @@ main() { createDom() { zone.run(() { - var values = count++ % 2 == 0 ? - ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] : - ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-']; + var values = count++ % 2 == 0 + ? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] + : ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-']; rootScope.context['initData'] = buildTree(maxDepth, values, 0); }); @@ -46,23 +47,21 @@ main() { } @Component( - selector: 'tree', - map: const {'data': '=>data'}, - template: ' {{data.value}}' - '' - '' - '' -) + selector: 'tree', + map: const {'data': '=>data'}, + template: ' {{data.value}}' + '' + '' + '') class TreeComponent { var data; } buildTree(maxDepth, values, curDepth) { if (maxDepth == curDepth) return new TreeNode(''); - return new TreeNode( - values[curDepth], - buildTree(maxDepth, values, curDepth+1), - buildTree(maxDepth, values, curDepth+1)); + return new TreeNode(values[curDepth], + buildTree(maxDepth, values, curDepth + 1), + buildTree(maxDepth, values, curDepth + 1)); } class TreeNode { @@ -71,4 +70,3 @@ class TreeNode { TreeNode right; TreeNode([this.value, this.left, this.right]); } - diff --git a/modules/benchpress/benchpress.dart b/modules/benchpress/benchpress.dart index 0b08f0d01b..3d334f5ec6 100644 --- a/modules/benchpress/benchpress.dart +++ b/modules/benchpress/benchpress.dart @@ -1,2 +1,3 @@ export './common.dart'; -export './src/webdriver/async_webdriver_adapter.dart' show AsyncWebDriverAdapter; +export './src/webdriver/async_webdriver_adapter.dart' + show AsyncWebDriverAdapter; diff --git a/modules/benchpress/src/webdriver/async_webdriver_adapter.dart b/modules/benchpress/src/webdriver/async_webdriver_adapter.dart index bbe69d15fc..8a554fd752 100644 --- a/modules/benchpress/src/webdriver/async_webdriver_adapter.dart +++ b/modules/benchpress/src/webdriver/async_webdriver_adapter.dart @@ -13,7 +13,7 @@ class AsyncWebDriverAdapter extends WebDriverAdapter { } Future executeScript(String script) { - return _driver.execute(script, const[]); + return _driver.execute(script, const []); } Future capabilities() { @@ -21,12 +21,11 @@ class AsyncWebDriverAdapter extends WebDriverAdapter { } Future> logs(String type) { - return _driver.logs.get(type) - .map((LogEntry entry) => { - 'message': entry.message - }) - .fold([], (log, Map entry) { - return log..add(entry); - }); + return _driver.logs + .get(type) + .map((LogEntry entry) => {'message': entry.message}) + .fold([], (log, Map entry) { + return log..add(entry); + }); } } diff --git a/modules/examples/test/benchpress/webdriver_async.server.spec.dart b/modules/examples/test/benchpress/webdriver_async.server.spec.dart index d6bac085ee..8df51d565c 100644 --- a/modules/examples/test/benchpress/webdriver_async.server.spec.dart +++ b/modules/examples/test/benchpress/webdriver_async.server.spec.dart @@ -2,7 +2,8 @@ import 'dart:async'; import 'dart:io' show Platform; import 'package:guinness/guinness.dart'; import 'package:benchpress/benchpress.dart'; -import 'package:webdriver/webdriver.dart' show WebDriver, Capabilities, LogType, LogLevel, By; +import 'package:webdriver/webdriver.dart' + show WebDriver, Capabilities, LogType, LogLevel, By; main() { describe('benchpress', () { @@ -11,10 +12,12 @@ main() { beforeEach(() async { driver = await createTestDriver(); - await driver.get('http://localhost:8002/examples/src/benchpress/index.html'); + await driver + .get('http://localhost:8002/examples/src/benchpress/index.html'); var bindings = [ - bind(WebDriverAdapter).toFactory(() => new AsyncWebDriverAdapter(driver), []) + bind(WebDriverAdapter).toFactory( + () => new AsyncWebDriverAdapter(driver), []) ]; runner = new Runner(bindings); }); @@ -24,34 +27,30 @@ main() { }); it('should work', () { - return runner.sample( - id: 'benchpress smoke test', - execute: () async { - var button = await driver.findElement(const By.tagName('button')); - await button.click(); - var logText = await (await driver.findElement(const By.id('log'))).text; - expect(logText, 'hi'); - } - ); + return runner.sample(id: 'benchpress smoke test', execute: () async { + var button = await driver.findElement(const By.tagName('button')); + await button.click(); + var logText = await (await driver.findElement(const By.id('log'))).text; + expect(logText, 'hi'); + }); }); }); } Future createTestDriver() { Map env = Platform.environment; - return WebDriver.createDriver(desiredCapabilities: { + return WebDriver.createDriver( + desiredCapabilities: { 'name': 'Dartium', 'browserName': 'chrome', 'chromeOptions': { 'binary': env['DARTIUM_BIN'], 'args': ['--js-flags=--expose-gc'], 'perfLoggingPrefs': { - 'traceCategories': 'v8,blink.console,disabled-by-default-devtools.timeline' + 'traceCategories': + 'v8,blink.console,disabled-by-default-devtools.timeline' }, }, - 'loggingPrefs': { - 'performance': 'ALL', - 'browser': 'ALL', - } + 'loggingPrefs': {'performance': 'ALL', 'browser': 'ALL',} }); }