| 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. You can find the | 7 * straightforward, and essentially like an editor refactoring. You can find the |
| 8 * core implementation in [transformClass], which is ultimately called by | 8 * core implementation in [transformClass], which is ultimately called by |
| 9 * [transformObservables], the entry point to this library. | 9 * [transformObservables], the entry point to this library. |
| 10 */ | 10 */ |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void transformTopLevelField(TopLevelVariableDeclaration field, | 118 void transformTopLevelField(TopLevelVariableDeclaration field, |
| 119 TextEditTransaction code, Set<String> changedFields) { | 119 TextEditTransaction code, Set<String> changedFields) { |
| 120 | 120 |
| 121 transformFields(field.variables, code, field.offset, field.end, | 121 transformFields(field.variables, code, field.offset, field.end, |
| 122 isTopLevel: true, changedFields: changedFields); | 122 isTopLevel: true, changedFields: changedFields); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void transformClassFields(FieldDeclaration member, TextEditTransaction code, | 125 void transformClassFields(FieldDeclaration member, TextEditTransaction code, |
| 126 Set<String> instanceFields, Set<String> staticFields) { | 126 Set<String> instanceFields, Set<String> staticFields) { |
| 127 | 127 |
| 128 bool isStatic = hasKeyword(member.keyword, Keyword.STATIC); | |
| 129 transformFields(member.fields, code, member.offset, member.end, | 128 transformFields(member.fields, code, member.offset, member.end, |
| 130 isStatic: isStatic, | 129 isStatic: member.isStatic, |
| 131 changedFields: isStatic ? staticFields : instanceFields); | 130 changedFields: member.isStatic ? staticFields : instanceFields); |
| 132 } | 131 } |
| 133 | 132 |
| 134 | 133 |
| 135 void fixConstructor(ConstructorDeclaration ctor, TextEditTransaction code, | 134 void fixConstructor(ConstructorDeclaration ctor, TextEditTransaction code, |
| 136 Set<String> changedFields) { | 135 Set<String> changedFields) { |
| 137 | 136 |
| 138 // Fix normal initializers | 137 // Fix normal initializers |
| 139 for (var initializer in ctor.initializers) { | 138 for (var initializer in ctor.initializers) { |
| 140 if (initializer is ConstructorFieldInitializer) { | 139 if (initializer is ConstructorFieldInitializer) { |
| 141 var field = initializer.fieldName; | 140 var field = initializer.fieldName; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 __\$$name, value); | 241 __\$$name, value); |
| 243 } | 242 } |
| 244 __\$$name = value; | 243 __\$$name = value; |
| 245 }'''.replaceAll('\n', '\n$indent')); | 244 }'''.replaceAll('\n', '\n$indent')); |
| 246 | 245 |
| 247 if (changedFields != null) changedFields.add(name); | 246 if (changedFields != null) changedFields.add(name); |
| 248 } | 247 } |
| 249 | 248 |
| 250 code.edit(begin, end, '$replace'); | 249 code.edit(begin, end, '$replace'); |
| 251 } | 250 } |
| OLD | NEW |