run dartformat
diff --git a/lib/src/mirror_loader.dart b/lib/src/mirror_loader.dart
index 2c62312..1a76de5 100644
--- a/lib/src/mirror_loader.dart
+++ b/lib/src/mirror_loader.dart
@@ -32,8 +32,8 @@
/// Queue for pending intialization functions to run.
final _initQueue = new Queue<Function>();
- StaticInitializationCrawler(
- this.typeFilter, this.customFilter, {LibraryMirror root}) {
+ StaticInitializationCrawler(this.typeFilter, this.customFilter,
+ {LibraryMirror root}) {
_root = root == null ? currentMirrorSystem().isolate.rootLibrary : root;
}
@@ -70,51 +70,47 @@
_readAnnotations(lib);
// Last, parse all class and method annotations.
- lib .declarations
- .values
+ lib.declarations.values
.where((d) => d is ClassMirror || d is MethodMirror)
.forEach((DeclarationMirror d) => _readAnnotations(d));
}
void _readAnnotations(DeclarationMirror declaration) {
- declaration
- .metadata
- .where((m) {
- if (m.reflectee is! StaticInitializer) return false;
- if (typeFilter != null &&
- !typeFilter.any((t) => m.reflectee.runtimeType == t)) {
- return false;
- }
- if (customFilter != null && !customFilter(m.reflectee)) return false;
- return true;
- })
- .forEach((meta) {
- if (!_annotationsFound.containsKey(declaration)) {
- _annotationsFound[declaration] = new Set<InstanceMirror>();
- }
- if (_annotationsFound[declaration].contains(meta)) return;
- _annotationsFound[declaration].add(meta);
+ declaration.metadata.where((m) {
+ if (m.reflectee is! StaticInitializer) return false;
+ if (typeFilter != null &&
+ !typeFilter.any((t) => m.reflectee.runtimeType == t)) {
+ return false;
+ }
+ if (customFilter != null && !customFilter(m.reflectee)) return false;
+ return true;
+ }).forEach((meta) {
+ if (!_annotationsFound.containsKey(declaration)) {
+ _annotationsFound[declaration] = new Set<InstanceMirror>();
+ }
+ if (_annotationsFound[declaration].contains(meta)) return;
+ _annotationsFound[declaration].add(meta);
- // Initialize super classes first, this is the only exception to the
- // post-order rule.
- if (declaration is ClassMirror && declaration.superclass != null) {
- _readAnnotations(declaration.superclass);
- }
+ // Initialize super classes first, this is the only exception to the
+ // post-order rule.
+ if (declaration is ClassMirror && declaration.superclass != null) {
+ _readAnnotations(declaration.superclass);
+ }
- var annotatedValue;
- if (declaration is ClassMirror) {
- annotatedValue = declaration.reflectedType;
- } else if (declaration is MethodMirror) {
- if (!declaration.isStatic) {
- throw new UnsupportedError(
- 'Only static methods are supported for StaticInitializers');
- }
- annotatedValue = (declaration.owner as ObjectMirror)
- .getField(declaration.simpleName).reflectee;
- } else {
- annotatedValue = declaration.qualifiedName;
- }
- _initQueue.addLast(() => meta.reflectee.initialize(annotatedValue));
- });
+ var annotatedValue;
+ if (declaration is ClassMirror) {
+ annotatedValue = declaration.reflectedType;
+ } else if (declaration is MethodMirror) {
+ if (!declaration.isStatic) {
+ throw new UnsupportedError(
+ 'Only static methods are supported for StaticInitializers');
+ }
+ annotatedValue = (declaration.owner as ObjectMirror)
+ .getField(declaration.simpleName).reflectee;
+ } else {
+ annotatedValue = declaration.qualifiedName;
+ }
+ _initQueue.addLast(() => meta.reflectee.initialize(annotatedValue));
+ });
}
}
diff --git a/test/bar.dart b/test/bar.dart
index 22ae8a6..93ad0dc 100644
--- a/test/bar.dart
+++ b/test/bar.dart
@@ -4,7 +4,7 @@
@initializeTracker
library static_init.test.bar;
-import 'foo.dart'; // Make sure cycles are ok.
+import 'foo.dart'; // Make sure cycles are ok.
import 'initialize_tracker.dart';
// Foo should be initialized first.
diff --git a/test/init_method_test.dart b/test/init_method_test.dart
index b1eb45c..a641948 100644
--- a/test/init_method_test.dart
+++ b/test/init_method_test.dart
@@ -15,7 +15,6 @@
// Run all static initializers.
run().then((_) {
-
test('initMethod annotation invokes functions once', () {
expect(calledFoo, 1);
expect(calledBar, 1);
@@ -25,7 +24,6 @@
expect(calledBar, 1);
});
});
-
});
}
diff --git a/test/static_init_custom_filter_test.dart b/test/static_init_custom_filter_test.dart
index 43f4ab6..49a9749 100644
--- a/test/static_init_custom_filter_test.dart
+++ b/test/static_init_custom_filter_test.dart
@@ -25,19 +25,21 @@
expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]);
}).then((_) {
originalSize = InitializeTracker.seen.length;
- }).then((_) => runPhase(1))
- .then((_) => runPhase(2))
- .then((_) => runPhase(3))
- .then((_) => runPhase(4))
- .then((_) => run()).then((_) {
+ })
+ .then((_) => runPhase(1))
+ .then((_) => runPhase(2))
+ .then((_) => runPhase(3))
+ .then((_) => runPhase(4))
+ .then((_) => run())
+ .then((_) {
expect(InitializeTracker.seen.length, originalSize);
});
});
}
-Future runPhase(int phase) =>
- run(customFilter: (StaticInitializer meta) =>
- meta is PhasedInitializer && meta.phase == phase);
+Future runPhase(int phase) => run(
+ customFilter: (StaticInitializer meta) =>
+ meta is PhasedInitializer && meta.phase == phase);
@PhasedInitializer(3)
class Foo {}
diff --git a/test/static_init_test.dart b/test/static_init_test.dart
index f8d0d5e..3fed3c8 100644
--- a/test/static_init_test.dart
+++ b/test/static_init_test.dart
@@ -15,12 +15,20 @@
// Run all static initializers.
run().then((_) {
-
test('annotations are seen in post-order with superclasses first', () {
// Foo comes first because its a superclass of Bar.
- var expectedNames = [#static_init.test.bar, Foo, Bar, bar,
- #static_init.test.foo, fooBar, foo, #static_init.static_init_test,
- zap, Zap];
+ var expectedNames = [
+ #static_init.test.bar,
+ Foo,
+ Bar,
+ bar,
+ #static_init.test.foo,
+ fooBar,
+ foo,
+ #static_init.static_init_test,
+ zap,
+ Zap
+ ];
expect(InitializeTracker.seen, expectedNames);
});
@@ -31,7 +39,6 @@
expect(InitializeTracker.seen.length, originalSize);
});
});
-
});
}