Chromium Code Reviews| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 // that is expensive in analyzer, so it isn't feasible yet. | 136 // that is expensive in analyzer, so it isn't feasible yet. |
| 137 bool _isObservableAnnotation(Annotation node) => | 137 bool _isObservableAnnotation(Annotation node) => |
| 138 _isAnnotationContant(node, 'observable') || | 138 _isAnnotationContant(node, 'observable') || |
| 139 _isAnnotationContant(node, 'published') || | 139 _isAnnotationContant(node, 'published') || |
| 140 _isAnnotationType(node, 'ObservableProperty') || | 140 _isAnnotationType(node, 'ObservableProperty') || |
| 141 _isAnnotationType(node, 'PublishedProperty'); | 141 _isAnnotationType(node, 'PublishedProperty'); |
| 142 | 142 |
| 143 bool _isAnnotationContant(Annotation m, String name) => | 143 bool _isAnnotationContant(Annotation m, String name) => |
| 144 m.name.name == name && m.constructorName == null && m.arguments == null; | 144 m.name.name == name && m.constructorName == null && m.arguments == null; |
| 145 | 145 |
| 146 bool _isAnnotationType(Annotation m, String name) => m.name == name; | 146 bool _isAnnotationType(Annotation m, String name) => m.name.name == name; |
|
Siggi Cherem (dart-lang)
2014/06/03 02:23:44
ouch!
Jennifer Messerly
2014/06/04 04:42:16
no kidding. doh!
| |
| 147 | 147 |
| 148 void _transformClass(ClassDeclaration cls, TextEditTransaction code, | 148 void _transformClass(ClassDeclaration cls, TextEditTransaction code, |
| 149 SourceFile file, TransformLogger logger) { | 149 SourceFile file, TransformLogger logger) { |
| 150 | 150 |
| 151 if (_hasObservable(cls)) { | 151 if (_hasObservable(cls)) { |
| 152 logger.warning('@observable on a class no longer has any effect. ' | 152 logger.warning('@observable on a class no longer has any effect. ' |
| 153 'It should be placed on individual fields.', | 153 'It should be placed on individual fields.', |
| 154 span: _getSpan(file, cls)); | 154 span: _getSpan(file, cls)); |
| 155 } | 155 } |
| 156 | 156 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 | 427 |
| 428 Token _findFieldSeperator(Token token) { | 428 Token _findFieldSeperator(Token token) { |
| 429 while (token != null) { | 429 while (token != null) { |
| 430 if (token.type == TokenType.COMMA || token.type == TokenType.SEMICOLON) { | 430 if (token.type == TokenType.COMMA || token.type == TokenType.SEMICOLON) { |
| 431 break; | 431 break; |
| 432 } | 432 } |
| 433 token = token.next; | 433 token = token.next; |
| 434 } | 434 } |
| 435 return token; | 435 return token; |
| 436 } | 436 } |
| OLD | NEW |