| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Future apply(Transform transform) { | 41 Future apply(Transform transform) { |
| 42 return transform.primaryInput.readAsString().then((content) { | 42 return transform.primaryInput.readAsString().then((content) { |
| 43 var id = transform.primaryInput.id; | 43 var id = transform.primaryInput.id; |
| 44 // TODO(sigmund): improve how we compute this url | 44 // TODO(sigmund): improve how we compute this url |
| 45 var url = id.path.startsWith('lib/') | 45 var url = id.path.startsWith('lib/') |
| 46 ? 'package:${id.package}/${id.path.substring(4)}' : id.path; | 46 ? 'package:${id.package}/${id.path.substring(4)}' : id.path; |
| 47 var sourceFile = new SourceFile.text(url, content); | 47 var sourceFile = new SourceFile.text(url, content); |
| 48 var transaction = _transformCompilationUnit( | 48 var transaction = _transformCompilationUnit( |
| 49 content, sourceFile, transform.logger); | 49 content, sourceFile, transform.logger); |
| 50 if (!transaction.hasEdits) { | 50 if (!transaction.hasEdits) { |
| 51 transform.addOutput(input); | 51 transform.addOutput(transform.primaryInput); |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 var printer = transaction.commit(); | 54 var printer = transaction.commit(); |
| 55 // TODO(sigmund): emit source maps when barback supports it (see | 55 // TODO(sigmund): emit source maps when barback supports it (see |
| 56 // dartbug.com/12340) | 56 // dartbug.com/12340) |
| 57 printer.build(url); | 57 printer.build(url); |
| 58 transform.addOutput(new Asset.fromString(id, printer.text)); | 58 transform.addOutput(new Asset.fromString(id, printer.text)); |
| 59 }); | 59 }); |
| 60 } | 60 } |
| 61 } | 61 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 $type __\$$name$initializer; | 321 $type __\$$name$initializer; |
| 322 $type get $name => __\$$name; | 322 $type get $name => __\$$name; |
| 323 set $name($type value) { | 323 set $name($type value) { |
| 324 __\$$name = notifyPropertyChange(const Symbol('$name'), __\$$name, value); | 324 __\$$name = notifyPropertyChange(const Symbol('$name'), __\$$name, value); |
| 325 } | 325 } |
| 326 '''.replaceAll('\n', '\n$indent')); | 326 '''.replaceAll('\n', '\n$indent')); |
| 327 } | 327 } |
| 328 | 328 |
| 329 code.edit(begin, end, '$replace'); | 329 code.edit(begin, end, '$replace'); |
| 330 } | 330 } |
| OLD | NEW |