| Index: test_reflectable/test/meta_reflectors_scoping.dart
|
| diff --git a/test_reflectable/test/meta_reflectors_scoping.dart b/test_reflectable/test/meta_reflectors_scoping.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ebcec500a2eb6b042e72076e189a97634e936df4
|
| --- /dev/null
|
| +++ b/test_reflectable/test/meta_reflectors_scoping.dart
|
| @@ -0,0 +1,35 @@
|
| +// Copyright (c) 2015, the Dart Team. All rights reserved. Use of this
|
| +// source code is governed by a BSD-style license that can be found in
|
| +// the LICENSE file.
|
| +
|
| +// File being transformed by the reflectable transformer.
|
| +// Part of the entry point 'reflectors_test.dart'.
|
| +//
|
| +// Independence: The `MetaReflector` class is independent of the particular
|
| +// entry point 'reflectors_test.dart' and its transitive closure, it could be
|
| +// in a third-party package only depending on reflectable.
|
| +
|
| +library test_reflectable.test.meta_reflectors_scoping;
|
| +
|
| +import 'package:reflectable/reflectable.dart';
|
| +
|
| +/// Used to provide access to reflectors associated with a given scope,
|
| +/// which is a [String]. The connection is created by top level functions
|
| +/// in the program with the annotation `@MetaReflector()`. Such a function
|
| +/// must have type `F` where `typedef Iterable<Reflectable> F(String _)`,
|
| +/// and it is assumed to return the set of reflectors which belong to the
|
| +/// scope specified by the argument.
|
| +class ScopeMetaReflector extends Reflectable {
|
| + const ScopeMetaReflector()
|
| + : super(const TopLevelInvokeMetaCapability(ScopeMetaReflector),
|
| + declarationsCapability, libraryCapability);
|
| + Set<Reflectable> reflectablesOfScope(String scope) {
|
| + Set<Reflectable> result = new Set<Reflectable>();
|
| + for (LibraryMirror library in libraries.values) {
|
| + for (DeclarationMirror declaration in library.declarations.values) {
|
| + result.addAll(library.invoke(declaration.simpleName, [scope]));
|
| + }
|
| + }
|
| + return result;
|
| + }
|
| +}
|
|
|