Use Dart 2 constants (dart-lang/watcher#60)
diff --git a/pkgs/watcher/CHANGELOG.md b/pkgs/watcher/CHANGELOG.md index fe30bc6..d8f2d5f 100644 --- a/pkgs/watcher/CHANGELOG.md +++ b/pkgs/watcher/CHANGELOG.md
@@ -1,3 +1,7 @@ +# 0.9.7+9 + +* Internal changes only. + # 0.9.7+8 * Fix Dart 2.0 type issues on Mac and Windows.
diff --git a/pkgs/watcher/lib/src/constructable_file_system_event.dart b/pkgs/watcher/lib/src/constructable_file_system_event.dart index a0f153e..29b7c8d 100644 --- a/pkgs/watcher/lib/src/constructable_file_system_event.dart +++ b/pkgs/watcher/lib/src/constructable_file_system_event.dart
@@ -14,7 +14,7 @@ class ConstructableFileSystemCreateEvent extends _ConstructableFileSystemEvent implements FileSystemCreateEvent { - final type = FileSystemEvent.CREATE; + final type = FileSystemEvent.create; ConstructableFileSystemCreateEvent(String path, bool isDirectory) : super(path, isDirectory); @@ -24,7 +24,7 @@ class ConstructableFileSystemDeleteEvent extends _ConstructableFileSystemEvent implements FileSystemDeleteEvent { - final type = FileSystemEvent.DELETE; + final type = FileSystemEvent.delete; ConstructableFileSystemDeleteEvent(String path, bool isDirectory) : super(path, isDirectory); @@ -35,7 +35,7 @@ class ConstructableFileSystemModifyEvent extends _ConstructableFileSystemEvent implements FileSystemModifyEvent { final bool contentChanged; - final type = FileSystemEvent.MODIFY; + final type = FileSystemEvent.modify; ConstructableFileSystemModifyEvent( String path, bool isDirectory, this.contentChanged) @@ -48,7 +48,7 @@ class ConstructableFileSystemMoveEvent extends _ConstructableFileSystemEvent implements FileSystemMoveEvent { final String destination; - final type = FileSystemEvent.MOVE; + final type = FileSystemEvent.move; ConstructableFileSystemMoveEvent( String path, bool isDirectory, this.destination)
diff --git a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart index 5ad9984..9da413a 100644 --- a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart +++ b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
@@ -244,13 +244,13 @@ // If we previously thought this was a MODIFY, we now consider it to be a // CREATE or REMOVE event. This is safe for the same reason as above. - if (type == FileSystemEvent.MODIFY) { + if (type == FileSystemEvent.modify) { type = event.type; continue; } // A CREATE event contradicts a REMOVE event and vice versa. - assert(type == FileSystemEvent.CREATE || type == FileSystemEvent.DELETE); + assert(type == FileSystemEvent.create || type == FileSystemEvent.delete); if (type != event.type) return null; } @@ -258,23 +258,23 @@ // from FSEvents reporting an add that happened prior to the watch // beginning. If we also received a MODIFY event, we want to report that, // but not the CREATE. - if (type == FileSystemEvent.CREATE && + if (type == FileSystemEvent.create && hadModifyEvent && _files.contains(batch.first.path)) { - type = FileSystemEvent.MODIFY; + type = FileSystemEvent.modify; } switch (type) { - case FileSystemEvent.CREATE: + case FileSystemEvent.create: // Issue 16003 means that a CREATE event for a directory can indicate // that the directory was moved and then re-created. // [_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); - case FileSystemEvent.DELETE: + case FileSystemEvent.delete: return new ConstructableFileSystemDeleteEvent(batch.first.path, isDir); - case FileSystemEvent.MODIFY: + case FileSystemEvent.modify: return new ConstructableFileSystemModifyEvent( batch.first.path, isDir, false); default:
diff --git a/pkgs/watcher/lib/src/directory_watcher/windows.dart b/pkgs/watcher/lib/src/directory_watcher/windows.dart index db9ca83..0e550ae 100644 --- a/pkgs/watcher/lib/src/directory_watcher/windows.dart +++ b/pkgs/watcher/lib/src/directory_watcher/windows.dart
@@ -132,7 +132,7 @@ // the directory is now gone. if (event is FileSystemMoveEvent || event is FileSystemDeleteEvent || - (FileSystemEntity.typeSync(path) == FileSystemEntityType.NOT_FOUND)) { + (FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound)) { for (var path in _files.paths) { _emitEvent(ChangeType.REMOVE, path); } @@ -283,27 +283,27 @@ // If we previously thought this was a MODIFY, we now consider it to be a // CREATE or REMOVE event. This is safe for the same reason as above. - if (type == FileSystemEvent.MODIFY) { + if (type == FileSystemEvent.modify) { type = event.type; continue; } // A CREATE event contradicts a REMOVE event and vice versa. - assert(type == FileSystemEvent.CREATE || - type == FileSystemEvent.DELETE || - type == FileSystemEvent.MOVE); + assert(type == FileSystemEvent.create || + type == FileSystemEvent.delete || + type == FileSystemEvent.move); if (type != event.type) return null; } switch (type) { - case FileSystemEvent.CREATE: + case FileSystemEvent.create: return new ConstructableFileSystemCreateEvent(batch.first.path, isDir); - case FileSystemEvent.DELETE: + case FileSystemEvent.delete: return new ConstructableFileSystemDeleteEvent(batch.first.path, isDir); - case FileSystemEvent.MODIFY: + case FileSystemEvent.modify: return new ConstructableFileSystemModifyEvent( batch.first.path, isDir, false); - case FileSystemEvent.MOVE: + case FileSystemEvent.move: return null; default: throw 'unreachable';
diff --git a/pkgs/watcher/lib/src/file_watcher/native.dart b/pkgs/watcher/lib/src/file_watcher/native.dart index 8e7dd09..5f56f73 100644 --- a/pkgs/watcher/lib/src/file_watcher/native.dart +++ b/pkgs/watcher/lib/src/file_watcher/native.dart
@@ -49,7 +49,7 @@ } void _onBatch(List<FileSystemEvent> batch) { - if (batch.any((event) => event.type == FileSystemEvent.DELETE)) { + if (batch.any((event) => event.type == FileSystemEvent.delete)) { // If the file is deleted, the underlying stream will close. We handle // emitting our own REMOVE event in [_onDone]. return;
diff --git a/pkgs/watcher/pubspec.yaml b/pkgs/watcher/pubspec.yaml index 3cb9643..2f449ff 100644 --- a/pkgs/watcher/pubspec.yaml +++ b/pkgs/watcher/pubspec.yaml
@@ -1,12 +1,12 @@ name: watcher -version: 0.9.7+8 +version: 0.9.7+9 author: Dart Team <misc@dartlang.org> homepage: https://github.com/dart-lang/watcher description: > A file system watcher. It monitors changes to contents of directories and sends notifications when files have been added, removed, or modified. environment: - sdk: '>=2.0.0-dev.20.0 <2.0.0' + sdk: '>=2.0.0-dev.61.0 <2.0.0' dependencies: async: '>=1.10.0 <3.0.0' path: '>=0.9.0 <2.0.0'