| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart Team. All rights reserved. Use of this | 1 // Copyright (c) 2015, the Dart Team. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in | 2 // source code is governed by a BSD-style license that can be found in |
| 3 // the LICENSE file. | 3 // the LICENSE file. |
| 4 | 4 |
| 5 /// File being transformed by the reflectable transformer. | 5 /// File being transformed by the reflectable transformer. |
| 6 /// Part of the entry point 'reflectors_test.dart'. | 6 /// Part of the entry point 'reflectors_test.dart'. |
| 7 /// | 7 /// |
| 8 /// Independence: The `ScopeMetaReflector` and `AllReflectorsMetaReflector` | 8 /// Independence: The `ScopeMetaReflector` and `AllReflectorsMetaReflector` |
| 9 /// classes are independent of the particular entry point 'reflectors_test.dart' | 9 /// classes are independent of the particular entry point 'reflectors_test.dart' |
| 10 /// and its transitive closure, it could be in a third-party package only | 10 /// and its transitive closure, it could be in a third-party package only |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 /// and it is assumed to return the set of reflectors which belong to the | 22 /// and it is assumed to return the set of reflectors which belong to the |
| 23 /// scope specified by the argument. | 23 /// scope specified by the argument. |
| 24 class ScopeMetaReflector extends Reflectable { | 24 class ScopeMetaReflector extends Reflectable { |
| 25 const ScopeMetaReflector() | 25 const ScopeMetaReflector() |
| 26 : super(const TopLevelInvokeMetaCapability(ScopeMetaReflector), | 26 : super(const TopLevelInvokeMetaCapability(ScopeMetaReflector), |
| 27 declarationsCapability, libraryCapability); | 27 declarationsCapability, libraryCapability); |
| 28 Set<Reflectable> reflectablesOfScope(String scope) { | 28 Set<Reflectable> reflectablesOfScope(String scope) { |
| 29 Set<Reflectable> result = new Set<Reflectable>(); | 29 Set<Reflectable> result = new Set<Reflectable>(); |
| 30 for (LibraryMirror library in libraries.values) { | 30 for (LibraryMirror library in libraries.values) { |
| 31 for (DeclarationMirror declaration in library.declarations.values) { | 31 for (DeclarationMirror declaration in library.declarations.values) { |
| 32 result.addAll(library.invoke(declaration.simpleName, [scope])); | 32 if (declaration is MethodMirror) { |
| 33 result.addAll(library.invoke(declaration.simpleName, [scope])); |
| 34 } |
| 33 } | 35 } |
| 34 } | 36 } |
| 35 return result; | 37 return result; |
| 36 } | 38 } |
| 37 } | 39 } |
| 38 | 40 |
| 39 /// Used to get access to all reflectors. | 41 /// Used to get access to all reflectors. |
| 40 class AllReflectorsMetaReflector extends Reflectable { | 42 class AllReflectorsMetaReflector extends Reflectable { |
| 41 const AllReflectorsMetaReflector() | 43 const AllReflectorsMetaReflector() |
| 42 : super(subtypeQuantifyCapability, newInstanceCapability); | 44 : super(subtypeQuantifyCapability, newInstanceCapability); |
| 43 | 45 |
| 44 Set<Reflectable> get reflectors { | 46 Set<Reflectable> get reflectors { |
| 45 Set<Reflectable> result = new Set<Reflectable>(); | 47 Set<Reflectable> result = new Set<Reflectable>(); |
| 46 annotatedClasses.forEach((ClassMirror classMirror) { | 48 annotatedClasses.forEach((ClassMirror classMirror) { |
| 47 if (classMirror.isAbstract) return; | 49 if (classMirror.isAbstract) return; |
| 48 Reflectable reflector = | 50 Reflectable reflector = |
| 49 Reflectable.getInstance(classMirror.reflectedType); | 51 Reflectable.getInstance(classMirror.reflectedType); |
| 50 if (reflector != null) result.add(reflector); | 52 if (reflector != null) result.add(reflector); |
| 51 }); | 53 }); |
| 52 return result; | 54 return result; |
| 53 } | 55 } |
| 54 } | 56 } |
| OLD | NEW |