-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[ Widget Preview ] Ignore modifications to files in ephemeral directories #178398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ries The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes #178317
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses an issue where the widget previewer would crash when files in ephemeral directories were modified. The changes introduce logic to ignore file system events from these directories and from files not associated with an analysis context. This is a solid fix, complete with a new regression test. I have one minor suggestion to improve code clarity by removing a duplicated line.
jyameo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ries (flutter#178398) The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes flutter#178317
…ries (flutter#178398) The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes flutter#178317
…ries (flutter#178398) The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes flutter#178317
…ries (flutter#178398) The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes flutter#178317
…ries (flutter#178398) The `flutter` tool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to a `flutter pub get` downloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context. This change adds additional checks to the `PreviewDetector` that allow for ignoring changes to `pubspec.yaml`s and `.dart` sources under known ephemeral directories (e.g., build/, linux/flutter/ephemeral/, etc), as well as `.dart` files that aren't associated with an analysis context. Fixes flutter#178317
The
fluttertool creates various directories for ephemeral state while executing commands. In some situations, these directories contain or link to other Dart / Flutter projects with '.dart' sources or 'pubspec.yaml's. If these files change while the widget previewer is active (e.g., due to aflutter pub getdownloading and configuring new plugins for the project), the previewer's directory watcher will detect the change and attempt to analyze the source. This causes an exception to be thrown by the analyzer as the modified file path does not have a valid analysis context.This change adds additional checks to the
PreviewDetectorthat allow for ignoring changes topubspec.yamls and.dartsources under known ephemeral directories (e.g., build/,linux/flutter/ephemeral/, etc), as well as
.dartfiles that aren't associated with an analysis context.Fixes #178317