Refresh resources before sync check in DeleteResourcesProcessor#4046
Conversation
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
Test Results 855 files 855 suites 49m 15s ⏱️ Results for commit 158eebd. ♻️ This comment has been updated with latest results. |
3aa88d0 to
a53009a
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the LTK delete-resources refactoring to honor the workspace “Refresh on access” (lightweight auto-refresh) preference when performing out-of-sync checks, aligning its behavior with other resource refactorings and reducing unnecessary out-of-sync warnings when resources were modified outside Eclipse.
Changes:
- In
DeleteResourcesProcessor, when the sync check fails and lightweight auto-refresh is enabled, refresh the resource and re-check synchronization; if refresh reveals the resource was deleted externally, drop it from the deletion set. - Add regression tests covering: warning when auto-refresh is disabled, successful delete without warnings when enabled, and externally deleted resources being handled gracefully.
- Bump
org.eclipse.ltk.core.refactoringbundle version.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringTests.java | Adds tests for delete refactoring behavior with/without lightweight auto-refresh and for external deletion. |
| bundles/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/DeleteResourcesProcessor.java | Implements refresh-and-recheck flow for out-of-sync resources and removes externally deleted resources from the delete set. |
| bundles/org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF | Increments bundle version for the change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When the workspace "Refresh on access" preference (Preferences > General > Workspace > "Refresh on access", backed by ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH) is enabled, the Delete Resources refactoring wizard reports "is not in sync with" warnings even though the user explicitly opted into refresh on access. Note that this preference is enabled by default. DeleteResourcesProcessor now follows the same pattern as RenameResourceProcessor: if the sync check fails and the preference is enabled, the resource is refreshed and the check is repeated. Resources that are already in sync are not refreshed. If the refresh reveals that a resource was deleted externally, the resource is dropped from the set to delete instead of failing later in DeleteResourceChange with "resource does not exist". The refresh runs under a child progress monitor so it stays cancelable, and a failed refresh degrades to the existing out-of-sync warning rather than aborting the condition check. Fixes eclipse-platform#3982
a53009a to
158eebd
Compare
The Delete Resources refactoring wizard reported "is not in sync with" warnings for files that were changed outside Eclipse, even though the "Refresh on access" workspace preference promises a lazy refresh and is enabled by default. The sync check used
IResource.isSynchronized, which only compares timestamps and never triggers that refresh.DeleteResourcesProcessornow follows the same pattern asRenameResourceProcessor: when the preference (PREF_LIGHTWEIGHT_AUTO_REFRESH) is enabled and the sync check fails, the resource is refreshed and the check is repeated, so resources that are already in sync pay no refresh cost. If the refresh reveals that a resource was deleted externally, it is dropped from the deletion set instead of failing later with "resource does not exist". The refresh stays cancelable via a child progress monitor, and a failed refresh degrades to the existing out-of-sync warning.New tests cover the warning with the preference disabled, the refresh with it enabled, and the externally deleted case.
Fixes #3982