diff --git a/benchmark/path_set.dart b/benchmark/path_set.dart index bf9f5fc7cf9dc..8a5b843ef3c4b 100644 --- a/benchmark/path_set.dart +++ b/benchmark/path_set.dart @@ -19,11 +19,11 @@ final String root = Platform.isWindows ? r"C:\root" : "/root"; abstract class PathSetBenchmark extends BenchmarkBase { PathSetBenchmark(String method) : super("PathSet.$method"); - final PathSet pathSet = new PathSet(root); + final PathSet pathSet = PathSet(root); /// Use a fixed [Random] with a constant seed to ensure the tests are /// deterministic. - final math.Random random = new math.Random(1234); + final math.Random random = math.Random(1234); /// Walks over a virtual directory [depth] levels deep invoking [callback] /// for each "file". @@ -140,8 +140,8 @@ class RemoveBenchmark extends PathSetBenchmark { } main() { - new AddBenchmark().report(); - new ContainsBenchmark().report(); - new PathsBenchmark().report(); - new RemoveBenchmark().report(); + AddBenchmark().report(); + ContainsBenchmark().report(); + PathsBenchmark().report(); + RemoveBenchmark().report(); } diff --git a/example/watch.dart b/example/watch.dart index da3c2633c7686..1477e4282f274 100644 --- a/example/watch.dart +++ b/example/watch.dart @@ -14,7 +14,7 @@ main(List arguments) { return; } - var watcher = new DirectoryWatcher(p.absolute(arguments[0])); + var watcher = DirectoryWatcher(p.absolute(arguments[0])); watcher.events.listen((event) { print(event); }); diff --git a/lib/src/async_queue.dart b/lib/src/async_queue.dart index 1904192b4a404..de7b7188a7751 100644 --- a/lib/src/async_queue.dart +++ b/lib/src/async_queue.dart @@ -17,7 +17,7 @@ typedef Future ItemProcessor(T item); /// needed. When all items are processed, it stops processing until more items /// are added. class AsyncQueue { - final _items = new Queue(); + final _items = Queue(); /// Whether or not the queue is currently waiting on a processing future to /// complete. diff --git a/lib/src/directory_watcher.dart b/lib/src/directory_watcher.dart index 6beebd0a4faea..8c52ed97af29a 100644 --- a/lib/src/directory_watcher.dart +++ b/lib/src/directory_watcher.dart @@ -29,10 +29,10 @@ abstract class DirectoryWatcher implements Watcher { /// watchers. factory DirectoryWatcher(String directory, {Duration pollingDelay}) { if (FileSystemEntity.isWatchSupported) { - if (Platform.isLinux) return new LinuxDirectoryWatcher(directory); - if (Platform.isMacOS) return new MacOSDirectoryWatcher(directory); - if (Platform.isWindows) return new WindowsDirectoryWatcher(directory); + if (Platform.isLinux) return LinuxDirectoryWatcher(directory); + if (Platform.isMacOS) return MacOSDirectoryWatcher(directory); + if (Platform.isWindows) return WindowsDirectoryWatcher(directory); } - return new PollingDirectoryWatcher(directory, pollingDelay: pollingDelay); + return PollingDirectoryWatcher(directory, pollingDelay: pollingDelay); } } diff --git a/lib/src/directory_watcher/linux.dart b/lib/src/directory_watcher/linux.dart index 5eeed2327f143..f3866c6c676bb 100644 --- a/lib/src/directory_watcher/linux.dart +++ b/lib/src/directory_watcher/linux.dart @@ -28,7 +28,7 @@ class LinuxDirectoryWatcher extends ResubscribableWatcher String get directory => path; LinuxDirectoryWatcher(String directory) - : super(directory, () => new _LinuxDirectoryWatcher(directory)); + : super(directory, () => _LinuxDirectoryWatcher(directory)); } class _LinuxDirectoryWatcher @@ -37,16 +37,16 @@ class _LinuxDirectoryWatcher String get path => _files.root; Stream get events => _eventsController.stream; - final _eventsController = new StreamController.broadcast(); + final _eventsController = StreamController.broadcast(); bool get isReady => _readyCompleter.isCompleted; Future get ready => _readyCompleter.future; - final _readyCompleter = new Completer(); + final _readyCompleter = Completer(); /// A stream group for the [Directory.watch] events of [path] and all its /// subdirectories. - var _nativeEvents = new StreamGroup(); + var _nativeEvents = StreamGroup(); /// All known files recursively within [path]. final PathSet _files; @@ -60,12 +60,12 @@ class _LinuxDirectoryWatcher /// /// These are gathered together so that they may all be canceled when the /// watcher is closed. - final _subscriptions = new Set(); + final _subscriptions = Set(); - _LinuxDirectoryWatcher(String path) : _files = new PathSet(path) { - _nativeEvents.add(new Directory(path) + _LinuxDirectoryWatcher(String path) : _files = PathSet(path) { + _nativeEvents.add(Directory(path) .watch() - .transform(new StreamTransformer.fromHandlers(handleDone: (sink) { + .transform(StreamTransformer.fromHandlers(handleDone: (sink) { // Handle the done event here rather than in the call to [_listen] because // [innerStream] won't close until we close the [StreamGroup]. However, if // we close the [StreamGroup] here, we run the risk of new-directory @@ -76,11 +76,10 @@ class _LinuxDirectoryWatcher // Batch the inotify changes together so that we can dedup events. var innerStream = _nativeEvents.stream - .transform(new BatchedStreamTransformer()); + .transform(BatchedStreamTransformer()); _listen(innerStream, _onBatch, onError: _eventsController.addError); - _listen(new Directory(path).list(recursive: true), - (FileSystemEntity entity) { + _listen(Directory(path).list(recursive: true), (FileSystemEntity entity) { if (entity is Directory) { _watchSubdir(entity.path); } else { @@ -122,16 +121,16 @@ class _LinuxDirectoryWatcher // TODO(nweiz): Catch any errors here that indicate that the directory in // question doesn't exist and silently stop watching it instead of // propagating the errors. - var stream = new Directory(path).watch(); + var stream = Directory(path).watch(); _subdirStreams[path] = stream; _nativeEvents.add(stream); } /// The callback that's run when a batch of changes comes in. void _onBatch(List batch) { - var files = new Set(); - var dirs = new Set(); - var changed = new Set(); + var files = Set(); + var dirs = Set(); + var changed = Set(); // inotify event batches are ordered by occurrence, so we treat them as a // log of what happened to a file. We only emit events based on the @@ -208,8 +207,7 @@ class _LinuxDirectoryWatcher /// Emits [ChangeType.ADD] events for the recursive contents of [path]. void _addSubdir(String path) { - _listen(new Directory(path).list(recursive: true), - (FileSystemEntity entity) { + _listen(Directory(path).list(recursive: true), (FileSystemEntity entity) { if (entity is Directory) { _watchSubdir(entity.path); } else { @@ -247,7 +245,7 @@ class _LinuxDirectoryWatcher void _emit(ChangeType type, String path) { if (!isReady) return; if (_eventsController.isClosed) return; - _eventsController.add(new WatchEvent(type, path)); + _eventsController.add(WatchEvent(type, path)); } /// Like [Stream.listen], but automatically adds the subscription to diff --git a/lib/src/directory_watcher/mac_os.dart b/lib/src/directory_watcher/mac_os.dart index 61531c5d91923..f593fbd511909 100644 --- a/lib/src/directory_watcher/mac_os.dart +++ b/lib/src/directory_watcher/mac_os.dart @@ -27,7 +27,7 @@ class MacOSDirectoryWatcher extends ResubscribableWatcher String get directory => path; MacOSDirectoryWatcher(String directory) - : super(directory, () => new _MacOSDirectoryWatcher(directory)); + : super(directory, () => _MacOSDirectoryWatcher(directory)); } class _MacOSDirectoryWatcher @@ -36,12 +36,12 @@ class _MacOSDirectoryWatcher final String path; Stream get events => _eventsController.stream; - final _eventsController = new StreamController.broadcast(); + final _eventsController = StreamController.broadcast(); bool get isReady => _readyCompleter.isCompleted; Future get ready => _readyCompleter.future; - final _readyCompleter = new Completer(); + final _readyCompleter = Completer(); /// The set of files that are known to exist recursively within the watched /// directory. @@ -64,7 +64,7 @@ class _MacOSDirectoryWatcher /// The subscriptions to [Directory.list] calls for listing the contents of a /// subdirectory that was moved into the watched directory. - final _listSubscriptions = new Set>(); + final _listSubscriptions = Set>(); /// The timer for tracking how long we wait for an initial batch of bogus /// events (see issue 14373). @@ -72,7 +72,7 @@ class _MacOSDirectoryWatcher _MacOSDirectoryWatcher(String path) : path = path, - _files = new PathSet(path) { + _files = PathSet(path) { _startWatch(); // Before we're ready to emit events, wait for [_listDir] to complete and @@ -136,8 +136,7 @@ class _MacOSDirectoryWatcher if (_files.containsDir(path)) continue; StreamSubscription subscription; - subscription = - new Directory(path).list(recursive: true).listen((entity) { + subscription = Directory(path).list(recursive: true).listen((entity) { if (entity is Directory) return; if (_files.contains(path)) return; @@ -182,11 +181,11 @@ class _MacOSDirectoryWatcher // directory's full contents will be examined anyway, so we ignore such // events. Emitting them could cause useless or out-of-order events. var directories = unionAll(batch.map((event) { - if (!event.isDirectory) return new Set(); + if (!event.isDirectory) return Set(); if (event is FileSystemMoveEvent) { - return new Set.from([event.path, event.destination]); + return Set.from([event.path, event.destination]); } - return new Set.from([event.path]); + return Set.from([event.path]); })); isInModifiedDirectory(String path) => @@ -194,9 +193,7 @@ class _MacOSDirectoryWatcher addEvent(String path, FileSystemEvent event) { if (isInModifiedDirectory(path)) return; - eventsForPaths - .putIfAbsent(path, () => new Set()) - .add(event); + eventsForPaths.putIfAbsent(path, () => Set()).add(event); } for (var event in batch) { @@ -271,11 +268,11 @@ class _MacOSDirectoryWatcher // [_eventsBasedOnFileSystem] will handle this correctly by producing a // DELETE event followed by a CREATE event if the directory exists. if (isDir) return null; - return new ConstructableFileSystemCreateEvent(batch.first.path, false); + return ConstructableFileSystemCreateEvent(batch.first.path, false); case FileSystemEvent.delete: - return new ConstructableFileSystemDeleteEvent(batch.first.path, isDir); + return ConstructableFileSystemDeleteEvent(batch.first.path, isDir); case FileSystemEvent.modify: - return new ConstructableFileSystemModifyEvent( + return ConstructableFileSystemModifyEvent( batch.first.path, isDir, false); default: throw 'unreachable'; @@ -292,32 +289,32 @@ class _MacOSDirectoryWatcher List _eventsBasedOnFileSystem(String path) { var fileExisted = _files.contains(path); var dirExisted = _files.containsDir(path); - var fileExists = new File(path).existsSync(); - var dirExists = new Directory(path).existsSync(); + var fileExists = File(path).existsSync(); + var dirExists = Directory(path).existsSync(); var events = []; if (fileExisted) { if (fileExists) { - events.add(new ConstructableFileSystemModifyEvent(path, false, false)); + events.add(ConstructableFileSystemModifyEvent(path, false, false)); } else { - events.add(new ConstructableFileSystemDeleteEvent(path, false)); + events.add(ConstructableFileSystemDeleteEvent(path, false)); } } else if (dirExisted) { if (dirExists) { // If we got contradictory events for a directory that used to exist and // still exists, we need to rescan the whole thing in case it was // replaced with a different directory. - events.add(new ConstructableFileSystemDeleteEvent(path, true)); - events.add(new ConstructableFileSystemCreateEvent(path, true)); + events.add(ConstructableFileSystemDeleteEvent(path, true)); + events.add(ConstructableFileSystemCreateEvent(path, true)); } else { - events.add(new ConstructableFileSystemDeleteEvent(path, true)); + events.add(ConstructableFileSystemDeleteEvent(path, true)); } } if (!fileExisted && fileExists) { - events.add(new ConstructableFileSystemCreateEvent(path, false)); + events.add(ConstructableFileSystemCreateEvent(path, false)); } else if (!dirExisted && dirExists) { - events.add(new ConstructableFileSystemCreateEvent(path, true)); + events.add(ConstructableFileSystemCreateEvent(path, true)); } return events; @@ -330,7 +327,7 @@ class _MacOSDirectoryWatcher // If the directory still exists and we're still expecting bogus events, // this is probably issue 14849 rather than a real close event. We should // just restart the watcher. - if (!isReady && new Directory(path).existsSync()) { + if (!isReady && Directory(path).existsSync()) { _startWatch(); return; } @@ -348,9 +345,9 @@ class _MacOSDirectoryWatcher /// Start or restart the underlying [Directory.watch] stream. void _startWatch() { // Batch the FSEvent changes together so that we can dedup events. - var innerStream = new Directory(path) + var innerStream = Directory(path) .watch(recursive: true) - .transform(new BatchedStreamTransformer()); + .transform(BatchedStreamTransformer()); _watchSubscription = innerStream.listen(_onBatch, onError: _eventsController.addError, onDone: _onDone); } @@ -362,8 +359,8 @@ class _MacOSDirectoryWatcher if (_initialListSubscription != null) _initialListSubscription.cancel(); _files.clear(); - var completer = new Completer(); - var stream = new Directory(path).list(recursive: true); + var completer = Completer(); + var stream = Directory(path).list(recursive: true); _initialListSubscription = stream.listen((entity) { if (entity is! Directory) _files.add(entity.path); }, onError: _emitError, onDone: completer.complete, cancelOnError: true); @@ -376,16 +373,15 @@ class _MacOSDirectoryWatcher /// watcher tests take on the bots, so it should be safe to assume that any /// bogus events will be signaled in that time frame. Future _waitForBogusEvents() { - var completer = new Completer(); - _bogusEventTimer = - new Timer(new Duration(milliseconds: 200), completer.complete); + var completer = Completer(); + _bogusEventTimer = Timer(Duration(milliseconds: 200), completer.complete); return completer.future; } /// Emit an event with the given [type] and [path]. void _emitEvent(ChangeType type, String path) { if (!isReady) return; - _eventsController.add(new WatchEvent(type, path)); + _eventsController.add(WatchEvent(type, path)); } /// Emit an error, then close the watcher. diff --git a/lib/src/directory_watcher/polling.dart b/lib/src/directory_watcher/polling.dart index 790d0b9826ffb..735a8072276d0 100644 --- a/lib/src/directory_watcher/polling.dart +++ b/lib/src/directory_watcher/polling.dart @@ -25,8 +25,8 @@ class PollingDirectoryWatcher extends ResubscribableWatcher /// and higher CPU usage. Defaults to one second. PollingDirectoryWatcher(String directory, {Duration pollingDelay}) : super(directory, () { - return new _PollingDirectoryWatcher(directory, - pollingDelay != null ? pollingDelay : new Duration(seconds: 1)); + return _PollingDirectoryWatcher(directory, + pollingDelay != null ? pollingDelay : Duration(seconds: 1)); }); } @@ -36,12 +36,12 @@ class _PollingDirectoryWatcher final String path; Stream get events => _events.stream; - final _events = new StreamController.broadcast(); + final _events = StreamController.broadcast(); bool get isReady => _ready.isCompleted; Future get ready => _ready.future; - final _ready = new Completer(); + final _ready = Completer(); /// The amount of time the watcher pauses between successive polls of the /// directory contents. @@ -50,7 +50,7 @@ class _PollingDirectoryWatcher /// The previous modification times of the files in the directory. /// /// Used to tell which files have been modified. - final _lastModifieds = new Map(); + final _lastModifieds = Map(); /// The subscription used while [directory] is being listed. /// @@ -70,11 +70,11 @@ class _PollingDirectoryWatcher /// /// Used to tell which files have been removed: files that are in /// [_lastModifieds] but not in here when a poll completes have been removed. - final _polledFiles = new Set(); + final _polledFiles = Set(); _PollingDirectoryWatcher(this.path, this._pollingDelay) { - _filesToProcess = new AsyncQueue(_processFile, - onError: (e, StackTrace stackTrace) { + _filesToProcess = + AsyncQueue(_processFile, onError: (e, StackTrace stackTrace) { if (!_events.isClosed) _events.addError(e, stackTrace); }); @@ -107,7 +107,7 @@ class _PollingDirectoryWatcher _filesToProcess.add(null); } - var stream = new Directory(path).list(recursive: true); + var stream = Directory(path).list(recursive: true); _listSubscription = stream.listen((entity) { assert(!_events.isClosed); @@ -154,7 +154,7 @@ class _PollingDirectoryWatcher if (!isReady) return null; var type = lastModified == null ? ChangeType.ADD : ChangeType.MODIFY; - _events.add(new WatchEvent(type, file)); + _events.add(WatchEvent(type, file)); }); } @@ -165,14 +165,14 @@ class _PollingDirectoryWatcher // status for must have been removed. var removedFiles = _lastModifieds.keys.toSet().difference(_polledFiles); for (var removed in removedFiles) { - if (isReady) _events.add(new WatchEvent(ChangeType.REMOVE, removed)); + if (isReady) _events.add(WatchEvent(ChangeType.REMOVE, removed)); _lastModifieds.remove(removed); } if (!isReady) _ready.complete(); // Wait and then poll again. - return new Future.delayed(_pollingDelay).then((_) { + return Future.delayed(_pollingDelay).then((_) { if (_events.isClosed) return; _poll(); }); diff --git a/lib/src/directory_watcher/windows.dart b/lib/src/directory_watcher/windows.dart index baeaf233a0f02..0214939950210 100644 --- a/lib/src/directory_watcher/windows.dart +++ b/lib/src/directory_watcher/windows.dart @@ -21,11 +21,11 @@ class WindowsDirectoryWatcher extends ResubscribableWatcher String get directory => path; WindowsDirectoryWatcher(String directory) - : super(directory, () => new _WindowsDirectoryWatcher(directory)); + : super(directory, () => _WindowsDirectoryWatcher(directory)); } class _EventBatcher { - static const Duration _BATCH_DELAY = const Duration(milliseconds: 100); + static const Duration _BATCH_DELAY = Duration(milliseconds: 100); final List events = []; Timer timer; @@ -34,7 +34,7 @@ class _EventBatcher { if (timer != null) { timer.cancel(); } - timer = new Timer(_BATCH_DELAY, callback); + timer = Timer(_BATCH_DELAY, callback); } void cancelTimer() { @@ -48,15 +48,15 @@ class _WindowsDirectoryWatcher final String path; Stream get events => _eventsController.stream; - final _eventsController = new StreamController.broadcast(); + final _eventsController = StreamController.broadcast(); bool get isReady => _readyCompleter.isCompleted; Future get ready => _readyCompleter.future; - final _readyCompleter = new Completer(); + final _readyCompleter = Completer(); final Map _eventBatchers = - new HashMap(); + HashMap(); /// The set of files that are known to exist recursively within the watched /// directory. @@ -81,11 +81,11 @@ class _WindowsDirectoryWatcher /// The subscriptions to the [Directory.list] calls for listing the contents /// of subdirectories that were moved into the watched directory. final Set> _listSubscriptions = - new HashSet>(); + HashSet>(); _WindowsDirectoryWatcher(String path) : path = path, - _files = new PathSet(path) { + _files = PathSet(path) { // Before we're ready to emit events, wait for [_listDir] to complete. _listDir().then((_) { _startWatch(); @@ -121,7 +121,7 @@ class _WindowsDirectoryWatcher var parent = p.dirname(absoluteDir); // Check if [path] is already the root directory. if (FileSystemEntity.identicalSync(parent, path)) return; - var parentStream = new Directory(parent).watch(recursive: false); + var parentStream = Directory(parent).watch(recursive: false); _parentWatchSubscription = parentStream.listen((event) { // Only look at events for 'directory'. if (p.basename(event.path) != p.basename(absoluteDir)) return; @@ -151,7 +151,7 @@ class _WindowsDirectoryWatcher void _onEvent(FileSystemEvent event) { assert(isReady); final batcher = - _eventBatchers.putIfAbsent(event.path, () => new _EventBatcher()); + _eventBatchers.putIfAbsent(event.path, () => _EventBatcher()); batcher.addEvent(event, () { _eventBatchers.remove(event.path); _onBatch(batcher.events); @@ -178,7 +178,7 @@ class _WindowsDirectoryWatcher if (_files.containsDir(path)) continue; - var stream = new Directory(path).list(recursive: true); + var stream = Directory(path).list(recursive: true); StreamSubscription subscription; subscription = stream.listen((entity) { if (entity is Directory) return; @@ -222,11 +222,11 @@ class _WindowsDirectoryWatcher // directory's full contents will be examined anyway, so we ignore such // events. Emitting them could cause useless or out-of-order events. var directories = unionAll(batch.map((event) { - if (!event.isDirectory) return new Set(); + if (!event.isDirectory) return Set(); if (event is FileSystemMoveEvent) { - return new Set.from([event.path, event.destination]); + return Set.from([event.path, event.destination]); } - return new Set.from([event.path]); + return Set.from([event.path]); })); isInModifiedDirectory(String path) => @@ -234,9 +234,7 @@ class _WindowsDirectoryWatcher addEvent(String path, FileSystemEvent event) { if (isInModifiedDirectory(path)) return; - eventsForPaths - .putIfAbsent(path, () => new Set()) - .add(event); + eventsForPaths.putIfAbsent(path, () => Set()).add(event); } for (var event in batch) { @@ -297,11 +295,11 @@ class _WindowsDirectoryWatcher switch (type) { case FileSystemEvent.create: - return new ConstructableFileSystemCreateEvent(batch.first.path, isDir); + return ConstructableFileSystemCreateEvent(batch.first.path, isDir); case FileSystemEvent.delete: - return new ConstructableFileSystemDeleteEvent(batch.first.path, isDir); + return ConstructableFileSystemDeleteEvent(batch.first.path, isDir); case FileSystemEvent.modify: - return new ConstructableFileSystemModifyEvent( + return ConstructableFileSystemModifyEvent( batch.first.path, isDir, false); case FileSystemEvent.move: return null; @@ -320,32 +318,32 @@ class _WindowsDirectoryWatcher List _eventsBasedOnFileSystem(String path) { var fileExisted = _files.contains(path); var dirExisted = _files.containsDir(path); - var fileExists = new File(path).existsSync(); - var dirExists = new Directory(path).existsSync(); + var fileExists = File(path).existsSync(); + var dirExists = Directory(path).existsSync(); var events = []; if (fileExisted) { if (fileExists) { - events.add(new ConstructableFileSystemModifyEvent(path, false, false)); + events.add(ConstructableFileSystemModifyEvent(path, false, false)); } else { - events.add(new ConstructableFileSystemDeleteEvent(path, false)); + events.add(ConstructableFileSystemDeleteEvent(path, false)); } } else if (dirExisted) { if (dirExists) { // If we got contradictory events for a directory that used to exist and // still exists, we need to rescan the whole thing in case it was // replaced with a different directory. - events.add(new ConstructableFileSystemDeleteEvent(path, true)); - events.add(new ConstructableFileSystemCreateEvent(path, true)); + events.add(ConstructableFileSystemDeleteEvent(path, true)); + events.add(ConstructableFileSystemCreateEvent(path, true)); } else { - events.add(new ConstructableFileSystemDeleteEvent(path, true)); + events.add(ConstructableFileSystemDeleteEvent(path, true)); } } if (!fileExisted && fileExists) { - events.add(new ConstructableFileSystemCreateEvent(path, false)); + events.add(ConstructableFileSystemCreateEvent(path, false)); } else if (!dirExisted && dirExists) { - events.add(new ConstructableFileSystemCreateEvent(path, true)); + events.add(ConstructableFileSystemCreateEvent(path, true)); } return events; @@ -368,7 +366,7 @@ class _WindowsDirectoryWatcher /// Start or restart the underlying [Directory.watch] stream. void _startWatch() { // Batch the events together so that we can dedup events. - var innerStream = new Directory(path).watch(recursive: true); + var innerStream = Directory(path).watch(recursive: true); _watchSubscription = innerStream.listen(_onEvent, onError: _eventsController.addError, onDone: _onDone); } @@ -380,8 +378,8 @@ class _WindowsDirectoryWatcher if (_initialListSubscription != null) _initialListSubscription.cancel(); _files.clear(); - var completer = new Completer(); - var stream = new Directory(path).list(recursive: true); + var completer = Completer(); + var stream = Directory(path).list(recursive: true); void handleEntity(FileSystemEntity entity) { if (entity is! Directory) _files.add(entity.path); } @@ -395,7 +393,7 @@ class _WindowsDirectoryWatcher void _emitEvent(ChangeType type, String path) { if (!isReady) return; - _eventsController.add(new WatchEvent(type, path)); + _eventsController.add(WatchEvent(type, path)); } /// Emit an error, then close the watcher. diff --git a/lib/src/file_watcher.dart b/lib/src/file_watcher.dart index 09065bc8bde4b..c4abddd6c853f 100644 --- a/lib/src/file_watcher.dart +++ b/lib/src/file_watcher.dart @@ -33,8 +33,8 @@ abstract class FileWatcher implements Watcher { // [FileSystemEntity.isWatchSupported] is still true because directory // watching does work. if (FileSystemEntity.isWatchSupported && !Platform.isWindows) { - return new NativeFileWatcher(file); + return NativeFileWatcher(file); } - return new PollingFileWatcher(file, pollingDelay: pollingDelay); + return PollingFileWatcher(file, pollingDelay: pollingDelay); } } diff --git a/lib/src/file_watcher/native.dart b/lib/src/file_watcher/native.dart index 5f56f739fea49..ff25eb74e55b4 100644 --- a/lib/src/file_watcher/native.dart +++ b/lib/src/file_watcher/native.dart @@ -15,20 +15,19 @@ import '../watch_event.dart'; /// Single-file notifications are much simpler than those for multiple files, so /// this doesn't need to be split out into multiple OS-specific classes. class NativeFileWatcher extends ResubscribableWatcher implements FileWatcher { - NativeFileWatcher(String path) - : super(path, () => new _NativeFileWatcher(path)); + NativeFileWatcher(String path) : super(path, () => _NativeFileWatcher(path)); } class _NativeFileWatcher implements FileWatcher, ManuallyClosedWatcher { final String path; Stream get events => _eventsController.stream; - final _eventsController = new StreamController.broadcast(); + final _eventsController = StreamController.broadcast(); bool get isReady => _readyCompleter.isCompleted; Future get ready => _readyCompleter.future; - final _readyCompleter = new Completer(); + final _readyCompleter = Completer(); StreamSubscription _subscription; @@ -42,9 +41,9 @@ class _NativeFileWatcher implements FileWatcher, ManuallyClosedWatcher { void _listen() { // Batch the events together so that we can dedup them. - _subscription = new File(path) + _subscription = File(path) .watch() - .transform(new BatchedStreamTransformer()) + .transform(BatchedStreamTransformer()) .listen(_onBatch, onError: _eventsController.addError, onDone: _onDone); } @@ -55,11 +54,11 @@ class _NativeFileWatcher implements FileWatcher, ManuallyClosedWatcher { return; } - _eventsController.add(new WatchEvent(ChangeType.MODIFY, path)); + _eventsController.add(WatchEvent(ChangeType.MODIFY, path)); } _onDone() async { - var fileExists = await new File(path).exists(); + var fileExists = await File(path).exists(); // Check for this after checking whether the file exists because it's // possible that [close] was called between [File.exists] being called and @@ -70,10 +69,10 @@ class _NativeFileWatcher implements FileWatcher, ManuallyClosedWatcher { // If the file exists now, it was probably removed and quickly replaced; // this can happen for example when another file is moved on top of it. // Re-subscribe and report a modify event. - _eventsController.add(new WatchEvent(ChangeType.MODIFY, path)); + _eventsController.add(WatchEvent(ChangeType.MODIFY, path)); _listen(); } else { - _eventsController.add(new WatchEvent(ChangeType.REMOVE, path)); + _eventsController.add(WatchEvent(ChangeType.REMOVE, path)); close(); } } diff --git a/lib/src/file_watcher/polling.dart b/lib/src/file_watcher/polling.dart index 960b11b9b4a0d..777038fdfadbe 100644 --- a/lib/src/file_watcher/polling.dart +++ b/lib/src/file_watcher/polling.dart @@ -14,8 +14,8 @@ import '../watch_event.dart'; class PollingFileWatcher extends ResubscribableWatcher implements FileWatcher { PollingFileWatcher(String path, {Duration pollingDelay}) : super(path, () { - return new _PollingFileWatcher(path, - pollingDelay != null ? pollingDelay : new Duration(seconds: 1)); + return _PollingFileWatcher( + path, pollingDelay != null ? pollingDelay : Duration(seconds: 1)); }); } @@ -23,12 +23,12 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { final String path; Stream get events => _eventsController.stream; - final _eventsController = new StreamController.broadcast(); + final _eventsController = StreamController.broadcast(); bool get isReady => _readyCompleter.isCompleted; Future get ready => _readyCompleter.future; - final _readyCompleter = new Completer(); + final _readyCompleter = Completer(); /// The timer that controls polling. Timer _timer; @@ -40,7 +40,7 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { DateTime _lastModified; _PollingFileWatcher(this.path, Duration pollingDelay) { - _timer = new Timer.periodic(pollingDelay, (_) => _poll()); + _timer = Timer.periodic(pollingDelay, (_) => _poll()); _poll(); } @@ -49,11 +49,11 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { // We don't mark the file as removed if this is the first poll (indicated by // [_lastModified] being null). Instead, below we forward the dart:io error // that comes from trying to read the mtime below. - var pathExists = await new File(path).exists(); + var pathExists = await File(path).exists(); if (_eventsController.isClosed) return; if (_lastModified != null && !pathExists) { - _eventsController.add(new WatchEvent(ChangeType.REMOVE, path)); + _eventsController.add(WatchEvent(ChangeType.REMOVE, path)); close(); return; } @@ -80,7 +80,7 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { _readyCompleter.complete(); } else { _lastModified = modified; - _eventsController.add(new WatchEvent(ChangeType.MODIFY, path)); + _eventsController.add(WatchEvent(ChangeType.MODIFY, path)); } } diff --git a/lib/src/path_set.dart b/lib/src/path_set.dart index 77737f82ec90f..9a2c03cc1e02c 100644 --- a/lib/src/path_set.dart +++ b/lib/src/path_set.dart @@ -22,7 +22,7 @@ class PathSet { /// Each entry represents a directory or file. It may be a file or directory /// that was explicitly added, or a parent directory that was implicitly /// added in order to add a child. - final _Entry _entries = new _Entry(); + final _Entry _entries = _Entry(); PathSet(this.root); @@ -33,7 +33,7 @@ class PathSet { var parts = p.split(path); var entry = _entries; for (var part in parts) { - entry = entry.contents.putIfAbsent(part, () => new _Entry()); + entry = entry.contents.putIfAbsent(part, () => _Entry()); } entry.isExplicit = true; @@ -49,7 +49,7 @@ class PathSet { /// empty set. Set remove(String path) { path = _normalize(path); - var parts = new Queue.of(p.split(path)); + var parts = Queue.of(p.split(path)); // Remove the children of [dir], as well as [dir] itself if necessary. // @@ -61,7 +61,7 @@ class PathSet { // the next level. var part = parts.removeFirst(); var entry = dir.contents[part]; - if (entry == null || entry.contents.isEmpty) return new Set(); + if (entry == null || entry.contents.isEmpty) return Set(); partialPath = p.join(partialPath, part); var paths = recurse(entry, partialPath); @@ -75,10 +75,10 @@ class PathSet { // If there's only one component left in [path], we should remove it. var entry = dir.contents.remove(parts.first); - if (entry == null) return new Set(); + if (entry == null) return Set(); if (entry.contents.isEmpty) { - return new Set.from([p.join(root, path)]); + return Set.from([p.join(root, path)]); } var set = _explicitPathsWithin(entry, path); @@ -96,7 +96,7 @@ class PathSet { /// /// [dirPath] should be the path to [dir]. Set _explicitPathsWithin(_Entry dir, String dirPath) { - var paths = new Set(); + var paths = Set(); recurse(_Entry dir, String path) { dir.contents.forEach((name, entry) { var entryPath = p.join(path, name); diff --git a/lib/src/resubscribable.dart b/lib/src/resubscribable.dart index e96b918dccba0..e00ebb0d10d48 100644 --- a/lib/src/resubscribable.dart +++ b/lib/src/resubscribable.dart @@ -32,7 +32,7 @@ abstract class ResubscribableWatcher implements Watcher { bool get isReady => _readyCompleter.isCompleted; Future get ready => _readyCompleter.future; - var _readyCompleter = new Completer(); + var _readyCompleter = Completer(); /// Creates a new [ResubscribableWatcher] wrapping the watchers /// emitted by [_factory]. @@ -40,7 +40,7 @@ abstract class ResubscribableWatcher implements Watcher { ManuallyClosedWatcher watcher; StreamSubscription subscription; - _eventsController = new StreamController.broadcast( + _eventsController = StreamController.broadcast( onListen: () { watcher = _factory(); subscription = watcher.events.listen(_eventsController.add, @@ -57,7 +57,7 @@ abstract class ResubscribableWatcher implements Watcher { // watcher's `onDone` event doesn't close [events]. subscription.cancel(); watcher.close(); - _readyCompleter = new Completer(); + _readyCompleter = Completer(); }, sync: true); } diff --git a/lib/src/stat.dart b/lib/src/stat.dart index 05ee9ba0a9aae..59a5eb6f0f92f 100644 --- a/lib/src/stat.dart +++ b/lib/src/stat.dart @@ -24,7 +24,7 @@ void mockGetModificationTime(MockTimeCallback callback) { /// Gets the modification time for the file at [path]. Future getModificationTime(String path) { if (_mockTimeCallback != null) { - return new Future.value(_mockTimeCallback(path)); + return Future.value(_mockTimeCallback(path)); } return FileStat.stat(path).then((stat) => stat.modified); diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 30fbaae217aac..676ae281bfb9a 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -18,7 +18,7 @@ bool isDirectoryNotFoundException(error) { /// Returns the union of all elements in each set in [sets]. Set unionAll(Iterable> sets) => - sets.fold(new Set(), (union, set) => union.union(set)); + sets.fold(Set(), (union, set) => union.union(set)); /// A stream transformer that batches all events that are sent at the same time. /// @@ -29,8 +29,8 @@ Set unionAll(Iterable> sets) => /// microtasks. class BatchedStreamTransformer extends StreamTransformerBase> { Stream> bind(Stream input) { - var batch = new Queue(); - return new StreamTransformer>.fromHandlers( + var batch = Queue(); + return StreamTransformer>.fromHandlers( handleData: (event, sink) { batch.add(event); diff --git a/lib/src/watch_event.dart b/lib/src/watch_event.dart index 54093a5d7c329..94ee5cb897465 100644 --- a/lib/src/watch_event.dart +++ b/lib/src/watch_event.dart @@ -18,13 +18,13 @@ class WatchEvent { /// Enum for what kind of change has happened to a file. class ChangeType { /// A new file has been added. - static const ADD = const ChangeType("add"); + static const ADD = ChangeType("add"); /// A file has been removed. - static const REMOVE = const ChangeType("remove"); + static const REMOVE = ChangeType("remove"); /// The contents of a file have changed. - static const MODIFY = const ChangeType("modify"); + static const MODIFY = ChangeType("modify"); final String _name; const ChangeType(this._name); diff --git a/lib/watcher.dart b/lib/watcher.dart index b3cebe6657c3e..107ac8fae273c 100644 --- a/lib/watcher.dart +++ b/lib/watcher.dart @@ -58,10 +58,10 @@ abstract class Watcher { /// and higher CPU usage. Defaults to one second. Ignored for non-polling /// watchers. factory Watcher(String path, {Duration pollingDelay}) { - if (new File(path).existsSync()) { - return new FileWatcher(path, pollingDelay: pollingDelay); + if (File(path).existsSync()) { + return FileWatcher(path, pollingDelay: pollingDelay); } else { - return new DirectoryWatcher(path, pollingDelay: pollingDelay); + return DirectoryWatcher(path, pollingDelay: pollingDelay); } } } diff --git a/pubspec.yaml b/pubspec.yaml index 8f38a49f646d8..552b13a9dbd20 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,7 +8,7 @@ author: Dart Team homepage: https://github.com/dart-lang/watcher environment: - sdk: '>=2.0.0-dev.61.0 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dependencies: async: '>=1.10.0 <3.0.0' diff --git a/test/directory_watcher/linux_test.dart b/test/directory_watcher/linux_test.dart index 744045fcd37e7..0b81919a28cae 100644 --- a/test/directory_watcher/linux_test.dart +++ b/test/directory_watcher/linux_test.dart @@ -12,12 +12,12 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); + watcherFactory = (dir) => LinuxDirectoryWatcher(dir); sharedTests(); test('DirectoryWatcher creates a LinuxDirectoryWatcher on Linux', () { - expect(new DirectoryWatcher('.'), new TypeMatcher()); + expect(DirectoryWatcher('.'), TypeMatcher()); }); test('emits events for many nested files moved out then immediately back in', diff --git a/test/directory_watcher/mac_os_test.dart b/test/directory_watcher/mac_os_test.dart index 689d353184332..1470f71dc448d 100644 --- a/test/directory_watcher/mac_os_test.dart +++ b/test/directory_watcher/mac_os_test.dart @@ -12,12 +12,12 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new MacOSDirectoryWatcher(dir); + watcherFactory = (dir) => MacOSDirectoryWatcher(dir); sharedTests(); test('DirectoryWatcher creates a MacOSDirectoryWatcher on Mac OS', () { - expect(new DirectoryWatcher('.'), new TypeMatcher()); + expect(DirectoryWatcher('.'), TypeMatcher()); }); test( diff --git a/test/directory_watcher/polling_test.dart b/test/directory_watcher/polling_test.dart index 39bbbef0b9075..d64eb07060cb3 100644 --- a/test/directory_watcher/polling_test.dart +++ b/test/directory_watcher/polling_test.dart @@ -10,8 +10,8 @@ import '../utils.dart'; void main() { // Use a short delay to make the tests run quickly. - watcherFactory = (dir) => new PollingDirectoryWatcher(dir, - pollingDelay: new Duration(milliseconds: 100)); + watcherFactory = (dir) => + PollingDirectoryWatcher(dir, pollingDelay: Duration(milliseconds: 100)); sharedTests(); diff --git a/test/directory_watcher/shared.dart b/test/directory_watcher/shared.dart index 2c0f44116977c..f6e451cbc7e28 100644 --- a/test/directory_watcher/shared.dart +++ b/test/directory_watcher/shared.dart @@ -276,7 +276,7 @@ void sharedTests() { isAddEvent("new") ]); }, onPlatform: { - "mac-os": new Skip("https://github.com/dart-lang/watcher/issues/21") + "mac-os": Skip("https://github.com/dart-lang/watcher/issues/21") }); test('emits events for many nested files added at once', () async { @@ -316,7 +316,7 @@ void sharedTests() { renameDir("dir/old", "dir/new"); await inAnyOrder(unionAll(withPermutations((i, j, k) { - return new Set.from([ + return Set.from([ isRemoveEvent("dir/old/sub-$i/sub-$j/file-$k.txt"), isAddEvent("dir/new/sub-$i/sub-$j/file-$k.txt") ]); diff --git a/test/directory_watcher/windows_test.dart b/test/directory_watcher/windows_test.dart index 875f4ee818006..7931fa81922af 100644 --- a/test/directory_watcher/windows_test.dart +++ b/test/directory_watcher/windows_test.dart @@ -12,7 +12,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new WindowsDirectoryWatcher(dir); + watcherFactory = (dir) => WindowsDirectoryWatcher(dir); // TODO(grouma) - renable when https://github.com/dart-lang/sdk/issues/31760 // is resolved. @@ -21,7 +21,6 @@ void main() { }, skip: "SDK issue see - https://github.com/dart-lang/sdk/issues/31760"); test('DirectoryWatcher creates a WindowsDirectoryWatcher on Windows', () { - expect( - new DirectoryWatcher('.'), new TypeMatcher()); + expect(DirectoryWatcher('.'), TypeMatcher()); }); } diff --git a/test/file_watcher/native_test.dart b/test/file_watcher/native_test.dart index b6ed901bcba7c..2417dae6063d8 100644 --- a/test/file_watcher/native_test.dart +++ b/test/file_watcher/native_test.dart @@ -11,7 +11,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (file) => new NativeFileWatcher(file); + watcherFactory = (file) => NativeFileWatcher(file); setUp(() { writeFile("file.txt"); diff --git a/test/file_watcher/polling_test.dart b/test/file_watcher/polling_test.dart index 01d579a9f91d7..9492f658eb3bc 100644 --- a/test/file_watcher/polling_test.dart +++ b/test/file_watcher/polling_test.dart @@ -11,8 +11,8 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (file) => new PollingFileWatcher(file, - pollingDelay: new Duration(milliseconds: 100)); + watcherFactory = (file) => + PollingFileWatcher(file, pollingDelay: Duration(milliseconds: 100)); setUp(() { writeFile("file.txt"); diff --git a/test/file_watcher/shared.dart b/test/file_watcher/shared.dart index 286a042100e94..eefe5dfc49403 100644 --- a/test/file_watcher/shared.dart +++ b/test/file_watcher/shared.dart @@ -64,7 +64,7 @@ void sharedTests() { var sub = watcher.events.listen(null); deleteFile("file.txt"); - await new Future.delayed(new Duration(milliseconds: 10)); + await Future.delayed(Duration(milliseconds: 10)); await sub.cancel(); }); } diff --git a/test/no_subscription/linux_test.dart b/test/no_subscription/linux_test.dart index e9bfd69cada78..aa57637720eba 100644 --- a/test/no_subscription/linux_test.dart +++ b/test/no_subscription/linux_test.dart @@ -11,7 +11,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); + watcherFactory = (dir) => LinuxDirectoryWatcher(dir); sharedTests(); } diff --git a/test/no_subscription/mac_os_test.dart b/test/no_subscription/mac_os_test.dart index fc14ebf10704f..5ffb11738382b 100644 --- a/test/no_subscription/mac_os_test.dart +++ b/test/no_subscription/mac_os_test.dart @@ -12,7 +12,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new MacOSDirectoryWatcher(dir); + watcherFactory = (dir) => MacOSDirectoryWatcher(dir); sharedTests(); } diff --git a/test/no_subscription/polling_test.dart b/test/no_subscription/polling_test.dart index 75fa3a7a0f440..633ca2eb4f8f9 100644 --- a/test/no_subscription/polling_test.dart +++ b/test/no_subscription/polling_test.dart @@ -8,7 +8,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new PollingDirectoryWatcher(dir); + watcherFactory = (dir) => PollingDirectoryWatcher(dir); sharedTests(); } diff --git a/test/no_subscription/shared.dart b/test/no_subscription/shared.dart index ba8468401cf87..2fa3353e08d98 100644 --- a/test/no_subscription/shared.dart +++ b/test/no_subscription/shared.dart @@ -14,7 +14,7 @@ void sharedTests() { // utils.dart because it needs to be very explicit about when the event // stream is and is not subscribed. var watcher = createWatcher(); - var queue = new StreamQueue(watcher.events); + var queue = StreamQueue(watcher.events); queue.hasNext; var future = @@ -33,7 +33,7 @@ void sharedTests() { // Now write a file while we aren't listening. writeFile("unwatched.txt"); - queue = new StreamQueue(watcher.events); + queue = StreamQueue(watcher.events); future = expectLater(queue, emits(isWatchEvent(ChangeType.ADD, "added.txt"))); expect(queue, neverEmits(isWatchEvent(ChangeType.ADD, "unwatched.txt"))); diff --git a/test/path_set_test.dart b/test/path_set_test.dart index fe91d417f9ac1..9ca41818083ac 100644 --- a/test/path_set_test.dart +++ b/test/path_set_test.dart @@ -16,7 +16,7 @@ Matcher containsDir(String path) => predicate( void main() { PathSet paths; - setUp(() => paths = new PathSet("root")); + setUp(() => paths = PathSet("root")); group("adding a path", () { test("stores the path in the set", () { diff --git a/test/ready/linux_test.dart b/test/ready/linux_test.dart index e9bfd69cada78..aa57637720eba 100644 --- a/test/ready/linux_test.dart +++ b/test/ready/linux_test.dart @@ -11,7 +11,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new LinuxDirectoryWatcher(dir); + watcherFactory = (dir) => LinuxDirectoryWatcher(dir); sharedTests(); } diff --git a/test/ready/mac_os_test.dart b/test/ready/mac_os_test.dart index 9533cc81807f7..4bfdc8d3eddd4 100644 --- a/test/ready/mac_os_test.dart +++ b/test/ready/mac_os_test.dart @@ -11,7 +11,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new MacOSDirectoryWatcher(dir); + watcherFactory = (dir) => MacOSDirectoryWatcher(dir); sharedTests(); } diff --git a/test/ready/polling_test.dart b/test/ready/polling_test.dart index 75fa3a7a0f440..633ca2eb4f8f9 100644 --- a/test/ready/polling_test.dart +++ b/test/ready/polling_test.dart @@ -8,7 +8,7 @@ import 'shared.dart'; import '../utils.dart'; void main() { - watcherFactory = (dir) => new PollingDirectoryWatcher(dir); + watcherFactory = (dir) => PollingDirectoryWatcher(dir); sharedTests(); } diff --git a/test/ready/shared.dart b/test/ready/shared.dart index 730d5795345ed..76089e25ed0a8 100644 --- a/test/ready/shared.dart +++ b/test/ready/shared.dart @@ -38,7 +38,7 @@ void sharedTests() { // Ensure ready completes immediately expect( - watcher.ready.timeout(new Duration(milliseconds: 0), + watcher.ready.timeout(Duration(milliseconds: 0), onTimeout: () => throw 'Does not complete immedately'), completes); }); diff --git a/test/utils.dart b/test/utils.dart index 7462c991ae1da..95f594d8a7b2a 100644 --- a/test/utils.dart +++ b/test/utils.dart @@ -61,13 +61,13 @@ Future startWatcher({String path}) async { assert(p.isRelative(path) && !path.startsWith("..")); var mtime = _mockFileModificationTimes[path]; - return new DateTime.fromMillisecondsSinceEpoch(mtime ?? 0); + return DateTime.fromMillisecondsSinceEpoch(mtime ?? 0); }); // We want to wait until we're ready *after* we subscribe to the watcher's // events. var watcher = createWatcher(path: path); - _watcherEvents = new StreamQueue(watcher.events); + _watcherEvents = StreamQueue(watcher.events); // Forces a subscription to the underlying stream. _watcherEvents.hasNext; await watcher.ready; @@ -93,7 +93,7 @@ List _collectedStreamMatchers; /// The returned matcher will match each of the collected matchers in order. StreamMatcher _collectStreamMatcher(block()) { var oldStreamMatchers = _collectedStreamMatchers; - _collectedStreamMatchers = new List(); + _collectedStreamMatchers = List(); try { block(); return emitsInOrder(_collectedStreamMatchers); @@ -207,12 +207,12 @@ void writeFile(String path, {String contents, bool updateModified}) { var fullPath = p.join(d.sandbox, path); // Create any needed subdirectories. - var dir = new Directory(p.dirname(fullPath)); + var dir = Directory(p.dirname(fullPath)); if (!dir.existsSync()) { dir.createSync(recursive: true); } - new File(fullPath).writeAsStringSync(contents); + File(fullPath).writeAsStringSync(contents); if (updateModified) { path = p.normalize(path); @@ -224,12 +224,12 @@ void writeFile(String path, {String contents, bool updateModified}) { /// Schedules deleting a file in the sandbox at [path]. void deleteFile(String path) { - new File(p.join(d.sandbox, path)).deleteSync(); + File(p.join(d.sandbox, path)).deleteSync(); } /// Schedules renaming a file in the sandbox from [from] to [to]. void renameFile(String from, String to) { - new File(p.join(d.sandbox, from)).renameSync(p.join(d.sandbox, to)); + File(p.join(d.sandbox, from)).renameSync(p.join(d.sandbox, to)); // Make sure we always use the same separator on Windows. to = p.normalize(to); @@ -240,17 +240,17 @@ void renameFile(String from, String to) { /// Schedules creating a directory in the sandbox at [path]. void createDir(String path) { - new Directory(p.join(d.sandbox, path)).createSync(); + Directory(p.join(d.sandbox, path)).createSync(); } /// Schedules renaming a directory in the sandbox from [from] to [to]. void renameDir(String from, String to) { - new Directory(p.join(d.sandbox, from)).renameSync(p.join(d.sandbox, to)); + Directory(p.join(d.sandbox, from)).renameSync(p.join(d.sandbox, to)); } /// Schedules deleting a directory in the sandbox at [path]. void deleteDir(String path) { - new Directory(p.join(d.sandbox, path)).deleteSync(recursive: true); + Directory(p.join(d.sandbox, path)).deleteSync(recursive: true); } /// Runs [callback] with every permutation of non-negative numbers for each @@ -261,7 +261,7 @@ void deleteDir(String path) { /// [limit] defaults to 3. Set withPermutations(S callback(int i, int j, int k), {int limit}) { if (limit == null) limit = 3; - var results = new Set(); + var results = Set(); for (var i = 0; i < limit; i++) { for (var j = 0; j < limit; j++) { for (var k = 0; k < limit; k++) {