Skip to content
This repository was archived by the owner on Jan 20, 2018. It is now read-only.

Commit 515f2ae

Browse files
authored
Publish 0.6.2+7 (#59)
* prepare for 0.6.2+7 * dartfmt
1 parent eacce6c commit 515f2ae

16 files changed

+103
-53
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.2+7
2+
3+
* Strong mode fixes.
4+
15
## 0.6.2+6
26

37
* Small bug fixes for https://github.com/dart-lang/web-components/issues/54.

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
analyzer:
2+
strong-mode: true

lib/build/initializer_plugin.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class DefaultInitializerPlugin implements InitializerPlugin {
235235
buffer.write(_evaluateExpression(expression, pluginData));
236236
} else {
237237
libraryPrefixes.putIfAbsent(
238-
element.library, () => 'i${libraryPrefixes.length}');
238+
element.library, () => 'i${libraryPrefixes.length}');
239239

240240
buffer.write('${libraryPrefixes[element.library]}.');
241241
if (element is ClassElement) {
@@ -263,8 +263,7 @@ class DefaultInitializerPlugin implements InitializerPlugin {
263263
return buffer.toString();
264264
}
265265

266-
_evaluateExpression(
267-
Expression expression, InitializerPluginData pluginData) {
266+
_evaluateExpression(Expression expression, InitializerPluginData pluginData) {
268267
var logger = pluginData.logger;
269268
var result = pluginData.resolver.evaluateConstant(
270269
pluginData.initializer.targetElement.library, expression);

lib/src/init_method.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ part of initialize;
88
/// it shouldn't be used directly in annotations, instead use the `initMethod`
99
/// singleton below.
1010
typedef dynamic _ZeroArg();
11+
1112
class _InitMethod implements Initializer<_ZeroArg> {
1213
const _InitMethod();
1314

lib/src/initializer.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class LibraryIdentifier {
4242
const LibraryIdentifier(this.name, this.package, this.path);
4343

4444
bool operator ==(dynamic other) =>
45-
other is LibraryIdentifier && name == other.name && package == other.package &&
45+
other is LibraryIdentifier &&
46+
name == other.name &&
47+
package == other.package &&
4648
path == other.path;
4749

4850
String toString() => '$name: $package:$path';

lib/src/mirror_loader.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class InitializationCrawler {
3737
/// Note: The [from] argument is only supported in the mirror_loader.dart. It
3838
/// is not supported statically.
3939
InitializationCrawler(this.typeFilter, this.customFilter, {Uri from})
40-
: _rootLibrary = from == null
41-
? _root
42-
: _libs[from] {
40+
: _rootLibrary = from == null ? _root : _libs[from] {
4341
if (_rootLibrary == null) throw 'Unable to find library at $from.';
4442
}
4543

@@ -124,10 +122,14 @@ class InitializationCrawler {
124122
Iterable<DeclarationMirror> _sortedDeclarationsWithMetadata(
125123
LibraryMirror lib) {
126124
return new List()
127-
..addAll(_sortDeclarations(lib, lib.declarations.values
128-
.where((d) => d is MethodMirror && d.metadata.isNotEmpty)))
129-
..addAll(_sortDeclarations(lib, lib.declarations.values
130-
.where((d) => d is ClassMirror && d.metadata.isNotEmpty)));
125+
..addAll(_sortDeclarations(
126+
lib,
127+
lib.declarations.values
128+
.where((d) => d is MethodMirror && d.metadata.isNotEmpty)))
129+
..addAll(_sortDeclarations(
130+
lib,
131+
lib.declarations.values
132+
.where((d) => d is ClassMirror && d.metadata.isNotEmpty)));
131133
}
132134

133135
List<DeclarationMirror> _sortDeclarations(
@@ -202,7 +204,8 @@ class InitializationCrawler {
202204
throw _TOP_LEVEL_FUNCTIONS_ONLY;
203205
}
204206
annotatedValue = (declaration.owner as ObjectMirror)
205-
.getField(declaration.simpleName).reflectee;
207+
.getField(declaration.simpleName)
208+
.reflectee;
206209
} else if (declaration is LibraryMirror) {
207210
var package;
208211
var filePath;

lib/transformer.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ class InitializeTransformer extends Transformer {
129129
// [entryPoint].
130130
void _replaceEntryWithBootstrap(Transform transform, dom.Document document,
131131
AssetId entryPoint, AssetId originalDartFile, AssetId newDartFile) {
132-
var scripts = _getScripts(document)
133-
.where((script) {
132+
var scripts = _getScripts(document).where((script) {
134133
var assetId = uriToAssetId(entryPoint, _getScriptAttribute(script),
135134
transform.logger, script.sourceSpan);
136135
return assetId == originalDartFile;
@@ -258,6 +257,7 @@ class _BootstrapFileBuilder {
258257
'(possibly transitive).');
259258
}
260259
}
260+
261261
readSuperClassAnnotations(clazz.supertype);
262262
_readAnnotations(clazz);
263263
}
@@ -285,7 +285,8 @@ class _BootstrapFileBuilder {
285285
if (e is PropertyAccessorElement) {
286286
// 'as dynamic' is because evaluationResult is a property on an impl class, e.g. one that
287287
// isn't supposed to be used externally.
288-
return _isInitializer((e.variable as dynamic).evaluationResult.value.type);
288+
return _isInitializer(
289+
(e.variable as dynamic).evaluationResult.value.type);
289290
} else if (e is ConstructorElement) {
290291
return _isInitializer(e.returnType);
291292
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: initialize
2-
version: 0.6.2+6
2+
version: 0.6.2+7
33
author: Polymer.dart Authors <[email protected]>
44
description: Generic building blocks for doing static initialization.
55
homepage: https://github.com/dart-lang/initialize

test/deferred_library_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ main() {
2424
expect(InitializeTracker.seen.length, 5);
2525
});
2626
});
27-
}, skip: 'Should be skipped only in pub-serve mode, blocked on '
28-
'https://github.com/dart-lang/test/issues/388.');
27+
},
28+
skip: 'Should be skipped only in pub-serve mode, blocked on '
29+
'https://github.com/dart-lang/test/issues/388.');
2930
}

test/initializer_custom_filter_test.dart

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,34 @@ import 'package:initialize/src/initialize_tracker.dart';
1515
main() {
1616
test('filter option limits which types of annotations will be ran', () {
1717
var originalSize;
18-
return runPhase(1).then((_) {
19-
// Even though Baz extends Bar, only Baz should be run.
20-
expect(InitializeTracker.seen, [Baz]);
21-
}).then((_) => runPhase(2)).then((_) {
22-
expect(InitializeTracker.seen, [Baz, foo]);
23-
}).then((_) => runPhase(3)).then((_) {
24-
expect(InitializeTracker.seen, [Baz, foo, Foo]);
25-
}).then((_) => runPhase(4)).then((_) {
26-
expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]);
27-
}).then((_) {
28-
originalSize = InitializeTracker.seen.length;
29-
})
18+
return runPhase(1)
19+
.then((_) {
20+
// Even though Baz extends Bar, only Baz should be run.
21+
expect(InitializeTracker.seen, [Baz]);
22+
})
23+
.then((_) => runPhase(2))
24+
.then((_) {
25+
expect(InitializeTracker.seen, [Baz, foo]);
26+
})
27+
.then((_) => runPhase(3))
28+
.then((_) {
29+
expect(InitializeTracker.seen, [Baz, foo, Foo]);
30+
})
31+
.then((_) => runPhase(4))
32+
.then((_) {
33+
expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]);
34+
})
35+
.then((_) {
36+
originalSize = InitializeTracker.seen.length;
37+
})
3038
.then((_) => runPhase(1))
3139
.then((_) => runPhase(2))
3240
.then((_) => runPhase(3))
3341
.then((_) => runPhase(4))
3442
.then((_) => run())
3543
.then((_) {
36-
expect(InitializeTracker.seen.length, originalSize);
37-
});
44+
expect(InitializeTracker.seen.length, originalSize);
45+
});
3846
});
3947
}
4048

test/initializer_cycle_error_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:test/test.dart';
1515
main() {
1616
test('super class cycles are not supported', () {
1717
expect(run, throwsUnsupportedError);
18-
}, skip: 'Should be skipped only in pub-serve mode, blocked on '
19-
'https://github.com/dart-lang/test/issues/388.');
18+
},
19+
skip: 'Should be skipped only in pub-serve mode, blocked on '
20+
'https://github.com/dart-lang/test/issues/388.');
2021
}

