Fix analysis errors, warnings, and hints.
R=rnystrom@google.com
Review URL: https://codereview.chromium.org//1184763005.
diff --git a/lib/src/directory_watcher/linux.dart b/lib/src/directory_watcher/linux.dart
index 870faa7..04d88e6 100644
--- a/lib/src/directory_watcher/linux.dart
+++ b/lib/src/directory_watcher/linux.dart
@@ -7,8 +7,6 @@
import 'dart:async';
import 'dart:io';
-import 'package:stack_trace/stack_trace.dart';
-
import '../utils.dart';
import '../watch_event.dart';
import 'resubscribable.dart';
@@ -58,13 +56,13 @@
_LinuxDirectoryWatcher(String directory)
: directory = directory {
// Batch the inotify changes together so that we can dedup events.
- var innerStream = Chain.track(new Directory(directory).watch())
+ var innerStream = new Directory(directory).watch()
.transform(new BatchedStreamTransformer<FileSystemEvent>());
_listen(innerStream, _onBatch,
onError: _eventsController.addError,
onDone: _onDone);
- _listen(Chain.track(new Directory(directory).list()), (entity) {
+ _listen(new Directory(directory).list(), (entity) {
_entries[entity.path] = new _EntryState(entity is Directory);
if (entity is! Directory) return;
_watchSubdir(entity.path);
@@ -159,7 +157,7 @@
// event for every new file.
watcher.ready.then((_) {
if (!isReady || _eventsController.isClosed) return;
- _listen(Chain.track(new Directory(path).list(recursive: true)), (entry) {
+ _listen(new Directory(path).list(recursive: true), (entry) {
if (entry is Directory) return;
_eventsController.add(new WatchEvent(ChangeType.ADD, entry.path));
}, onError: (error, stackTrace) {
diff --git a/lib/src/directory_watcher/mac_os.dart b/lib/src/directory_watcher/mac_os.dart
index 89ac905..f3de727 100644
--- a/lib/src/directory_watcher/mac_os.dart
+++ b/lib/src/directory_watcher/mac_os.dart
@@ -7,8 +7,6 @@
import 'dart:async';
import 'dart:io';
-import 'package:stack_trace/stack_trace.dart';
-
import '../constructable_file_system_event.dart';
import '../path_set.dart';
import '../utils.dart';
@@ -136,7 +134,7 @@
if (_files.containsDir(path)) continue;
var subscription;
- subscription = Chain.track(new Directory(path).list(recursive: true))
+ subscription = new Directory(path).list(recursive: true)
.listen((entity) {
if (entity is Directory) return;
if (_files.contains(path)) return;
@@ -273,7 +271,7 @@
case FileSystemEvent.MODIFY:
return new ConstructableFileSystemModifyEvent(
batch.first.path, isDir, false);
- default: assert(false);
+ default: throw 'unreachable';
}
}
@@ -343,8 +341,7 @@
/// Start or restart the underlying [Directory.watch] stream.
void _startWatch() {
// Batch the FSEvent changes together so that we can dedup events.
- var innerStream =
- Chain.track(new Directory(directory).watch(recursive: true))
+ var innerStream = new Directory(directory).watch(recursive: true)
.transform(new BatchedStreamTransformer<FileSystemEvent>());
_watchSubscription = innerStream.listen(_onBatch,
onError: _eventsController.addError,
@@ -359,7 +356,7 @@
_files.clear();
var completer = new Completer();
- var stream = Chain.track(new Directory(directory).list(recursive: true));
+ var stream = new Directory(directory).list(recursive: true);
_initialListSubscription = stream.listen((entity) {
if (entity is! Directory) _files.add(entity.path);
},
diff --git a/lib/src/directory_watcher/polling.dart b/lib/src/directory_watcher/polling.dart
index 12a3245..144391f 100644
--- a/lib/src/directory_watcher/polling.dart
+++ b/lib/src/directory_watcher/polling.dart
@@ -7,8 +7,6 @@
import 'dart:async';
import 'dart:io';
-import 'package:stack_trace/stack_trace.dart';
-
import '../async_queue.dart';
import '../stat.dart';
import '../utils.dart';
@@ -105,7 +103,7 @@
_filesToProcess.add(null);
}
- var stream = Chain.track(new Directory(directory).list(recursive: true));
+ var stream = new Directory(directory).list(recursive: true);
_listSubscription = stream.listen((entity) {
assert(!_events.isClosed);
diff --git a/lib/src/directory_watcher/windows.dart b/lib/src/directory_watcher/windows.dart
index 4f41d33..bd17cf4 100644
--- a/lib/src/directory_watcher/windows.dart
+++ b/lib/src/directory_watcher/windows.dart
@@ -10,7 +10,6 @@
import 'dart:io';
import 'package:path/path.dart' as p;
-import 'package:stack_trace/stack_trace.dart';
import '../constructable_file_system_event.dart';
import '../path_set.dart';
@@ -117,8 +116,7 @@
var parent = p.dirname(absoluteDir);
// Check if [directory] is already the root directory.
if (FileSystemEntity.identicalSync(parent, directory)) return;
- var parentStream = Chain.track(
- new Directory(parent).watch(recursive: false));
+ var parentStream = new Directory(parent).watch(recursive: false);
_parentWatchSubscription = parentStream.listen((event) {
// Only look at events for 'directory'.
if (p.basename(event.path) != p.basename(absoluteDir)) return;
@@ -159,7 +157,6 @@
/// The callback that's run when [Directory.watch] emits a batch of events.
void _onBatch(List<FileSystemEvent> batch) {
_sortEvents(batch).forEach((path, events) {
- var relativePath = p.relative(path, from: directory);
var canonicalEvent = _canonicalEvent(events);
events = canonicalEvent == null ?
@@ -177,7 +174,7 @@
if (_files.containsDir(path)) continue;
- var stream = Chain.track(new Directory(path).list(recursive: true));
+ var stream = new Directory(path).list(recursive: true);
var sub;
sub = stream.listen((entity) {
if (entity is Directory) return;
@@ -262,7 +259,6 @@
var type = batch.first.type;
var isDir = batch.first.isDirectory;
- var hadModifyEvent = false;
for (var event in batch.skip(1)) {
// If one event reports that the file is a directory and another event
@@ -273,10 +269,7 @@
// safely assume the file was modified after a CREATE or before the
// REMOVE; otherwise there will also be a REMOVE or CREATE event
// (respectively) that will be contradictory.
- if (event is FileSystemModifyEvent) {
- hadModifyEvent = true;
- continue;
- }
+ if (event is FileSystemModifyEvent) continue;
assert(event is FileSystemCreateEvent ||
event is FileSystemDeleteEvent ||
event is FileSystemMoveEvent);
@@ -305,7 +298,7 @@
batch.first.path, isDir, false);
case FileSystemEvent.MOVE:
return null;
- default: assert(false);
+ default: throw 'unreachable';
}
}
@@ -367,8 +360,7 @@
/// Start or restart the underlying [Directory.watch] stream.
void _startWatch() {
// Batch the events together so that we can dedup events.
- var innerStream =
- Chain.track(new Directory(directory).watch(recursive: true));
+ var innerStream = new Directory(directory).watch(recursive: true);
_watchSubscription = innerStream.listen(_onEvent,
onError: _eventsController.addError,
onDone: _onDone);
@@ -382,7 +374,7 @@
_files.clear();
var completer = new Completer();
- var stream = Chain.track(new Directory(directory).list(recursive: true));
+ var stream = new Directory(directory).list(recursive: true);
void handleEntity(entity) {
if (entity is! Directory) _files.add(entity.path);
}
diff --git a/lib/src/stat.dart b/lib/src/stat.dart
index 166d789..d36eff3 100644
--- a/lib/src/stat.dart
+++ b/lib/src/stat.dart
@@ -7,8 +7,6 @@
import 'dart:async';
import 'dart:io';
-import 'package:stack_trace/stack_trace.dart';
-
/// A function that takes a file path and returns the last modified time for
/// the file at that path.
typedef DateTime MockTimeCallback(String path);
@@ -31,5 +29,5 @@
return new Future.value(_mockTimeCallback(path));
}
- return Chain.track(FileStat.stat(path)).then((stat) => stat.modified);
+ return FileStat.stat(path).then((stat) => stat.modified);
}