OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library initialize.transformer; | 4 library initialize.transformer; |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (seen.contains(library)) continue; | 208 if (seen.contains(library)) continue; |
209 _readLibraries(library, seen); | 209 _readLibraries(library, seen); |
210 } | 210 } |
211 | 211 |
212 // Read annotations in this order: library, top level methods, classes. | 212 // Read annotations in this order: library, top level methods, classes. |
213 _readAnnotations(library); | 213 _readAnnotations(library); |
214 for (var method in _topLevelMethodsOfLibrary(library, seen)) { | 214 for (var method in _topLevelMethodsOfLibrary(library, seen)) { |
215 _readAnnotations(method); | 215 _readAnnotations(method); |
216 } | 216 } |
217 for (var clazz in _classesOfLibrary(library, seen)) { | 217 for (var clazz in _classesOfLibrary(library, seen)) { |
218 var superClass = clazz.supertype; | 218 readSuperClassAnnotations(InterfaceType superClass) { |
219 while (superClass != null) { | 219 if (superClass == null) return; |
| 220 readSuperClassAnnotations(superClass.superclass); |
220 if (_readAnnotations(superClass.element) && | 221 if (_readAnnotations(superClass.element) && |
221 superClass.element.library != clazz.library) { | 222 superClass.element.library != clazz.library) { |
222 _logger.warning( | 223 _logger.warning( |
223 'We have detected a cycle in your import graph when running ' | 224 'We have detected a cycle in your import graph when running ' |
224 'initializers on ${clazz.name}. This means the super class ' | 225 'initializers on ${clazz.name}. This means the super class ' |
225 '${superClass.name} has a dependency on this library ' | 226 '${superClass.name} has a dependency on this library ' |
226 '(possibly transitive).'); | 227 '(possibly transitive).'); |
227 } | 228 } |
228 superClass = superClass.superclass; | |
229 } | 229 } |
| 230 readSuperClassAnnotations(clazz.supertype); |
230 _readAnnotations(clazz); | 231 _readAnnotations(clazz); |
231 } | 232 } |
232 } | 233 } |
233 | 234 |
234 bool _readAnnotations(Element element) { | 235 bool _readAnnotations(Element element) { |
235 var found = false; | 236 var found = false; |
236 if (element.metadata.isEmpty) return found; | 237 if (element.metadata.isEmpty) return found; |
237 | 238 |
238 var metaNodes; | 239 var metaNodes; |
239 var node = element.node; | 240 var node = element.node; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 error = false; | 455 error = false; |
455 } else { | 456 } else { |
456 error = true; | 457 error = true; |
457 } | 458 } |
458 if (error) { | 459 if (error) { |
459 print('Bad value for "$field" in the initialize transformer. ' | 460 print('Bad value for "$field" in the initialize transformer. ' |
460 'Expected either one String or a list of Strings.'); | 461 'Expected either one String or a list of Strings.'); |
461 } | 462 } |
462 return files; | 463 return files; |
463 } | 464 } |
OLD | NEW |