test/initializer_from_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ main() {
2929
expect(InitializeTracker.seen.length, 2);
3030
// Don't know what the path will be, so have to explicitly check fields
3131
// and use an [endsWith] matcher for the path.
32-
expect(InitializeTracker.seen[1].name,
33-
#initialize.test.initializer_from_test);
32+
expect(
33+
InitializeTracker.seen[1].name, #initialize.test.initializer_from_test);
3434
expect(InitializeTracker.seen[1].package, isNull);
3535
expect(
3636
InitializeTracker.seen[1].path, endsWith('initializer_from_test.dart'));
37-
}, skip: 'Should be skipped only in pub-serve mode, blocked on '
38-
'https://github.com/dart-lang/test/issues/388.');
37+
},
38+
skip: 'Should be skipped only in pub-serve mode, blocked on '
39+
'https://github.com/dart-lang/test/issues/388.');
3940
}

test/initializer_super_test.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ main() {
1515
// Run all initializers.
1616
return run().then((_) {
1717
test('annotations are seen in post-order with superclasses first', () {
18-
var expectedNames = [A, C, B, E, D,];
18+
var expectedNames = [
19+
A,
20+
C,
21+
B,
22+
E,
23+
D,
24+
];
1925
expect(InitializeTracker.seen, expectedNames);
2026
});
2127
});

test/initializer_type_filter_test.dart

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@ main() {
2020
});
2121

