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 /// Code transform for @observable. The core transformation is relatively | 5 /// Code transform for @observable. The core transformation is relatively |
6 /// straightforward, and essentially like an editor refactoring. | 6 /// straightforward, and essentially like an editor refactoring. |
7 library observe.transformer; | 7 library observe.transformer; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // plausibly might need to be transformed. If not, we can avoid an | 66 // plausibly might need to be transformed. If not, we can avoid an |
67 // expensive parse. | 67 // expensive parse. |
68 if (!observableMatcher.hasMatch(content)) return null; | 68 if (!observableMatcher.hasMatch(content)) return null; |
69 | 69 |
70 var id = transform.primaryInput.id; | 70 var id = transform.primaryInput.id; |
71 // TODO(sigmund): improve how we compute this url | 71 // TODO(sigmund): improve how we compute this url |
72 var url = id.path.startsWith('lib/') | 72 var url = id.path.startsWith('lib/') |
73 ? 'package:${id.package}/${id.path.substring(4)}' : id.path; | 73 ? 'package:${id.package}/${id.path.substring(4)}' : id.path; |
74 var sourceFile = new SourceFile(content, url: url); | 74 var sourceFile = new SourceFile(content, url: url); |
75 var logger = new BuildLogger(transform, | 75 var logger = new BuildLogger(transform, |
76 convertErrorsToWarnings: !releaseMode); | 76 convertErrorsToWarnings: !releaseMode, |
| 77 detailsUri: 'http://goo.gl/5HPeuP'); |
77 var transaction = _transformCompilationUnit( | 78 var transaction = _transformCompilationUnit( |
78 content, sourceFile, logger); | 79 content, sourceFile, logger); |
79 if (!transaction.hasEdits) { | 80 if (!transaction.hasEdits) { |
80 transform.addOutput(transform.primaryInput); | 81 transform.addOutput(transform.primaryInput); |
81 } else { | 82 } else { |
82 var printer = transaction.commit(); | 83 var printer = transaction.commit(); |
83 // TODO(sigmund): emit source maps when barback supports it (see | 84 // TODO(sigmund): emit source maps when barback supports it (see |
84 // dartbug.com/12340) | 85 // dartbug.com/12340) |
85 printer.build(url); | 86 printer.build(url); |
86 transform.addOutput(new Asset.fromString(id, printer.text)); | 87 transform.addOutput(new Asset.fromString(id, printer.text)); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 token = token.next; | 404 token = token.next; |
404 } | 405 } |
405 return token; | 406 return token; |
406 } | 407 } |
407 | 408 |
408 // TODO(sigmund): remove hard coded Polymer support (@published). The proper way | 409 // TODO(sigmund): remove hard coded Polymer support (@published). The proper way |
409 // to do this would be to switch to use the analyzer to resolve whether | 410 // to do this would be to switch to use the analyzer to resolve whether |
410 // annotations are subtypes of ObservableProperty. | 411 // annotations are subtypes of ObservableProperty. |
411 final observableMatcher = | 412 final observableMatcher = |
412 new RegExp("@(published|observable|PublishedProperty|ObservableProperty)"); | 413 new RegExp("@(published|observable|PublishedProperty|ObservableProperty)"); |
OLD | NEW |