| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Code transform for @observable. The core transformation is relatively | 6 * Code transform for @observable. The core transformation is relatively |
| 7 * straightforward, and essentially like an editor refactoring. | 7 * straightforward, and essentially like an editor refactoring. |
| 8 */ | 8 */ |
| 9 library observe.transform; | 9 library observe.transform; |
| 10 | 10 |
| 11 import 'dart:async'; | 11 import 'dart:async'; |
| 12 | 12 |
| 13 import 'package:analyzer_experimental/src/generated/ast.dart'; | 13 import 'package:analyzer_experimental/src/generated/ast.dart'; |
| 14 import 'package:analyzer_experimental/src/generated/error.dart'; | 14 import 'package:analyzer_experimental/src/generated/error.dart'; |
| 15 import 'package:analyzer_experimental/src/generated/parser.dart'; | 15 import 'package:analyzer_experimental/src/generated/parser.dart'; |
| 16 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 16 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
| 17 import 'package:barback/barback.dart'; | 17 import 'package:barback/barback.dart'; |
| 18 import 'package:path/path.dart' as path; | |
| 19 import 'package:source_maps/refactor.dart'; | 18 import 'package:source_maps/refactor.dart'; |
| 20 import 'package:source_maps/span.dart' show SourceFile; | 19 import 'package:source_maps/span.dart' show SourceFile; |
| 21 | 20 |
| 22 /** | 21 /** |
| 23 * A [Transformer] that replaces observables based on dirty-checking with an | 22 * A [Transformer] that replaces observables based on dirty-checking with an |
| 24 * implementation based on change notifications. | 23 * implementation based on change notifications. |
| 25 * | 24 * |
| 26 * The transformation adds hooks for field setters and notifies the observation | 25 * The transformation adds hooks for field setters and notifies the observation |
| 27 * system of the change. | 26 * system of the change. |
| 28 */ | 27 */ |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 $type __\$$name$initializer; | 320 $type __\$$name$initializer; |
| 322 $type get $name => __\$$name; | 321 $type get $name => __\$$name; |
| 323 set $name($type value) { | 322 set $name($type value) { |
| 324 __\$$name = notifyPropertyChange(const Symbol('$name'), __\$$name, value); | 323 __\$$name = notifyPropertyChange(const Symbol('$name'), __\$$name, value); |
| 325 } | 324 } |
| 326 '''.replaceAll('\n', '\n$indent')); | 325 '''.replaceAll('\n', '\n$indent')); |
| 327 } | 326 } |
| 328 | 327 |
| 329 code.edit(begin, end, '$replace'); | 328 code.edit(begin, end, '$replace'); |
| 330 } | 329 } |
| OLD | NEW |