2222
test('filter option limits which types of annotations will be ran', () {
23-
return run(typeFilter: const [_Adder]).then((_) {
24-
expect(total, 2);
25-
}).then((_) => run(typeFilter: const [_Subtractor])).then((_) {
26-
expect(total, 0);
27-
}).then((_) => run(typeFilter: const [_Adder])).then((_) {
28-
// Sanity check, future calls should be no-ops
29-
expect(total, 0);
30-
}).then((_) => run(typeFilter: const [_Subtractor])).then((_) {
31-
expect(total, 0);
32-
});
23+
return run(typeFilter: const [_Adder])
24+
.then((_) {
25+
expect(total, 2);
26+
})
27+
.then((_) => run(typeFilter: const [_Subtractor]))
28+
.then((_) {
29+
expect(total, 0);
30+
})
31+
.then((_) => run(typeFilter: const [_Adder]))
32+
.then((_) {
33+
// Sanity check, future calls should be no-ops
34+
expect(total, 0);
35+
})
36+
.then((_) => run(typeFilter: const [_Subtractor]))
37+
.then((_) {
38+
expect(total, 0);
39+
});
3340
});
3441
}
3542

@@ -48,6 +55,7 @@ class _Adder implements Initializer<dynamic> {
4855
@override
4956
initialize(_) => total++;
5057
}
58+
5159
const adder = const _Adder();
5260

5361
// Initializer that decrements `total` by one.
@@ -57,4 +65,5 @@ class _Subtractor implements Initializer<dynamic> {
5765
@override
5866
initialize(_) => total--;
5967
}
68+
6069
const subtractor = const _Subtractor();

test/transformer_test.dart

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ main() {
1919
}
2020

2121
void htmlEntryPointTests() {
22-
var phases = [[new InitializeTransformer(['web/*.html'])]];
22+
var phases = [
23+
[
24+
new InitializeTransformer(['web/*.html'])
25+
]
26+
];
2327

2428
testPhases('basic', phases, {
2529
'a|web/index.html': '''
2630
<html><head></head><body>
2731
<script type="application/dart" src="index.dart"></script>
2832
</body></html>
29-
'''.replaceAll(' ', ''),
33+
'''
34+
.replaceAll(' ', ''),
3035
'a|web/index.dart': '''
3136
library web_foo;
3237
@@ -77,7 +82,8 @@ void htmlEntryPointTests() {
7782
<html><head></head><body>
7883
<script type="application/dart" src="index.initialize.dart"></script>
7984
80-
</body></html>'''.replaceAll(' ', ''),
85+
</body></html>'''
86+
.replaceAll(' ', ''),
8187
'a|web/index.initialize.dart': formatter.format('''
8288
import 'package:initialize/src/static_loader.dart';
8389
import 'package:initialize/initialize.dart';
@@ -109,7 +115,11 @@ void htmlEntryPointTests() {
109115
}
110116

111117
void dartEntryPointTests() {
112-
var phases = [[new InitializeTransformer(['web/index.dart'])]];
118+
var phases = [
119+
[
120+
new InitializeTransformer(['web/index.dart'])
121+
]
122+
];
113123

114124
testPhases('constructor arguments', phases, {
115125
'a|web/index.dart': '''

tool/all_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# Fast fail the script on failures.
88
set -e
99

10+
dartanalyzer --fatal-warnings lib/initialize.dart lib/transformer.dart
11+
1012
# Run the un-transformed command-line tests.
1113
dart test/deferred_library_test.dart
1214
dart test/init_method_test.dart

0 commit comments

Comments
 (0)