Run dartfmt --fix (#65)
Drops optional `new` and `const`
Bump SDK constraint to `2.0.0` to ensure compatibility with omitted
`new`.
diff --git a/benchmark/path_set.dart b/benchmark/path_set.dart
index bf9f5fc..8a5b843 100644
--- a/benchmark/path_set.dart
+++ b/benchmark/path_set.dart
@@ -19,11 +19,11 @@
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 @@
}
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 da3c263..1477e42 100644
--- a/example/watch.dart
+++ b/example/watch.dart
@@ -14,7 +14,7 @@
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 1904192..de7b718 100644
--- a/lib/src/async_queue.dart
+++ b/lib/src/async_queue.dart
@@ -17,7 +17,7 @@
/// needed. When all items are processed, it stops processing until more items
/// are added.
class AsyncQueue<T> {
- final _items = new Queue<T>();
+ final _items = Queue<T>();
/// 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 6beebd0..8c52ed9 100644
--- a/lib/src/directory_watcher.dart
+++ b/lib/src/directory_watcher.dart
@@ -29,10 +29,10 @@
/// 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 5eeed23..f3866c6 100644
--- a/lib/src/directory_watcher/linux.dart
+++ b/lib/src/directory_watcher/linux.dart
@@ -28,7 +28,7 @@
String get directory => path;
LinuxDirectoryWatcher(String directory)
- : super(directory, () => new _LinuxDirectoryWatcher(directory));
+ : super(directory, () => _LinuxDirectoryWatcher(directory));
}
class _LinuxDirectoryWatcher
@@ -37,16 +37,16 @@
String get path => _files.root;
Stream<WatchEvent> get events => _eventsController.stream;
- final _eventsController = new StreamController<WatchEvent>.broadcast();
+ final _eventsController = StreamController<WatchEvent>.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<FileSystemEvent>();
+ var _nativeEvents = StreamGroup<FileSystemEvent>();
/// All known files recursively within [path].
final PathSet _files;
@@ -60,12 +60,12 @@
///
/// These are gathered together so that they may all be canceled when the
/// watcher is closed.
- final _subscriptions = new Set<StreamSubscription>();
+ final _subscriptions = Set<StreamSubscription>();
- _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 @@
// Batch the inotify changes together so that we can dedup events.
var innerStream = _nativeEvents.stream
- .transform(new BatchedStreamTransformer<FileSystemEvent>());
+ .transform(BatchedStreamTransformer<FileSystemEvent>());
_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 @@
// 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<FileSystemEvent> batch) {
- var files = new Set<String>();
- var dirs = new Set<String>();
- var changed = new Set<String>();
+ var files = Set<String>();
+ var dirs = Set<String>();
+ var changed = Set<String>();
// 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 @@
/// 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 @@
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 61531c5..f593fbd 100644
--- a/lib/src/directory_watcher/mac_os.dart
+++ b/lib/src/directory_watcher/mac_os.dart
@@ -27,7 +27,7 @@
String get directory => path;
MacOSDirectoryWatcher(String directory)
- : super(directory, () => new _MacOSDirectoryWatcher(directory));
+ : super(directory, () => _MacOSDirectoryWatcher(directory));
}
class _MacOSDirectoryWatcher
@@ -36,12 +36,12 @@
final String path;
Stream<WatchEvent> get events => _eventsController.stream;
- final _eventsController = new StreamController<WatchEvent>.broadcast();
+ final _eventsController = StreamController<WatchEvent>.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 @@
/// The subscriptions to [Directory.list] calls for listing the contents of a
/// subdirectory that was moved into the watched directory.
- final _listSubscriptions = new Set<StreamSubscription<FileSystemEntity>>();
+ final _listSubscriptions = Set<StreamSubscription<FileSystemEntity>>();
/// The timer for tracking how long we wait for an initial batch of bogus
/// events (see issue 14373).
@@ -72,7 +72,7 @@
_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 @@
if (_files.containsDir(path)) continue;
StreamSubscription<FileSystemEntity> 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 @@
// 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<String>();
+ if (!event.isDirectory) return Set<String>();
if (event is FileSystemMoveEvent) {
- return new Set<String>.from([event.path, event.destination]);
+ return Set<String>.from([event.path, event.destination]);
}
- return new Set<String>.from([event.path]);
+ return Set<String>.from([event.path]);
}));
isInModifiedDirectory(String path) =>
@@ -194,9 +193,7 @@
addEvent(String path, FileSystemEvent event) {
if (isInModifiedDirectory(path)) return;
- eventsForPaths
- .putIfAbsent(path, () => new Set<FileSystemEvent>())
- .add(event);
+ eventsForPaths.putIfAbsent(path, () => Set<FileSystemEvent>()).add(event);
}
for (var event in batch) {
@@ -271,11 +268,11 @@
// [_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 @@
List<FileSystemEvent> _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 = <FileSystemEvent>[];
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 @@
// 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 @@
/// 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<FileSystemEvent>());
+ .transform(BatchedStreamTransformer<FileSystemEvent>());
_watchSubscription = innerStream.listen(_onBatch,
onError: _eventsController.addError, onDone: _onDone);
}
@@ -362,8 +359,8 @@
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 @@
/// 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 790d0b9..735a807 100644
--- a/lib/src/directory_watcher/polling.dart
+++ b/lib/src/directory_watcher/polling.dart
@@ -25,8 +25,8 @@
/// 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 @@
final String path;
Stream<WatchEvent> get events => _events.stream;
- final _events = new StreamController<WatchEvent>.broadcast();
+ final _events = StreamController<WatchEvent>.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 @@
/// The previous modification times of the files in the directory.
///
/// Used to tell which files have been modified.
- final _lastModifieds = new Map<String, DateTime>();
+ final _lastModifieds = Map<String, DateTime>();
/// The subscription used while [directory] is being listed.
///
@@ -70,11 +70,11 @@
///
/// 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<String>();
+ final _polledFiles = Set<String>();
_PollingDirectoryWatcher(this.path, this._pollingDelay) {
- _filesToProcess = new AsyncQueue<String>(_processFile,
- onError: (e, StackTrace stackTrace) {
+ _filesToProcess =
+ AsyncQueue<String>(_processFile, onError: (e, StackTrace stackTrace) {
if (!_events.isClosed) _events.addError(e, stackTrace);
});
@@ -107,7 +107,7 @@
_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 @@
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 @@
// 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 baeaf23..0214939 100644
--- a/lib/src/directory_watcher/windows.dart
+++ b/lib/src/directory_watcher/windows.dart
@@ -21,11 +21,11 @@
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<FileSystemEvent> events = [];
Timer timer;
@@ -34,7 +34,7 @@
if (timer != null) {
timer.cancel();
}
- timer = new Timer(_BATCH_DELAY, callback);
+ timer = Timer(_BATCH_DELAY, callback);
}
void cancelTimer() {
@@ -48,15 +48,15 @@
final String path;
Stream<WatchEvent> get events => _eventsController.stream;
- final _eventsController = new StreamController<WatchEvent>.broadcast();
+ final _eventsController = StreamController<WatchEvent>.broadcast();
bool get isReady => _readyCompleter.isCompleted;
Future get ready => _readyCompleter.future;
- final _readyCompleter = new Completer();
+ final _readyCompleter = Completer();
final Map<String, _EventBatcher> _eventBatchers =
- new HashMap<String, _EventBatcher>();
+ HashMap<String, _EventBatcher>();
/// The set of files that are known to exist recursively within the watched
/// directory.
@@ -81,11 +81,11 @@
/// The subscriptions to the [Directory.list] calls for listing the contents
/// of subdirectories that were moved into the watched directory.
final Set<StreamSubscription<FileSystemEntity>> _listSubscriptions =
- new HashSet<StreamSubscription<FileSystemEntity>>();
+ HashSet<StreamSubscription<FileSystemEntity>>();
_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 @@
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 @@
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 @@
if (_files.containsDir(path)) continue;
- var stream = new Directory(path).list(recursive: true);
+ var stream = Directory(path).list(recursive: true);
StreamSubscription<FileSystemEntity> subscription;
subscription = stream.listen((entity) {
if (entity is Directory) return;
@@ -222,11 +222,11 @@
// 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<String>();
+ if (!event.isDirectory) return Set<String>();
if (event is FileSystemMoveEvent) {
- return new Set<String>.from([event.path, event.destination]);
+ return Set<String>.from([event.path, event.destination]);
}
- return new Set<String>.from([event.path]);
+ return Set<String>.from([event.path]);
}));
isInModifiedDirectory(String path) =>
@@ -234,9 +234,7 @@
addEvent(String path, FileSystemEvent event) {
if (isInModifiedDirectory(path)) return;
- eventsForPaths
- .putIfAbsent(path, () => new Set<FileSystemEvent>())
- .add(event);
+ eventsForPaths.putIfAbsent(path, () => Set<FileSystemEvent>()).add(event);
}
for (var event in batch) {
@@ -297,11 +295,11 @@
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 @@
List<FileSystemEvent> _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 = <FileSystemEvent>[];
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 @@
/// 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 @@
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 @@
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 09065bc..c4abddd 100644
--- a/lib/src/file_watcher.dart
+++ b/lib/src/file_watcher.dart
@@ -33,8 +33,8 @@
// [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 5f56f73..ff25eb7 100644
--- a/lib/src/file_watcher/native.dart
+++ b/lib/src/file_watcher/native.dart
@@ -15,20 +15,19 @@
/// 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<WatchEvent> get events => _eventsController.stream;
- final _eventsController = new StreamController<WatchEvent>.broadcast();
+ final _eventsController = StreamController<WatchEvent>.broadcast();
bool get isReady => _readyCompleter.isCompleted;
Future get ready => _readyCompleter.future;
- final _readyCompleter = new Completer();
+ final _readyCompleter = Completer();
StreamSubscription _subscription;
@@ -42,9 +41,9 @@
void _listen() {
// Batch the events together so that we can dedup them.
- _subscription = new File(path)
+ _subscription = File(path)
.watch()
- .transform(new BatchedStreamTransformer<FileSystemEvent>())
+ .transform(BatchedStreamTransformer<FileSystemEvent>())
.listen(_onBatch, onError: _eventsController.addError, onDone: _onDone);
}
@@ -55,11 +54,11 @@
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 @@
// 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 960b11b..777038f 100644
--- a/lib/src/file_watcher/polling.dart
+++ b/lib/src/file_watcher/polling.dart
@@ -14,8 +14,8 @@
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 @@
final String path;
Stream<WatchEvent> get events => _eventsController.stream;
- final _eventsController = new StreamController<WatchEvent>.broadcast();
+ final _eventsController = StreamController<WatchEvent>.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 @@
DateTime _lastModified;
_PollingFileWatcher(this.path, Duration pollingDelay) {
- _timer = new Timer.periodic(pollingDelay, (_) => _poll());
+ _timer = Timer.periodic(pollingDelay, (_) => _poll());
_poll();
}
@@ -49,11 +49,11 @@
// 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 @@
_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 77737f8..9a2c03c 100644
--- a/lib/src/path_set.dart
+++ b/lib/src/path_set.dart
@@ -22,7 +22,7 @@
/// 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 @@
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 @@
/// empty set.
Set<String> 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 @@
// 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 @@
// 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 @@
///
/// [dirPath] should be the path to [dir].
Set<String> _explicitPathsWithin(_Entry dir, String dirPath) {
- var paths = new Set<String>();
+ var paths = Set<String>();
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 e96b918..e00ebb0 100644
--- a/lib/src/resubscribable.dart
+++ b/lib/src/resubscribable.dart
@@ -32,7 +32,7 @@
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 @@
ManuallyClosedWatcher watcher;
StreamSubscription subscription;
- _eventsController = new StreamController<WatchEvent>.broadcast(
+ _eventsController = StreamController<WatchEvent>.broadcast(
onListen: () {
watcher = _factory();
subscription = watcher.events.listen(_eventsController.add,
@@ -57,7 +57,7 @@
// 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 05ee9ba..59a5eb6 100644
--- a/lib/src/stat.dart
+++ b/lib/src/stat.dart
@@ -24,7 +24,7 @@
/// Gets the modification time for the file at [path].
Future<DateTime> 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 30fbaae..676ae28 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -18,7 +18,7 @@
/// Returns the union of all elements in each set in [sets].
Set<T> unionAll<T>(Iterable<Set<T>> sets) =>
- sets.fold(new Set<T>(), (union, set) => union.union(set));
+ sets.fold(Set<T>(), (union, set) => union.union(set));
/// A stream transformer that batches all events that are sent at the same time.
///
@@ -29,8 +29,8 @@
/// microtasks.
class BatchedStreamTransformer<T> extends StreamTransformerBase<T, List<T>> {
Stream<List<T>> bind(Stream<T> input) {
- var batch = new Queue<T>();
- return new StreamTransformer<T, List<T>>.fromHandlers(
+ var batch = Queue<T>();
+ return StreamTransformer<T, List<T>>.fromHandlers(
handleData: (event, sink) {
batch.add(event);
diff --git a/lib/src/watch_event.dart b/lib/src/watch_event.dart
index 54093a5..94ee5cb 100644
--- a/lib/src/watch_event.dart
+++ b/lib/src/watch_event.dart
@@ -18,13 +18,13 @@
/// 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 b3cebe6..107ac8f 100644
--- a/lib/watcher.dart
+++ b/lib/watcher.dart
@@ -58,10 +58,10 @@
/// 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 8f38a49..552b13a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -8,7 +8,7 @@
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 744045f..0b81919 100644
--- a/test/directory_watcher/linux_test.dart
+++ b/test/directory_watcher/linux_test.dart
@@ -12,12 +12,12 @@
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<LinuxDirectoryWatcher>());
+ expect(DirectoryWatcher('.'), TypeMatcher<LinuxDirectoryWatcher>());
});
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 689d353..1470f71 100644
--- a/test/directory_watcher/mac_os_test.dart
+++ b/test/directory_watcher/mac_os_test.dart
@@ -12,12 +12,12 @@
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<MacOSDirectoryWatcher>());
+ expect(DirectoryWatcher('.'), TypeMatcher<MacOSDirectoryWatcher>());
});
test(
diff --git a/test/directory_watcher/polling_test.dart b/test/directory_watcher/polling_test.dart
index 39bbbef..d64eb07 100644
--- a/test/directory_watcher/polling_test.dart
+++ b/test/directory_watcher/polling_test.dart
@@ -10,8 +10,8 @@
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 2c0f441..f6e451c 100644
--- a/test/directory_watcher/shared.dart
+++ b/test/directory_watcher/shared.dart
@@ -276,7 +276,7 @@
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 @@
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 875f4ee..7931fa8 100644
--- a/test/directory_watcher/windows_test.dart
+++ b/test/directory_watcher/windows_test.dart
@@ -12,7 +12,7 @@
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 @@
}, skip: "SDK issue see - https://github.com/dart-lang/sdk/issues/31760");
test('DirectoryWatcher creates a WindowsDirectoryWatcher on Windows', () {
- expect(
- new DirectoryWatcher('.'), new TypeMatcher<WindowsDirectoryWatcher>());
+ expect(DirectoryWatcher('.'), TypeMatcher<WindowsDirectoryWatcher>());
});
}
diff --git a/test/file_watcher/native_test.dart b/test/file_watcher/native_test.dart
index b6ed901..2417dae 100644
--- a/test/file_watcher/native_test.dart
+++ b/test/file_watcher/native_test.dart
@@ -11,7 +11,7 @@
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 01d579a..9492f65 100644
--- a/test/file_watcher/polling_test.dart
+++ b/test/file_watcher/polling_test.dart
@@ -11,8 +11,8 @@
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 286a042..eefe5df 100644
--- a/test/file_watcher/shared.dart
+++ b/test/file_watcher/shared.dart
@@ -64,7 +64,7 @@
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 e9bfd69..aa57637 100644
--- a/test/no_subscription/linux_test.dart
+++ b/test/no_subscription/linux_test.dart
@@ -11,7 +11,7 @@
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 fc14ebf..5ffb117 100644
--- a/test/no_subscription/mac_os_test.dart
+++ b/test/no_subscription/mac_os_test.dart
@@ -12,7 +12,7 @@
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 75fa3a7..633ca2e 100644
--- a/test/no_subscription/polling_test.dart
+++ b/test/no_subscription/polling_test.dart
@@ -8,7 +8,7 @@
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 ba84684..2fa3353 100644
--- a/test/no_subscription/shared.dart
+++ b/test/no_subscription/shared.dart
@@ -14,7 +14,7 @@
// 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 @@
// 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 fe91d41..9ca4181 100644
--- a/test/path_set_test.dart
+++ b/test/path_set_test.dart
@@ -16,7 +16,7 @@
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 e9bfd69..aa57637 100644
--- a/test/ready/linux_test.dart
+++ b/test/ready/linux_test.dart
@@ -11,7 +11,7 @@
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 9533cc8..4bfdc8d 100644
--- a/test/ready/mac_os_test.dart
+++ b/test/ready/mac_os_test.dart
@@ -11,7 +11,7 @@
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 75fa3a7..633ca2e 100644
--- a/test/ready/polling_test.dart
+++ b/test/ready/polling_test.dart
@@ -8,7 +8,7 @@
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 730d579..76089e2 100644
--- a/test/ready/shared.dart
+++ b/test/ready/shared.dart
@@ -38,7 +38,7 @@
// 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 7462c99..95f594d 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -61,13 +61,13 @@
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 @@
/// The returned matcher will match each of the collected matchers in order.
StreamMatcher _collectStreamMatcher(block()) {
var oldStreamMatchers = _collectedStreamMatchers;
- _collectedStreamMatchers = new List<StreamMatcher>();
+ _collectedStreamMatchers = List<StreamMatcher>();
try {
block();
return emitsInOrder(_collectedStreamMatchers);
@@ -207,12 +207,12 @@
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 @@
/// 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 @@
/// 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 @@
/// [limit] defaults to 3.
Set<S> withPermutations<S>(S callback(int i, int j, int k), {int limit}) {
if (limit == null) limit = 3;
- var results = new Set<S>();
+ var results = Set<S>();
for (var i = 0; i < limit; i++) {
for (var j = 0; j < limit; j++) {
for (var k = 0; k < limit; k++) {