Skip to content

Commit

Permalink
A bunch of strong mode fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Mar 2, 2016
1 parent 93ebf8b commit ff91232
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 32 deletions.
6 changes: 3 additions & 3 deletions lib/src/generate/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Future<BuildResult> build(List<List<Phase>> phaseGroups,
AssetReader reader,
AssetWriter writer,
Level logLevel,
onLog(LogRecord),
onLog(LogRecord record),
Stream terminateEventStream}) async {
var options = new BuildOptions(
packageGraph: packageGraph,
Expand Down Expand Up @@ -87,7 +87,7 @@ Stream<BuildResult> watch(List<List<Phase>> phaseGroups,
AssetReader reader,
AssetWriter writer,
Level logLevel,
onLog(LogRecord),
onLog(LogRecord record),
Duration debounceDelay,
DirectoryWatcherFactory directoryWatcherFactory,
Stream terminateEventStream}) {
Expand Down Expand Up @@ -124,7 +124,7 @@ Stream<BuildResult> serve(List<List<Phase>> phaseGroups,
AssetReader reader,
AssetWriter writer,
Level logLevel,
onLog(LogRecord),
onLog(LogRecord record),
Duration debounceDelay,
DirectoryWatcherFactory directoryWatcherFactory,
Stream terminateEventStream,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generate/build_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class BuildImpl {
/// Collect updates to the graph based on any changed assets.
var updates = <AssetId, ChangeType>{};
await Future.wait(_assetGraph.allNodes
.where((node) => node is! GeneratedAssetNode || node.wasOutput)
.where((node) => node is! GeneratedAssetNode || (node as GeneratedAssetNode).wasOutput)
.map((node) async {
var exists = await _reader.hasInput(node.id);
if (!exists) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/generate/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BuildOptions {
{this.debounceDelay,
this.directoryWatcherFactory,
Level logLevel,
onLog(LogRecord),
onLog(LogRecord record),
this.packageGraph,
this.reader,
this.writer,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/package_graph/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ PackageDependencyType _dependencyType(source) {

/// Gets the deps from a yaml file, taking into account dependency_overrides.
Map<String, YamlMap> _depsFromYaml(YamlMap yaml, {bool isRoot: false}) {
var deps = new Map.from(yaml['dependencies'] ?? {});
var deps = new Map<String, YamlMap>.from(yaml['dependencies'] ?? {});
if (isRoot) {
deps.addAll(new Map.from(yaml['dev_dependencies'] ?? {}));
yaml['dependency_overrides']?.forEach((dep, source) {
Expand Down
6 changes: 4 additions & 2 deletions test/analyzer/resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'package:build/build.dart';
import 'package:build/src/builder/build_step_impl.dart';
import 'package:build/src/util/barback.dart';

import 'package:logging/logging.dart';

import '../common/common.dart';

// Ported from
Expand All @@ -18,7 +20,7 @@ main() {
var entryPoint = makeAssetId('a|web/main.dart');
Future validateResolver(
{Map<String, String> inputs,
validator(Resolver),
validator(Resolver resolver),
List messages: const []}) async {
var writer = new InMemoryAssetWriter();
var reader = new InMemoryAssetReader(writer.assets);
Expand All @@ -28,7 +30,7 @@ main() {
var builder = new TestBuilder(validator);
var buildStep =
new BuildStepImpl(assets[entryPoint], [], reader, writer, 'a');
var logs = [];
var logs = <LogRecord>[];
if (messages != null) {
buildStep.logger.onRecord.listen(logs.add);
}
Expand Down
4 changes: 2 additions & 2 deletions test/asset/cache_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ main() {

test('Multiple readAsString calls wait on the same future', () async {
childReaderAssets[a.id] = new DatedString(a.stringContents);
var futures = [];
var futures = <Future>[];
futures.add(reader.readAsString(a.id));
futures.add(reader.readAsString(a.id));
expect(futures[0], futures[1]);
Expand All @@ -122,7 +122,7 @@ main() {

test('Multiple hasInput calls return the same future', () async {
childReaderAssets[a.id] = new DatedString(a.stringContents);
var futures = [];
var futures = <Future>[];
futures.add(reader.hasInput(a.id));
futures.add(reader.hasInput(a.id));
expect(futures[0], futures[1]);
Expand Down
2 changes: 1 addition & 1 deletion test/builder/build_step_impl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ main() {
Logger.root.level = Level.ALL;
var logger = buildStep.logger;
expect(logger.fullName, primary.id.toString());
var logs = [];
var logs = <LogRecord>[];
var listener = logger.onRecord.listen(logs.add);
logger.fine('hello');
logger.warning('world');
Expand Down
2 changes: 1 addition & 1 deletion test/common/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void checkOutputs(Map<String, String> outputs, BuildResult result,
}

Future<BuildResult> nextResult(results) {
var done = new Completer();
var done = new Completer<BuildResult>();
var startingLength = results.length;
() async {
while (results.length == startingLength) {
Expand Down
2 changes: 1 addition & 1 deletion test/common/copy_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CopyBuilder implements Builder {
}

List<AssetId> declareOutputs(AssetId input) {
var outputs = [];
var outputs = <AssetId>[];
for (int i = 0; i < numCopies; i++) {
outputs.add(_copiedAssetId(input, numCopies == 1 ? null : i));
}
Expand Down
11 changes: 7 additions & 4 deletions test/common/matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ class _AssetGraphMatcher extends Matcher {
return false;
}
if (item is GeneratedAssetNode) {
if (expectedNode is! GeneratedAssetNode) return false;
if (item.primaryInput != expectedNode.primaryInput) return false;
if (item.needsUpdate != expectedNode.needsUpdate) return false;
if (item.wasOutput != expectedNode.wasOutput) return false;
if (expectedNode is GeneratedAssetNode) {
if (item.primaryInput != expectedNode.primaryInput) return false;
if (item.needsUpdate != expectedNode.needsUpdate) return false;
if (item.wasOutput != expectedNode.wasOutput) return false;
} else {
return false;
}
}
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions test/generate/serve_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ main() {
});

test('does basic builds', () async {
var results = [];
var results = <BuildResult>[];
startServe(copyAPhaseGroup, {'a|web/a.txt': 'a'}, writer)
.listen(results.add);
var result = await nextResult(results);
Expand All @@ -56,7 +56,7 @@ main() {
var buildBlocker1 = new Completer();
copyBuilder.blockUntil = buildBlocker1.future;

var results = [];
var results = <BuildResult>[];
startServe(copyAPhaseGroup, {'a|web/a.txt': 'a'}, writer)
.listen(results.add);
// Give the build enough time to get started.
Expand Down Expand Up @@ -117,7 +117,7 @@ Stream<BuildResult> startServe(List<List<Phase>> phases,
final reader = new InMemoryAssetReader(actualAssets);
final rootPackage = new PackageNode('a', null, null, new Uri.file('a/'));
final packageGraph = new PackageGraph.fromRoot(rootPackage);
final watcherFactory = (path) => new FakeWatcher(path);
final watcherFactory = (String path) => new FakeWatcher(path);

return serve(phases,
debounceDelay: _debounceDelay,
Expand Down
24 changes: 12 additions & 12 deletions test/generate/watch_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ main() {
group('simple', () {
test('rebuilds on file updates', () async {
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(copyAPhaseGroup, {'a|web/a.txt': 'a'}, writer)
.listen(results.add);

Expand All @@ -50,7 +50,7 @@ main() {

test('rebuilds on new files', () async {
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(copyAPhaseGroup, {'a|web/a.txt': 'a'}, writer)
.listen(results.add);

Expand All @@ -69,7 +69,7 @@ main() {

test('rebuilds on deleted files', () async {
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(copyAPhaseGroup, {'a|web/a.txt': 'a', 'a|web/b.txt': 'b',},
writer)
.listen(results.add);
Expand All @@ -95,7 +95,7 @@ main() {

test('rebuilds properly update asset_graph.json', () async {
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(copyAPhaseGroup, {'a|web/a.txt': 'a', 'a|web/b.txt': 'b'},
writer)
.listen(results.add);
Expand Down Expand Up @@ -131,7 +131,7 @@ main() {
test('build fails if script is updated after the first build starts',
() async {
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(copyAPhaseGroup, {'a|web/a.txt': 'a'}, writer)
.listen(results.add);

Expand Down Expand Up @@ -163,7 +163,7 @@ main() {
]
];
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(phases, {'a|web/a.txt': 'a'}, writer).listen(results.add);

var result = await nextResult(results);
Expand Down Expand Up @@ -191,7 +191,7 @@ main() {
]
];
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(phases, {'a|web/a.txt': 'a'}, writer).listen(results.add);

var result = await nextResult(results);
Expand Down Expand Up @@ -222,7 +222,7 @@ main() {
]
];
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(phases, {'a|web/a.txt': 'a', 'a|web/b.txt': 'b'}, writer)
.listen(results.add);

Expand Down Expand Up @@ -262,7 +262,7 @@ main() {
]
];
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(phases, {'a|web/a.txt': 'a'}, writer).listen(results.add);

var result = await nextResult(results);
Expand Down Expand Up @@ -293,7 +293,7 @@ main() {
],
];
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(phases, {'a|web/a.txt': 'a', 'a|web/b.txt': 'b'}, writer)
.listen(results.add);

Expand Down Expand Up @@ -328,7 +328,7 @@ main() {
],
];
var writer = new InMemoryAssetWriter();
var results = [];
var results = <BuildResult>[];
startWatch(phases, {'a|web/a.txt': 'a', 'a|web/b.txt': 'b'}, writer)
.listen(results.add);

Expand Down Expand Up @@ -360,7 +360,7 @@ Stream<BuildResult> startWatch(List<List<Phase>> phases,
final reader = new InMemoryAssetReader(actualAssets);
final rootPackage = new PackageNode('a', null, null, new Uri.file('a/'));
final packageGraph = new PackageGraph.fromRoot(rootPackage);
final watcherFactory = (path) => new FakeWatcher(path);
final watcherFactory = (String path) => new FakeWatcher(path);

return watch(phases,
debounceDelay: _debounceDelay,
Expand Down

0 comments on commit ff91232

Please sign in to comment.