| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 var pos = cls.extendsClause.end; | 249 var pos = cls.extendsClause.end; |
| 250 code.edit(pos, pos, ' with ChangeNotifier '); | 250 code.edit(pos, pos, ' with ChangeNotifier '); |
| 251 } else { | 251 } else { |
| 252 var params = cls.typeParameters; | 252 var params = cls.typeParameters; |
| 253 var pos = params != null ? params.end : cls.name.end; | 253 var pos = params != null ? params.end : cls.name.end; |
| 254 code.edit(pos, pos, ' extends ChangeNotifier '); | 254 code.edit(pos, pos, ' extends ChangeNotifier '); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 SimpleIdentifier _getSimpleIdentifier(Identifier id) => | 258 SimpleIdentifier _getSimpleIdentifier(Identifier id) => |
| 259 id is PrefixedIdentifier ? (id as PrefixedIdentifier).identifier : id; | 259 id is PrefixedIdentifier ? id.identifier : id; |
| 260 | 260 |
| 261 | 261 |
| 262 bool _hasKeyword(Token token, Keyword keyword) => | 262 bool _hasKeyword(Token token, Keyword keyword) => |
| 263 token is KeywordToken && (token as KeywordToken).keyword == keyword; | 263 token is KeywordToken && token.keyword == keyword; |
| 264 | 264 |
| 265 String _getOriginalCode(TextEditTransaction code, ASTNode node) => | 265 String _getOriginalCode(TextEditTransaction code, ASTNode node) => |
| 266 code.original.substring(node.offset, node.end); | 266 code.original.substring(node.offset, node.end); |
| 267 | 267 |
| 268 void _fixConstructor(ConstructorDeclaration ctor, TextEditTransaction code, | 268 void _fixConstructor(ConstructorDeclaration ctor, TextEditTransaction code, |
| 269 Set<String> changedFields) { | 269 Set<String> changedFields) { |
| 270 | 270 |
| 271 // Fix normal initializers | 271 // Fix normal initializers |
| 272 for (var initializer in ctor.initializers) { | 272 for (var initializer in ctor.initializers) { |
| 273 if (initializer is ConstructorFieldInitializer) { | 273 if (initializer is ConstructorFieldInitializer) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 Token _findFieldSeperator(Token token) { | 407 Token _findFieldSeperator(Token token) { |
| 408 while (token != null) { | 408 while (token != null) { |
| 409 if (token.type == TokenType.COMMA || token.type == TokenType.SEMICOLON) { | 409 if (token.type == TokenType.COMMA || token.type == TokenType.SEMICOLON) { |
| 410 break; | 410 break; |
| 411 } | 411 } |
| 412 token = token.next; | 412 token = token.next; |
| 413 } | 413 } |
| 414 return token; | 414 return token; |
| 415 } | 415 } |
| OLD | NEW |