Remove unnecessary ConstructableFileSystemEvent classes (dart-lang/watcher#143)
diff --git a/pkgs/watcher/.github/workflows/test-package.yml b/pkgs/watcher/.github/workflows/test-package.yml index 1296823..bc16dd1 100644 --- a/pkgs/watcher/.github/workflows/test-package.yml +++ b/pkgs/watcher/.github/workflows/test-package.yml
@@ -46,7 +46,7 @@ fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - sdk: [2.19.0, dev] + sdk: [3.0.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
diff --git a/pkgs/watcher/CHANGELOG.md b/pkgs/watcher/CHANGELOG.md index c8aa266..17b93f9 100644 --- a/pkgs/watcher/CHANGELOG.md +++ b/pkgs/watcher/CHANGELOG.md
@@ -1,3 +1,8 @@ +## 1.1.0-dev + +- Require Dart SDK >= 3.0.0 +- Remove usage of redundant ConstructableFileSystemEvent classes. +- ## 1.0.3-dev - Require Dart SDK >= 2.19
diff --git a/pkgs/watcher/lib/src/constructable_file_system_event.dart b/pkgs/watcher/lib/src/constructable_file_system_event.dart deleted file mode 100644 index 0011a8d..0000000 --- a/pkgs/watcher/lib/src/constructable_file_system_event.dart +++ /dev/null
@@ -1,71 +0,0 @@ -// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:io'; - -abstract class _ConstructableFileSystemEvent implements FileSystemEvent { - @override - final bool isDirectory; - @override - final String path; - @override - int get type; - - _ConstructableFileSystemEvent(this.path, this.isDirectory); -} - -class ConstructableFileSystemCreateEvent extends _ConstructableFileSystemEvent - implements FileSystemCreateEvent { - @override - final type = FileSystemEvent.create; - - ConstructableFileSystemCreateEvent(String path, bool isDirectory) - : super(path, isDirectory); - - @override - String toString() => "FileSystemCreateEvent('$path')"; -} - -class ConstructableFileSystemDeleteEvent extends _ConstructableFileSystemEvent - implements FileSystemDeleteEvent { - @override - final type = FileSystemEvent.delete; - - ConstructableFileSystemDeleteEvent(String path, bool isDirectory) - : super(path, isDirectory); - - @override - String toString() => "FileSystemDeleteEvent('$path')"; -} - -class ConstructableFileSystemModifyEvent extends _ConstructableFileSystemEvent - implements FileSystemModifyEvent { - @override - final bool contentChanged; - @override - final type = FileSystemEvent.modify; - - ConstructableFileSystemModifyEvent( - String path, bool isDirectory, this.contentChanged) - : super(path, isDirectory); - - @override - String toString() => - "FileSystemModifyEvent('$path', contentChanged=$contentChanged)"; -} - -class ConstructableFileSystemMoveEvent extends _ConstructableFileSystemEvent - implements FileSystemMoveEvent { - @override - final String destination; - @override - final type = FileSystemEvent.move; - - ConstructableFileSystemMoveEvent( - String path, bool isDirectory, this.destination) - : super(path, isDirectory); - - @override - String toString() => "FileSystemMoveEvent('$path', '$destination')"; -}
diff --git a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart index 415d17a..d2db975 100644 --- a/pkgs/watcher/lib/src/directory_watcher/mac_os.dart +++ b/pkgs/watcher/lib/src/directory_watcher/mac_os.dart
@@ -7,7 +7,6 @@ import 'package:path/path.dart' as p; -import '../constructable_file_system_event.dart'; import '../directory_watcher.dart'; import '../path_set.dart'; import '../resubscribable.dart'; @@ -285,12 +284,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 ConstructableFileSystemCreateEvent(batch.first.path, false); + return FileSystemCreateEvent(batch.first.path, false); case FileSystemEvent.delete: - return ConstructableFileSystemDeleteEvent(batch.first.path, isDir); + return FileSystemDeleteEvent(batch.first.path, isDir); case FileSystemEvent.modify: - return ConstructableFileSystemModifyEvent( - batch.first.path, isDir, false); + return FileSystemModifyEvent(batch.first.path, isDir, false); default: throw StateError('unreachable'); } @@ -312,26 +310,26 @@ var events = <FileSystemEvent>[]; if (fileExisted) { if (fileExists) { - events.add(ConstructableFileSystemModifyEvent(path, false, false)); + events.add(FileSystemModifyEvent(path, false, false)); } else { - events.add(ConstructableFileSystemDeleteEvent(path, false)); + events.add(FileSystemDeleteEvent(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(ConstructableFileSystemDeleteEvent(path, true)); - events.add(ConstructableFileSystemCreateEvent(path, true)); + events.add(FileSystemDeleteEvent(path, true)); + events.add(FileSystemCreateEvent(path, true)); } else { - events.add(ConstructableFileSystemDeleteEvent(path, true)); + events.add(FileSystemDeleteEvent(path, true)); } } if (!fileExisted && fileExists) { - events.add(ConstructableFileSystemCreateEvent(path, false)); + events.add(FileSystemCreateEvent(path, false)); } else if (!dirExisted && dirExists) { - events.add(ConstructableFileSystemCreateEvent(path, true)); + events.add(FileSystemCreateEvent(path, true)); } return events;
diff --git a/pkgs/watcher/lib/src/directory_watcher/windows.dart b/pkgs/watcher/lib/src/directory_watcher/windows.dart index 141545b..aff7a74 100644 --- a/pkgs/watcher/lib/src/directory_watcher/windows.dart +++ b/pkgs/watcher/lib/src/directory_watcher/windows.dart
@@ -9,7 +9,6 @@ import 'package:path/path.dart' as p; -import '../constructable_file_system_event.dart'; import '../directory_watcher.dart'; import '../path_set.dart'; import '../resubscribable.dart'; @@ -306,12 +305,11 @@ switch (type) { case FileSystemEvent.create: - return ConstructableFileSystemCreateEvent(batch.first.path, isDir); + return FileSystemCreateEvent(batch.first.path, isDir); case FileSystemEvent.delete: - return ConstructableFileSystemDeleteEvent(batch.first.path, isDir); + return FileSystemDeleteEvent(batch.first.path, isDir); case FileSystemEvent.modify: - return ConstructableFileSystemModifyEvent( - batch.first.path, isDir, false); + return FileSystemModifyEvent(batch.first.path, isDir, false); case FileSystemEvent.move: return null; default: @@ -342,26 +340,26 @@ var events = <FileSystemEvent>[]; if (fileExisted) { if (fileExists) { - events.add(ConstructableFileSystemModifyEvent(path, false, false)); + events.add(FileSystemModifyEvent(path, false, false)); } else { - events.add(ConstructableFileSystemDeleteEvent(path, false)); + events.add(FileSystemDeleteEvent(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(ConstructableFileSystemDeleteEvent(path, true)); - events.add(ConstructableFileSystemCreateEvent(path, true)); + events.add(FileSystemDeleteEvent(path, true)); + events.add(FileSystemCreateEvent(path, true)); } else { - events.add(ConstructableFileSystemDeleteEvent(path, true)); + events.add(FileSystemDeleteEvent(path, true)); } } if (!fileExisted && fileExists) { - events.add(ConstructableFileSystemCreateEvent(path, false)); + events.add(FileSystemCreateEvent(path, false)); } else if (!dirExisted && dirExists) { - events.add(ConstructableFileSystemCreateEvent(path, true)); + events.add(FileSystemCreateEvent(path, true)); } return events;
diff --git a/pkgs/watcher/pubspec.yaml b/pkgs/watcher/pubspec.yaml index e64e79d..5df994f 100644 --- a/pkgs/watcher/pubspec.yaml +++ b/pkgs/watcher/pubspec.yaml
@@ -1,12 +1,12 @@ name: watcher -version: 1.0.3-dev +version: 1.1.0-dev description: >- A file system watcher. It monitors changes to contents of directories and sends notifications when files have been added, removed, or modified. repository: https://github.com/dart-lang/watcher environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^3.0.0 dependencies: async: ^2.5.0