diff --git a/demo/bouncing_balls/bouncy_balls.dart b/demo/bouncing_balls/bouncy_balls.dart index 7495c8eee..b5f4320a2 100644 --- a/demo/bouncing_balls/bouncy_balls.dart +++ b/demo/bouncing_balls/bouncy_balls.dart @@ -17,7 +17,7 @@ class BallModel { static _color() { var color = '#'; - for(var i=0; i < 6; i++) { + for(var i = 0; i < 6; i++) { color += (16 * random.nextDouble()).floor().toRadixString(16); } return color; @@ -27,8 +27,7 @@ class BallModel { @NgController( selector: '[bounce-controller]', - publishAs: 'bounce' -) + publishAs: 'bounce') class BounceController { var lastTime = window.performance.now(); var run = true; @@ -36,41 +35,41 @@ class BounceController { var digestTime = 0; var currentDigestTime = 0; var balls = []; - var zone; - var scope; + final NgZone zone; + final Scope scope; var ballClassName = 'ball'; - BounceController(NgZone this.zone, Scope this.scope) { + BounceController(this.zone, this.scope) { changeCount(100); tick(); } - toggleCSS() { + void toggleCSS() { ballClassName = ballClassName == '' ? 'ball' : ''; } - playPause() { + void playPause() { run = !run; if (run) requestAnimationFrame(tick); } - requestAnimationFrame(fn) { + void requestAnimationFrame(fn) { window.requestAnimationFrame((_) => zone.run(fn)); } - changeCount(count) { + void changeCount(count) { while(count > 0) { balls.add(new BallModel()); count--; } - while(count < 0) { + while(count < 0 && balls.isNotEmpty) { balls.removeAt(0); count++; } tick(); } - timeDigest() { + void timeDigest() { var start = window.performance.now(); digestTime = currentDigestTime; scope.rootScope.domRead(() { @@ -78,19 +77,30 @@ class BounceController { }); } - tick() { - var now = window.performance.now(), - delay = now - lastTime; + void tick() { + var now = window.performance.now(); + var delay = now - lastTime; fps = (1000/delay).round(); for(var i=0, ii=balls.length; i width) { b.x = 2*width - b.x; b.velX *= -1; } - if (b.y > height) { b.y = 2*height - b.y; b.velY *= -1; } + if (b.x < 0) { + b.x *= -1; + b.velX *= -1; + } else if (b.x > width) { + b.x = 2*width - b.x; + b.velX *= -1; + } + + if (b.y < 0) { + b.y *= -1; + b.velY *= -1; + } else if (b.y > height) { + b.y = 2*height - b.y; + b.velY *= -1; + } } lastTime = now; timeDigest(); @@ -101,18 +111,17 @@ class BounceController { @NgDirective( selector: '[ball-position]', map: const { - "ballPosition": '=>position' - } -) + "ballPosition": '=>position'}) class BallPositionDirective { - Element element; - Scope scope; - BallPositionDirective(Element this.element, Scope this.scope); + final Element element; + final Scope scope; + BallPositionDirective(this.element, this.scope); set position(BallModel model) { element.style.backgroundColor = model.color; - scope.observe('x', (x, _) => element.style.left = '${x + 10}px', context:model); - scope.observe('y', (y, _) => element.style.top = '${y + 10}px', context:model); + scope + ..observe('x', (x, _) => element.style.left = '${x + 10}px', context: model) + ..observe('y', (y, _) => element.style.top = '${y + 10}px', context: model); } } diff --git a/demo/bouncing_balls/index.html b/demo/bouncing_balls/index.html index 267371c28..568d6336d 100644 --- a/demo/bouncing_balls/index.html +++ b/demo/bouncing_balls/index.html @@ -45,7 +45,9 @@
-
+
+
+
{{bounce.fps}} fps. ({{bounce.balls.length}} balls) [{{(1000/bounce.fps).round()}} ms]
diff --git a/demo/helloworld/helloworld.dart b/demo/helloworld/helloworld.dart index 50e5d2c57..338e33bb6 100644 --- a/demo/helloworld/helloworld.dart +++ b/demo/helloworld/helloworld.dart @@ -10,8 +10,7 @@ import 'dart:mirrors'; @NgController( selector: '[hello-world-controller]', - publishAs: 'ctrl' -) + publishAs: 'ctrl') class HelloWorldController { String name = "world"; } diff --git a/demo/todo/web/index.html b/demo/todo/web/index.html index a3010d815..7cea710c6 100644 --- a/demo/todo/web/index.html +++ b/demo/todo/web/index.html @@ -8,33 +8,32 @@ -
Wait, Dart is loading this awesome app...
+
Wait, Dart is loading this awesome app...
-
-

Things To Do ;-)

+
+

Things To Do ;-)

-
- - -
- -

Remaining {{todo.remaining()}} of {{todo.items.length}} items.

+
+ + +
+

Remaining {{todo.remaining()}} of {{todo.items.length}} items.

-
    -
  • - -
  • -
-
- - - -
+
    +
  • + +
  • +
-
+
+ + + +
+
diff --git a/demo/todo/web/main.dart b/demo/todo/web/main.dart index 5c67d8084..02741b947 100644 --- a/demo/todo/web/main.dart +++ b/demo/todo/web/main.dart @@ -15,8 +15,8 @@ main() { print(window.location.search); var module = new Module() - ..type(TodoController) - ..type(PlaybackHttpBackendConfig); + ..type(TodoController) + ..type(PlaybackHttpBackendConfig); // If these is a query in the URL, use the server-backed // TodoController. Otherwise, use the stored-data controller. @@ -39,5 +39,5 @@ main() { module.type(HttpBackend, implementedBy: PlaybackHttpBackend); } - ngBootstrap(module:module); + ngBootstrap(module: module); } diff --git a/demo/todo/web/todo.dart b/demo/todo/web/todo.dart index d287be25c..289500a82 100644 --- a/demo/todo/web/todo.dart +++ b/demo/todo/web/todo.dart @@ -7,13 +7,13 @@ class Item { String text; bool done; - Item([String this.text = '', bool this.done = false]); + Item([this.text = '', this.done = false]); bool get isEmpty => text.isEmpty; - clone() => new Item(text, done); + Item clone() => new Item(text, done); - clear() { + void clear() { text = ''; done = false; } @@ -50,11 +50,10 @@ class HttpServerController implements ServerController { @NgController( - selector: '[todo-controller]', - publishAs: 'todo' -) + selector: '[todo-controller]', + publishAs: 'todo') class TodoController { - List items; + var items = []; Item newItem; TodoController(ServerController serverController) { @@ -69,33 +68,24 @@ class TodoController { } // workaround for https://github.com/angular/angular.dart/issues/37 - dynamic operator [](String key) { - if (key == 'newItem') { - return newItem; - } - return null; - } + dynamic operator [](String key) => key == 'newItem' ? newItem : null; - add() { + void add() { if (newItem.isEmpty) return; items.add(newItem.clone()); newItem.clear(); } - markAllDone() { + void markAllDone() { items.forEach((item) => item.done = true); } - archiveDone() { + void archiveDone() { items.removeWhere((item) => item.done); } - String classFor(Item item) { - return item.done ? 'done' : ''; - } + String classFor(Item item) => item.done ? 'done' : ''; - int remaining() { - return items.where((item) => !item.done).length; - } + int remaining() => items.fold(0, (count, item) => count += item.done ? 0 : 1); } diff --git a/lib/change_detection/ast.dart b/lib/change_detection/ast.dart index 088884389..66c55fba3 100644 --- a/lib/change_detection/ast.dart +++ b/lib/change_detection/ast.dart @@ -17,7 +17,7 @@ abstract class AST { assert(expression!=null); } WatchRecord<_Handler> setupWatch(WatchGroup watchGroup); - toString() => expression; + String toString() => expression; } /** @@ -59,9 +59,9 @@ class FieldReadAST extends AST { final String name; FieldReadAST(lhs, name) - : super('$lhs.$name'), - lhs = lhs, - name = name; + : lhs = lhs, + name = name, + super('$lhs.$name'); WatchRecord<_Handler> setupWatch(WatchGroup watchGroup) => watchGroup.addFieldWatch(lhs, name, expression); @@ -111,14 +111,14 @@ class MethodAST extends AST { class CollectionAST extends AST { final AST valueAST; CollectionAST(valueAST) - : super('#collection($valueAST)'), - valueAST = valueAST; + : valueAST = valueAST, + super('#collection($valueAST)'); WatchRecord<_Handler> setupWatch(WatchGroup watchGroup) => watchGroup.addCollectionWatch(valueAST); } -_argList(List items) => items.join(', '); +String _argList(List items) => items.join(', '); /** * The name is a bit oxymoron, but it is essentially the NullObject pattern. diff --git a/lib/change_detection/change_detection.dart b/lib/change_detection/change_detection.dart index 34052671b..2eb49fe2e 100644 --- a/lib/change_detection/change_detection.dart +++ b/lib/change_detection/change_detection.dart @@ -13,8 +13,8 @@ abstract class ChangeDetectorGroup { * Watch a specific [field] on an [object]. * * If the [field] is: - * - _name_ - Name of the field to watch. (If the [object] is a Map then - * treat it as a key.) + * - _name_ - Name of the property to watch. (If the [object] is a Map then + * treat the name as a key.) * - _[]_ - Watch all items in an array. * - _{}_ - Watch all items in a Map. * - _._ - Watch the actual object identity. @@ -51,8 +51,8 @@ abstract class ChangeDetectorGroup { abstract class ChangeDetector extends ChangeDetectorGroup { /** * This method does the work of collecting the changes and returns them as a - * linked list of [ChangeRecord]s. The [ChangeRecord]s are to be returned in - * the same order as they were registered. + * linked list of [ChangeRecord]s. The [ChangeRecord]s are returned in the + * same order as they were registered. */ ChangeRecord collectChanges([EvalExceptionHandler exceptionHandler]); } @@ -93,7 +93,7 @@ abstract class WatchRecord extends Record { /** * Check to see if the field on the object has changed. Returns [null] if no - * change, or a [ChangeRecord] if the change has been detected. + * change, or a [ChangeRecord] if a change has been detected. */ ChangeRecord check(); @@ -111,11 +111,11 @@ abstract class ChangeRecord extends Record { } /** - * If [ChangeDetector] is watching a an [Map] then the - * [currentValue] of [Record] will contain this object. The object contains a - * summary of changes to the map since the last execution. The changes - * are reported as a list of [MapKeyValue]s which contain the current - * and previous value in the list as well as the key. + * If the [ChangeDetector] is watching a [Map] then the [currentValue] of + * [Record] will contain an instance of this object. A [MapChangeRecord] + * contains the changes to the map since the last execution. The changes are + * reported as a list of [MapKeyValue]s which contain the key as well as its + * current and previous value. */ abstract class MapChangeRecord { /// The underlying iterable object @@ -168,73 +168,73 @@ abstract class ChangedKeyValue extends MapKeyValue { /** - * If [ChangeDetector] is watching a an [Iterable] then the - * [currentValue] of [Record] will contain this object. The object contains a - * summary of changes to the collection since the last execution. The changes - * are reported as a list of [CollectionChangeItem]s which contain the current - * and previous position in the list as well as the item. + * If the [ChangeDetector] is watching an [Iterable] then the [currentValue] of + * [Record] will contain this object. The [CollectionChangeRecord] contains the + * changes to the collection since the last execution. The changes are reported + * as a list of [CollectionChangeItem]s which contain the item as well as its + * current and previous position in the list. */ -abstract class CollectionChangeRecord { +abstract class CollectionChangeRecord { /** The underlying iterable object */ Iterable get iterable; /** A list of [CollectionItem]s which are in the iteration order. */ - CollectionItem get collectionHead; + CollectionItem get collectionHead; /** A list of new [AddedItem]s. */ - AddedItem get additionsHead; + AddedItem get additionsHead; /** A list of [MovedItem]s. */ - MovedItem get movesHead; + MovedItem get movesHead; /** A list of [RemovedItem]s. */ - RemovedItem get removalsHead; + RemovedItem get removalsHead; - void forEachAddition(void f(AddedItem addition)); - void forEachMove(void f(MovedItem move)); - void forEachRemoval(void f(RemovedItem removal)); + void forEachAddition(void f(AddedItem addition)); + void forEachMove(void f(MovedItem move)); + void forEachRemoval(void f(RemovedItem removal)); } /** - * Each item in collection is wrapped in [CollectionChangeItem], which can track - * the [item]s [currentKey] and [previousKey] location. + * Each changed item in the collection is wrapped in a [CollectionChangeItem], + * which tracks the [item]s [currentKey] and [previousKey] location. */ -abstract class CollectionChangeItem { // TODO(misko): change to since K is int. +abstract class CollectionChangeItem { /** Previous item location in the list or [null] if addition. */ - K get previousKey; // TODO(misko): rename to previousIndex + int get previousIndex; /** Current item location in the list or [null] if removal. */ - K get currentKey; // TODO(misko): rename to CurrentIndex + int get currentIndex; /** The item. */ V get item; } /** - * Used to create a linked list of collection items. - * These items are always in the iteration order of the collection. + * Used to create a linked list of collection items. These items are always in + * the iteration order of the collection. */ -abstract class CollectionItem extends CollectionChangeItem { - CollectionItem get nextCollectionItem; +abstract class CollectionItem extends CollectionChangeItem { + CollectionItem get nextCollectionItem; } /** - * A linked list of new items added to the collection. - * These items are always in the iteration order of the collection. + * A linked list of new items added to the collection. These items are always in + * the iteration order of the collection. */ -abstract class AddedItem extends CollectionChangeItem { - AddedItem get nextAddedItem; +abstract class AddedItem extends CollectionChangeItem { + AddedItem get nextAddedItem; } /** - * A linked list of moved items in to the collection. - * These items are always in the iteration order of the collection. + * A linked list of items moved in the collection. These items are always in + * the iteration order of the collection. */ -abstract class MovedItem extends CollectionChangeItem { - MovedItem get nextMovedItem; +abstract class MovedItem extends CollectionChangeItem { + MovedItem get nextMovedItem; } /** - * A linked list of removed items in to the collection. - * These items are always in the iteration order of the collection. + * A linked list of items removed from the collection. These items are always + * in the iteration order of the collection. */ -abstract class RemovedItem extends CollectionChangeItem { - RemovedItem get nextRemovedItem; +abstract class RemovedItem extends CollectionChangeItem { + RemovedItem get nextRemovedItem; } diff --git a/lib/change_detection/dirty_checking_change_detector.dart b/lib/change_detection/dirty_checking_change_detector.dart index a7c13ebcc..24a568341 100644 --- a/lib/change_detection/dirty_checking_change_detector.dart +++ b/lib/change_detection/dirty_checking_change_detector.dart @@ -557,11 +557,10 @@ class _MapChangeRecord implements MapChangeRecord { } } - bool _isInRemovals(KeyValueRecord record) { - return record == _removalsHead || - record._nextRemovedKeyValue != null || - record._prevRemovedKeyValue != null; - } + bool _isInRemovals(KeyValueRecord record) => + record == _removalsHead || + record._nextRemovedKeyValue != null || + record._prevRemovedKeyValue != null; void _addToRemovals(KeyValueRecord record) { assert(record._nextKeyValue == null); @@ -580,7 +579,11 @@ class _MapChangeRecord implements MapChangeRecord { void _removeFromSeq(KeyValueRecord prev, KeyValueRecord record) { KeyValueRecord next = record._nextKeyValue; - if (prev == null) _mapHead = next; else prev._nextKeyValue = next; + if (prev == null) { + _mapHead = next; + } else { + prev._nextKeyValue = next; + } assert((() { record._nextKeyValue = null; return true; @@ -594,8 +597,16 @@ class _MapChangeRecord implements MapChangeRecord { var prev = record._prevRemovedKeyValue; var next = record._nextRemovedKeyValue; - if (prev == null) _removalsHead = next; else prev._nextRemovedKeyValue = next; - if (next == null) _removalsTail = prev; else next._prevRemovedKeyValue = prev; + if (prev == null) { + _removalsHead = next; + } else { + prev._nextRemovedKeyValue = next; + } + if (next == null) { + _removalsTail = prev; + } else { + next._prevRemovedKeyValue = prev; + } record._prevRemovedKeyValue = record._nextRemovedKeyValue = null; } @@ -627,7 +638,8 @@ class _MapChangeRecord implements MapChangeRecord { } } -class KeyValueRecord implements KeyValue, AddedKeyValue, RemovedKeyValue, ChangedKeyValue { +class KeyValueRecord implements KeyValue, AddedKeyValue, + RemovedKeyValue, ChangedKeyValue { final K key; V _previousValue, _currentValue; @@ -651,7 +663,7 @@ class KeyValueRecord implements KeyValue, AddedKeyValue, Remov } -class _CollectionChangeRecord implements CollectionChangeRecord { +class _CollectionChangeRecord implements CollectionChangeRecord { Iterable _iterable; /** Used to keep track of items during moves. */ DuplicateMap _items = new DuplicateMap(); @@ -659,17 +671,17 @@ class _CollectionChangeRecord implements CollectionChangeRecord { /** Used to keep track of removed items. */ DuplicateMap _removedItems = new DuplicateMap(); - ItemRecord _collectionHead, _collectionTail; - ItemRecord _additionsHead, _additionsTail; - ItemRecord _movesHead, _movesTail; - ItemRecord _removalsHead, _removalsTail; + ItemRecord _collectionHead, _collectionTail; + ItemRecord _additionsHead, _additionsTail; + ItemRecord _movesHead, _movesTail; + ItemRecord _removalsHead, _removalsTail; - CollectionChangeItem get collectionHead => _collectionHead; - CollectionChangeItem get additionsHead => _additionsHead; - CollectionChangeItem get movesHead => _movesHead; - CollectionChangeItem get removalsHead => _removalsHead; + CollectionChangeItem get collectionHead => _collectionHead; + CollectionChangeItem get additionsHead => _additionsHead; + CollectionChangeItem get movesHead => _movesHead; + CollectionChangeItem get removalsHead => _removalsHead; - void forEachAddition(void f(AddedItem addition)){ + void forEachAddition(void f(AddedItem addition)){ ItemRecord record = _additionsHead; while(record != null) { f(record); @@ -677,7 +689,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { } } - void forEachMove(void f(MovedItem change)) { + void forEachMove(void f(MovedItem change)) { ItemRecord record = _movesHead; while(record != null) { f(record); @@ -685,7 +697,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { } } - void forEachRemoval(void f(RemovedItem removal)){ + void forEachRemoval(void f(RemovedItem removal)){ ItemRecord record = _removalsHead; while(record != null) { f(record); @@ -706,7 +718,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { return false; } else if (collection is List) { List list = collection; - for(int index = 0, length = list.length; index < length; index++) { + for(int index = 0; index < list.length; index++) { var item = list[index]; if (record == null || !identical(item, record.item)) { record = mismatch(record, item, index); @@ -746,14 +758,14 @@ class _CollectionChangeRecord implements CollectionChangeRecord { record = _additionsHead; while(record != null) { - record.previousKey = record.currentKey; + record.previousIndex = record.currentIndex; record = record._nextAddedRec; } _additionsHead = _additionsTail = null; record = _movesHead; while(record != null) { - record.previousKey = record.currentKey; + record.previousIndex = record.currentIndex; var nextRecord = record._nextMovedRec; assert((record._nextMovedRec = null) == null); record = nextRecord; @@ -779,7 +791,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { * - [item] is the current item in the collection * - [index] is the position of the item in the collection */ - ItemRecord mismatch(ItemRecord record, dynamic item, int index) { + ItemRecord mismatch(ItemRecord record, item, int index) { // Guard against bogus String changes if (record != null && item is String && record.item is String && record.item == item) { @@ -845,8 +857,8 @@ class _CollectionChangeRecord implements CollectionChangeRecord { ItemRecord reinsertRecord = _removedItems.get(item); if (reinsertRecord != null) { record = _collection_reinsertAfter(reinsertRecord, record._prevRec, index); - } else if (record.currentKey != index) { - record.currentKey = index; + } else if (record.currentIndex != index) { + record.currentIndex = index; _moves_add(record); } return record; @@ -938,7 +950,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { } _items.put(record); - record.currentKey = index; + record.currentIndex = index; return record; } @@ -982,7 +994,7 @@ class _CollectionChangeRecord implements CollectionChangeRecord { } ItemRecord _removals_add(ItemRecord record) { - record.currentKey = null; + record.currentIndex = null; _removedItems.put(record); if (_removalsTail == null) { @@ -1037,27 +1049,27 @@ removals: ${removals.join(", ")}' } } -class ItemRecord implements CollectionItem, AddedItem, - MovedItem, RemovedItem { - K previousKey = null; - K currentKey = null; +class ItemRecord implements CollectionItem, AddedItem, MovedItem, + RemovedItem { + int previousIndex = null; + int currentIndex = null; V item = _INITIAL_; - ItemRecord _prevRec, _nextRec; - ItemRecord _prevDupRec, _nextDupRec; - ItemRecord _prevRemovedRec, _nextRemovedRec; - ItemRecord _nextAddedRec, _nextMovedRec; + ItemRecord _prevRec, _nextRec; + ItemRecord _prevDupRec, _nextDupRec; + ItemRecord _prevRemovedRec, _nextRemovedRec; + ItemRecord _nextAddedRec, _nextMovedRec; - CollectionItem get nextCollectionItem => _nextRec; - RemovedItem get nextRemovedItem => _nextRemovedRec; - AddedItem get nextAddedItem => _nextAddedRec; - MovedItem get nextMovedItem => _nextMovedRec; + CollectionItem get nextCollectionItem => _nextRec; + RemovedItem get nextRemovedItem => _nextRemovedRec; + AddedItem get nextAddedItem => _nextAddedRec; + MovedItem get nextMovedItem => _nextMovedRec; ItemRecord(this.item); - toString() => previousKey == currentKey ? - '$item' : - '$item[$previousKey -> $currentKey]'; + String toString() => previousIndex == currentIndex + ? '$item' + : '$item[$previousIndex -> $currentIndex]'; } class _DuplicateItemRecordList { @@ -1081,7 +1093,11 @@ class _DuplicateItemRecordList { var next = beforeRecord; record._prevDupRec = prev; record._nextDupRec = next; - if (prev == null) head = record; else prev._nextDupRec = record; + if (prev == null) { + head = record; + } else { + prev._nextDupRec = record; + } next._prevDupRec = record; } } @@ -1091,7 +1107,7 @@ class _DuplicateItemRecordList { ItemRecord record = head; while(record != null) { if (hideIndex == null || - hideIndex < record.currentKey && identical(record.item, key)) { + hideIndex < record.currentIndex && identical(record.item, key)) { return record; } record = record._nextDupRec; @@ -1135,8 +1151,7 @@ class _DuplicateItemRecordList { * key. */ class DuplicateMap { - final Map map = - new Map(); + final map = {}; void put(ItemRecord record, [ItemRecord beforeRecord = null]) { assert(record._nextDupRec == null); diff --git a/lib/change_detection/prototype_map.dart b/lib/change_detection/prototype_map.dart index 5c0b7f298..130444184 100644 --- a/lib/change_detection/prototype_map.dart +++ b/lib/change_detection/prototype_map.dart @@ -3,22 +3,35 @@ part of angular.watch_group; class PrototypeMap implements Map { final Map prototype; final Map self = new Map(); + PrototypeMap(this.prototype); - operator []=(name, value) => self[name] = value; - operator [](name) => self.containsKey(name) ? self[name] : prototype[name]; + void operator []=(name, value) { + self[name] = value; + } + V operator [](name) => self.containsKey(name) ? self[name] : prototype[name]; - get isEmpty => self.isEmpty && prototype.isEmpty; - get isNotEmpty => self.isNotEmpty || prototype.isNotEmpty; - get keys => self.keys; - get values => self.values; - get length => self.length; + bool get isEmpty => self.isEmpty && prototype.isEmpty; + bool get isNotEmpty => self.isNotEmpty || prototype.isNotEmpty; + // todo(vbe) include prototype keys ? + Iterable get keys => self.keys; + // todo(vbe) include prototype values ? + Iterable get values => self.values; + int get length => self.length; - forEach(fn) => self.forEach(fn); - remove(key) => self.remove(key); + void forEach(fn) { + // todo(vbe) include prototype ? + self.forEach(fn); + } + V remove(key) => self.remove(key); clear() => self.clear; - containsKey(key) => self.containsKey(key); - containsValue(key) => self.containsValue(key); - addAll(map) => self.addAll(map); - putIfAbsent(key, fn) => self.putIfAbsent(key, fn); + // todo(vbe) include prototype ? + bool containsKey(key) => self.containsKey(key); + // todo(vbe) include prototype ? + bool containsValue(key) => self.containsValue(key); + void addAll(map) { + self.addAll(map); + } + // todo(vbe) include prototype ? + V putIfAbsent(key, fn) => self.putIfAbsent(key, fn); } diff --git a/lib/change_detection/watch_group.dart b/lib/change_detection/watch_group.dart index 1388b7e7d..ed6274813 100644 --- a/lib/change_detection/watch_group.dart +++ b/lib/change_detection/watch_group.dart @@ -96,8 +96,8 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList { _nextWatchGroup; final WatchGroup _parentWatchGroup; - WatchGroup._child(_parentWatchGroup, this._changeDetector, - this.context, this._cache, this._rootGroup) + WatchGroup._child(_parentWatchGroup, this._changeDetector, this.context, + this._cache, this._rootGroup) : _parentWatchGroup = _parentWatchGroup, id = '${_parentWatchGroup.id}.${_parentWatchGroup._nextChildId++}' { @@ -224,7 +224,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList { } WatchGroup get _childWatchGroupTail { - WatchGroup tail = this, nextTail; + var tail = this, nextTail; while ((nextTail = tail._watchGroupTail) != null) { tail = nextTail; } @@ -245,7 +245,7 @@ class WatchGroup implements _EvalWatchList, _WatchGroupList { this, _changeDetector.newGroup(), context == null ? this.context : context, - context == null ? this._cache: new Map>(), + context == null ? this._cache: >{}, _rootGroup == null ? this : _rootGroup); _WatchGroupList._add(this, childGroup); var marker = childGroup._marker; @@ -321,7 +321,7 @@ class RootWatchGroup extends WatchGroup { RootWatchGroup(ChangeDetector changeDetector, Object context): super._root(changeDetector, context); - WatchGroup get _rootGroup => this; + RootWatchGroup get _rootGroup => this; /** * Detect changes and process the [ReactionFn]s. @@ -334,14 +334,14 @@ class RootWatchGroup extends WatchGroup { * Each step is called in sequence. ([ReactionFn]s are not called until all * previous steps are completed). */ - int detectChanges({EvalExceptionHandler exceptionHandler, ChangeLog changeLog}) { + int detectChanges({EvalExceptionHandler exceptionHandler, + ChangeLog changeLog}) { // Process the ChangeRecords from the change detector ChangeRecord<_Handler> changeRecord = - (_changeDetector as ChangeDetector<_Handler>).collectChanges(exceptionHandler); + (_changeDetector as ChangeDetector<_Handler>) + .collectChanges(exceptionHandler); while (changeRecord != null) { - if (changeLog != null) { - changeLog(changeRecord.handler.expression); - } + if (changeLog != null) changeLog(changeRecord.handler.expression); changeRecord.handler.onChange(changeRecord); changeRecord = changeRecord.nextChange; } @@ -369,7 +369,6 @@ class RootWatchGroup extends WatchGroup { count++; try { dirtyWatch.invoke(); - } catch (e, s) { if (exceptionHandler == null) rethrow; else exceptionHandler(e, s); } @@ -566,7 +565,8 @@ class _ArgHandler extends _Handler { _releaseWatch() => null; _ArgHandler(WatchGroup watchGrp, this.watchRecord, int index) - : super(watchGrp, 'arg[$index]'), index = index; + : index = index, + super(watchGrp, 'arg[$index]'); void acceptValue(object) { watchRecord.dirtyArgs = true; @@ -628,11 +628,14 @@ class _EvalWatchRecord implements WatchRecord<_Handler>, ChangeRecord<_Handler> _EvalWatchRecord(this.watchGrp, this.handler, this.fn, name, int arity) : args = new List(arity), name = name, - symbol = name == null ? null : new Symbol(name) - { - if (fn is FunctionApply) mode = _MODE_FUNCTION_APPLY_; - else if (fn is Function) mode = _MODE_FUNCTION_; - else mode = _MODE_NULL_; + symbol = name == null ? null : new Symbol(name) { + if (fn is FunctionApply) { + mode = _MODE_FUNCTION_APPLY_; + } else if (fn is Function) { + mode = _MODE_FUNCTION_; + } else { + mode = _MODE_NULL_; + } } _EvalWatchRecord.marker() @@ -673,11 +676,9 @@ class _EvalWatchRecord implements WatchRecord<_Handler>, ChangeRecord<_Handler> mode = _MODE_MAP_CLOSURE_; } else { _instanceMirror = reflect(value); - if(_hasMethod(_instanceMirror.type, symbol)) { - mode = _MODE_METHOD_; - } else { - mode = _MODE_FIELD_CLOSURE_; - } + mode = _hasMethod(_instanceMirror.type, symbol) + ? _MODE_METHOD_ + : _MODE_FIELD_CLOSURE_; } } } @@ -737,7 +738,7 @@ class _EvalWatchRecord implements WatchRecord<_Handler>, ChangeRecord<_Handler> _EvalWatchList._remove(watchGrp, this); } - toString() { + String toString() { if (mode == _MODE_MARKER_) return 'MARKER[$currentValue]'; return '${watchGrp.id}:${handler.expression}'; } diff --git a/lib/core/scope.dart b/lib/core/scope.dart index 0bdb89f82..baeda16b1 100644 --- a/lib/core/scope.dart +++ b/lib/core/scope.dart @@ -71,12 +71,12 @@ class ScopeEvent { * value. Digest keeps checking the state of the watcher getters until it * can execute one full iteration with no watchers triggering. TTL is used * to prevent an infinite loop where watch A triggers watch B which in turn - * triggers watch A. If the system does not stabilize in TTL iteration then - * an digest is stop an an exception is thrown. + * triggers watch A. If the system does not stabilize in TTL iterations then + * the digest is stopped and an exception is thrown. */ @NgInjectableService() class ScopeDigestTTL { - final num ttl; + final int ttl; ScopeDigestTTL(): ttl = 5; ScopeDigestTTL.value(this.ttl); } @@ -91,22 +91,31 @@ class ScopeLocals implements Map { ScopeLocals(this._scope, this._locals); - operator []=(String name, value) => _scope[name] = value; - operator [](String name) => (_locals.containsKey(name) ? _locals : _scope)[name]; - - get isEmpty => _scope.isEmpty && _locals.isEmpty; - get isNotEmpty => _scope.isNotEmpty || _locals.isNotEmpty; - get keys => _scope.keys; - get values => _scope.values; - get length => _scope.length; - - forEach(fn) => _scope.forEach(fn); - remove(key) => _scope.remove(key); - clear() => _scope.clear; - containsKey(key) => _scope.containsKey(key); - containsValue(key) => _scope.containsValue(key); - addAll(map) => _scope.addAll(map); - putIfAbsent(key, fn) => _scope.putIfAbsent(key, fn); + void operator []=(String name, value) { + _scope[name] = value; + } + dynamic operator [](String name) => + (_locals.containsKey(name) ? _locals : _scope)[name]; + + bool get isEmpty => _scope.isEmpty && _locals.isEmpty; + bool get isNotEmpty => _scope.isNotEmpty || _locals.isNotEmpty; + List get keys => _scope.keys; + List get values => _scope.values; + int get length => _scope.length; + + void forEach(fn) { + _scope.forEach(fn); + } + dynamic remove(key) => _scope.remove(key); + void clear() { + _scope.clear; + } + bool containsKey(key) => _scope.containsKey(key); + bool containsValue(key) => _scope.containsValue(key); + void addAll(map) { + _scope.addAll(map); + } + dynamic putIfAbsent(key, fn) => _scope.putIfAbsent(key, fn); } class Scope { @@ -150,12 +159,10 @@ class Scope { if (expression is String && expression.isNotEmpty) { var obj = locals == null ? context : new ScopeLocals(context, locals); return rootScope._parser(expression).eval(obj); - } else if (expression is EvalFunction1) { - assert(locals == null); - return expression(context); - } else if (expression is EvalFunction0) { + } else { assert(locals == null); - return expression(); + if (expression is EvalFunction1) return expression(context); + if (expression is EvalFunction0) return expression(); } } @@ -169,9 +176,10 @@ class Scope { } catch (e, s) { rootScope._exceptionHandler(e, s); } finally { - rootScope._transitionState(RootScope.STATE_APPLY, null); - rootScope.digest(); - rootScope.flush(); + rootScope + .._transitionState(RootScope.STATE_APPLY, null) + ..digest() + ..flush(); } } @@ -197,10 +205,18 @@ class Scope { } void destroy() { - var prev = this._prev; - var next = this._next; - if (prev == null) _parentScope._childHead = next; else prev._next = next; - if (next == null) _parentScope._childTail = prev; else next._prev = prev; + var prev = _prev; + var next = _next; + if (prev == null) { + _parentScope._childHead = next; + } else { + prev._next = next; + } + if (next == null) { + _parentScope._childTail = prev; + } else { + next._prev = prev; + } this._next = this._prev = null; @@ -260,15 +276,17 @@ class RootScope extends Scope { ChangeLog changeLog; do { while(_runAsyncHead != null) { - try { _runAsyncHead.fn(); } - catch (e, s) { _exceptionHandler(e, s); } + try { + _runAsyncHead.fn(); + } catch (e, s) { + _exceptionHandler(e, s); + } _runAsyncHead = _runAsyncHead._next; } digestTTL--; count = rootWatchGroup.detectChanges( - exceptionHandler: _exceptionHandler, - changeLog: changeLog); + exceptionHandler: _exceptionHandler, changeLog: changeLog); if (digestTTL <= LOG_COUNT) { if (changeLog == null) { @@ -281,7 +299,7 @@ class RootScope extends Scope { } } if (digestTTL == 0) { - throw 'Model did not stabilize in ${_ttl.ttl} digests. ' + + throw 'Model did not stabilize in ${_ttl.ttl} digests. ' 'Last $LOG_COUNT iterations:\n${log.join('\n')}'; } } while (count > 0); @@ -297,8 +315,12 @@ class RootScope extends Scope { try { do { while(_domWriteHead != null) { - try { _domWriteHead.fn(); } - catch (e, s) { _exceptionHandler(e, s); } + try { + _domWriteHead.fn(); + } + catch (e, s) { + _exceptionHandler(e, s); + } _domWriteHead = _domWriteHead._next; } if (runObservers) { @@ -306,8 +328,12 @@ class RootScope extends Scope { observeGroup.detectChanges(exceptionHandler:_exceptionHandler); } while(_domReadHead != null) { - try { _domReadHead.fn(); } - catch (e, s) { _exceptionHandler(e, s); } + try { + _domReadHead.fn(); + } + catch (e, s) { + _exceptionHandler(e, s); + } _domReadHead = _domReadHead._next; } } while (_domWriteHead != null || _domReadHead != null); @@ -357,7 +383,6 @@ class RootScope extends Scope { } } - void destroy() {} void _transitionState(String from, String to) { @@ -378,7 +403,7 @@ class RootScope extends Scope { * have one. But that means that we have to keep track if the stream belongs * to the node. * - * Scope with [_ScopeStreams] but who's [_scope] dose not match the scope + * Scope with [_ScopeStreams] but who's [_scope] does not match the scope * is only inherited * * Only [Scope] with [_ScopeStreams] who's [_scope] matches the [Scope] @@ -393,20 +418,20 @@ class _Streams { /// Scope we belong to. final Scope _scope; /// [Stream]s for [_scope] only - final Map _streams = new Map(); + final _streams = new Map(); /// Child [Scope] event counts. final Map _typeCounts; _Streams(this._scope, this._exceptionHandler, _Streams inheritStreams) : _typeCounts = inheritStreams == null - ? new Map() + ? {} : new Map.from(inheritStreams._typeCounts); static ScopeEvent emit(Scope scope, String name, data) { - ScopeEvent event = new ScopeEvent(name, scope, data); - Scope scopeCursor = scope; + var event = new ScopeEvent(name, scope, data); + var scopeCursor = scope; while(scopeCursor != null) { - if (scopeCursor._streams !=null && + if (scopeCursor._streams != null && scopeCursor._streams._scope == scopeCursor) { ScopeStream stream = scopeCursor._streams._streams[name]; if (stream != null) { @@ -422,10 +447,10 @@ class _Streams { static ScopeEvent broadcast(Scope scope, String name, data) { _Streams scopeStreams = scope._streams; - ScopeEvent event = new ScopeEvent(name, scope, data); + var event = new ScopeEvent(name, scope, data); if (scopeStreams != null && scopeStreams._typeCounts.containsKey(name)) { - Queue queue = new Queue()..addFirst(scopeStreams._scope); - while(queue.isNotEmpty) { + var queue = new Queue()..addFirst(scopeStreams._scope); + while (queue.isNotEmpty) { scope = queue.removeFirst(); scopeStreams = scope._streams; assert(scopeStreams._scope == scope); @@ -437,9 +462,7 @@ class _Streams { var childScope = scope._childTail; while(childScope != null) { scopeStreams = childScope._streams; - if (scopeStreams != null) { - queue.addFirst(scopeStreams._scope); - } + if (scopeStreams != null) queue.addFirst(scopeStreams._scope); childScope = childScope._prev; } } @@ -490,7 +513,7 @@ class _Streams { void _addCount(String name, int amount) { // decrement the counters on all parent scopes _Streams lastStreams = null; - Scope scope = _scope; + var scope = _scope; while (scope != null) { if (lastStreams != scope._streams) { // we have a transition, need to decrement it @@ -513,7 +536,7 @@ class ScopeStream extends async.Stream { final ExceptionHandler _exceptionHandler; final _Streams _streams; final String _name; - final List subscriptions = []; + final subscriptions = []; ScopeStream(this._streams, this._exceptionHandler, this._name); @@ -702,7 +725,7 @@ class ExpressionVisitor implements Visitor { } } -_operationToFunction(String operation) { +Function _operationToFunction(String operation) { switch(operation) { case '!' : return _operation_negate; case '+' : return _operation_add; @@ -759,12 +782,8 @@ class MapFn extends FunctionApply { apply(List values) { // TODO(misko): figure out why do we need to make a copy instead of reusing instance? - Map map = {}; assert(values.length == keys.length); - for(var i = 0; i < keys.length; i++) { - map[keys[i]] = values[i]; - } - return map; + return new Map.fromIterables(keys, values); } } @@ -791,8 +810,8 @@ class _FilterWrapper extends FunctionApply { var value = Function.apply(filterFn, args); if (value is Iterable) { // Since filters are pure we can guarantee that this well never change. - // By wrapping in UnmodifiableListView we can hint to the dirty checker and - // short circuit the iterator. + // By wrapping in UnmodifiableListView we can hint to the dirty checker + // and short circuit the iterator. value = new UnmodifiableListView(value); } return value; diff --git a/lib/directive/ng_pluralize.dart b/lib/directive/ng_pluralize.dart index da224595b..2bb3b4c0a 100644 --- a/lib/directive/ng_pluralize.dart +++ b/lib/directive/ng_pluralize.dart @@ -94,15 +94,15 @@ class NgPluralizeDirective { final Interpolate interpolate; final AstParser parser; int offset; - Map discreteRules = new Map(); - Map categoryRules = new Map(); + var discreteRules = {}; + var categoryRules = {}; static final RegExp IS_WHEN = new RegExp(r'^when-(minus-)?.'); NgPluralizeDirective(this.scope, this.element, this.interpolate, NodeAttrs attributes, this.parser) { - Map whens = attributes['when'] == null ? - {} : - scope.eval(attributes['when']); + Map whens = attributes['when'] == null + ? {} + : scope.eval(attributes['when']); offset = attributes['offset'] == null ? 0 : int.parse(attributes['offset']); element.attributes.keys.where((k) => IS_WHEN.hasMatch(k)).forEach((k) { @@ -157,7 +157,7 @@ class NgPluralizeDirective { var interpolation = interpolate(expression); interpolation.setter = (text) => element.text = text; interpolation.setter(expression); - List items = interpolation.expressions.map((exp) => parser(exp)).toList(); + var items = interpolation.expressions.map((exp) => parser(exp)).toList(); AST ast = new PureFunctionAST(expression, new ArrayFn(), items); scope.watch(ast, interpolation.call); } diff --git a/test/change_detection/dirty_checking_change_detector_spec.dart b/test/change_detection/dirty_checking_change_detector_spec.dart index 72a398a46..367a2fd96 100644 --- a/test/change_detection/dirty_checking_change_detector_spec.dart +++ b/test/change_detection/dirty_checking_change_detector_spec.dart @@ -26,14 +26,15 @@ main() => describe('DirtyCheckingChangeDetector', () { var user = new _User('', ''); var change; - detector.watch(user, 'first', null); - detector.watch(user, 'last', null); - detector.collectChanges(); // throw away first set + detector + ..watch(user, 'first', null) + ..watch(user, 'last', null) + ..collectChanges(); // throw away first set change = detector.collectChanges(); expect(change).toEqual(null); - user.first = 'misko'; - user.last = 'hevery'; + user..first = 'misko' + ..last = 'hevery'; change = detector.collectChanges(); expect(change.currentValue).toEqual('misko'); @@ -59,8 +60,7 @@ main() => describe('DirtyCheckingChangeDetector', () { it('should ignore NaN != NaN', () { var user = new _User(); user.age = double.NAN; - detector.watch(user, 'age', null); - detector.collectChanges(); // throw away first set + detector..watch(user, 'age', null)..collectChanges(); // throw away first set var changes = detector.collectChanges(); expect(changes).toEqual(null); @@ -121,7 +121,8 @@ main() => describe('DirtyCheckingChangeDetector', () { child2.watch(obj,'a', '2A'); obj['a'] = 1; - expect(detector.collectChanges(), toEqualChanges(['0a', '0A', '1a', '1A', '2A', '1b'])); + expect(detector.collectChanges(), + toEqualChanges(['0a', '0A', '1a', '1A', '2A', '1b'])); obj['a'] = 2; child1a.remove(); // should also remove child2 @@ -293,12 +294,11 @@ main() => describe('DirtyCheckingChangeDetector', () { detector.collectChanges(); list.insert(0, 'b'); expect(list).toEqual(['b', 'a', 'a', 'b', 'b']); - // todo(vbe) There is something wrong when running this test w/ karma -// expect(detector.collectChanges().currentValue, toEqualCollectionRecord( -// collection: ['b[2 -> 0]', 'a[0 -> 1]', 'a[1 -> 2]', 'b', 'b[null -> 4]'], -// additions: ['b[null -> 4]'], -// moves: ['b[2 -> 0]', 'a[0 -> 1]', 'a[1 -> 2]'], -// removals: [])); + expect(detector.collectChanges().currentValue, toEqualCollectionRecord( + collection: ['b[2 -> 0]', 'a[0 -> 1]', 'a[1 -> 2]', 'b', 'b[null -> 4]'], + additions: ['b[null -> 4]'], + moves: ['b[2 -> 0]', 'a[0 -> 1]', 'a[1 -> 2]'], + removals: [])); }); it('should support UnmodifiableListView', () { @@ -397,8 +397,7 @@ main() => describe('DirtyCheckingChangeDetector', () { it('should do basic operations', () { var k1 = 'a'; - var r1 = new ItemRecord(k1); - r1.currentKey = 1; + var r1 = new ItemRecord(k1)..currentIndex = 1; map.put(r1); expect(map.get(k1, 2)).toEqual(null); expect(map.get(k1, 1)).toEqual(null); @@ -409,12 +408,9 @@ main() => describe('DirtyCheckingChangeDetector', () { it('should do basic operations on duplicate keys', () { var k1 = 'a'; - var r1 = new ItemRecord(k1); - var r2 = new ItemRecord(k1); - r1.currentKey = 1; - r2.currentKey = 2; - map.put(r1); - map.put(r2); + var r1 = new ItemRecord(k1)..currentIndex = 1; + var r2 = new ItemRecord(k1)..currentIndex = 2; + map..put(r1)..put(r2); expect(map.get(k1, 0)).toEqual(r1); expect(map.get(k1, 1)).toEqual(r2); expect(map.get(k1, 2)).toEqual(null); @@ -439,7 +435,7 @@ Matcher toEqualCollectionRecord({collection, additions, moves, removals}) => moves:moves, removals:removals); Matcher toEqualMapRecord({map, additions, changes, removals}) => new MapRecordMatcher(map:map, additions:additions, - changes:changes, removals:removals); + changes:changes, removals:removals); Matcher toEqualChanges(List changes) => new ChangeMatcher(changes); class ChangeMatcher extends Matcher { @@ -447,9 +443,11 @@ class ChangeMatcher extends Matcher { ChangeMatcher(this.expected); - Description describe(Description description) => description..add(expected.toString()); + Description describe(Description description) => + description..add(expected.toString()); - Description describeMismatch(changes, Description mismatchDescription, Map matchState, bool verbose) { + Description describeMismatch(changes, Description mismatchDescription, + Map matchState, bool verbose) { List list = []; while(changes != null) { list.add(changes.handler); @@ -469,14 +467,16 @@ class ChangeMatcher extends Matcher { } class CollectionRecordMatcher extends Matcher { - List collection; - List additions; - List moves; - List removals; + final List collection; + final List additions; + final List moves; + final List removals; - CollectionRecordMatcher({this.collection, this.additions, this.moves, this.removals}); + CollectionRecordMatcher({this.collection, this.additions, this.moves, + this.removals}); - Description describeMismatch(changes, Description mismatchDescription, Map matchState, bool verbose) { + Description describeMismatch(changes, Description mismatchDescription, + Map matchState, bool verbose) { List diffs = matchState['diffs']; return mismatchDescription..add(diffs.join('\n')); } @@ -496,16 +496,14 @@ class CollectionRecordMatcher extends Matcher { } bool matches(CollectionChangeRecord changeRecord, Map matchState) { - List diffs = matchState['diffs'] = []; - var equals = true; - equals = equals && checkCollection(changeRecord, diffs); - equals = equals && checkAdditions(changeRecord, diffs); - equals = equals && checkMoves(changeRecord, diffs); - equals = equals && checkRemovals(changeRecord, diffs); - return equals; + var diffs = matchState['diffs'] = []; + return checkCollection(changeRecord, diffs) && + checkAdditions(changeRecord, diffs) && + checkMoves(changeRecord, diffs) && + checkRemovals(changeRecord, diffs); } - checkCollection(CollectionChangeRecord changeRecord, List diffs) { + bool checkCollection(CollectionChangeRecord changeRecord, List diffs) { var equals = true; if (collection != null) { CollectionItem collectionItem = changeRecord.collectionHead; @@ -529,7 +527,7 @@ class CollectionRecordMatcher extends Matcher { return equals; } - checkAdditions(CollectionChangeRecord changeRecord, List diffs) { + bool checkAdditions(CollectionChangeRecord changeRecord, List diffs) { var equals = true; if (additions != null) { AddedItem addedItem = changeRecord.additionsHead; @@ -553,7 +551,7 @@ class CollectionRecordMatcher extends Matcher { return equals; } - checkMoves(CollectionChangeRecord changeRecord, List diffs) { + bool checkMoves(CollectionChangeRecord changeRecord, List diffs) { var equals = true; if (moves != null) { MovedItem movedItem = changeRecord.movesHead; @@ -577,7 +575,7 @@ class CollectionRecordMatcher extends Matcher { return equals; } - checkRemovals(CollectionChangeRecord changeRecord, List diffs) { + bool checkRemovals(CollectionChangeRecord changeRecord, List diffs) { var equals = true; if (removals != null) { RemovedItem removedItem = changeRecord.removalsHead; @@ -603,14 +601,15 @@ class CollectionRecordMatcher extends Matcher { } class MapRecordMatcher extends Matcher { - List map; - List additions; - List changes; - List removals; + final List map; + final List additions; + final List changes; + final List removals; MapRecordMatcher({this.map, this.additions, this.changes, this.removals}); - Description describeMismatch(changes, Description mismatchDescription, Map matchState, bool verbose) { + Description describeMismatch(changes, Description mismatchDescription, + Map matchState, bool verbose) { List diffs = matchState['diffs']; return mismatchDescription..add(diffs.join('\n')); } @@ -630,16 +629,14 @@ class MapRecordMatcher extends Matcher { } bool matches(MapChangeRecord changeRecord, Map matchState) { - List diffs = matchState['diffs'] = []; - var equals = true; - equals = equals && checkMap(changeRecord, diffs); - equals = equals && checkAdditions(changeRecord, diffs); - equals = equals && checkChanges(changeRecord, diffs); - equals = equals && checkRemovals(changeRecord, diffs); - return equals; + var diffs = matchState['diffs'] = []; + return checkMap(changeRecord, diffs) && + checkAdditions(changeRecord, diffs) && + checkChanges(changeRecord, diffs) && + checkRemovals(changeRecord, diffs); } - checkMap(MapChangeRecord changeRecord, List diffs) { + bool checkMap(MapChangeRecord changeRecord, List diffs) { var equals = true; if (map != null) { KeyValue mapKeyValue = changeRecord.mapHead; @@ -663,7 +660,7 @@ class MapRecordMatcher extends Matcher { return equals; } - checkAdditions(MapChangeRecord changeRecord, List diffs) { + bool checkAdditions(MapChangeRecord changeRecord, List diffs) { var equals = true; if (additions != null) { AddedKeyValue addedKeyValue = changeRecord.additionsHead; @@ -687,7 +684,7 @@ class MapRecordMatcher extends Matcher { return equals; } - checkChanges(MapChangeRecord changeRecord, List diffs) { + bool checkChanges(MapChangeRecord changeRecord, List diffs) { var equals = true; if (changes != null) { ChangedKeyValue movedKeyValue = changeRecord.changesHead; @@ -711,7 +708,7 @@ class MapRecordMatcher extends Matcher { return equals; } - checkRemovals(MapChangeRecord changeRecord, List diffs) { + bool checkRemovals(MapChangeRecord changeRecord, List diffs) { var equals = true; if (removals != null) { RemovedKeyValue removedKeyValue = changeRecord.removalsHead; diff --git a/test/change_detection/watch_group_spec.dart b/test/change_detection/watch_group_spec.dart index cbe9dfd26..597b9ee77 100644 --- a/test/change_detection/watch_group_spec.dart +++ b/test/change_detection/watch_group_spec.dart @@ -620,7 +620,7 @@ class MyClass { count() => _count++; - toString() => 'MyClass'; + String toString() => 'MyClass'; } class LoggingFunctionApply extends FunctionApply {