Close a project when its .project file is deleted - #2895
Conversation
8d66678 to
9923ce5
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core project lifecycle, persistence, refresh, and partial-move recovery behavior requiring final human validation.
Pull request overview
Closes open Eclipse workspace projects when their .project file disappears, preventing saves from recreating deleted metadata.
Changes:
- Detects
.projectdeletion during resource deletion and refresh, then closes the project. - Stops save/close operations from recreating missing descriptions.
- Preserves partially moved project content and updates affected tests.
File summaries
| File | Description |
|---|---|
Snapshot2Test.java |
Retains .project during snapshot setup. |
TestBug12575.java |
Updates cross-session deletion expectations. |
IWorkspaceTest.java |
Verifies saves do not recreate .project. |
ISynchronizerTest.java |
Retains project descriptions during synchronization testing. |
IProjectTest.java |
Tests explicit description rewriting. |
IProjectDescriptionTest.java |
Covers deletion, refresh, close, reopen, and failed moves. |
LocalSyncTest.java |
Expects refresh to close deleted projects. |
SaveManager.java |
Removes automatic project-description repair during saves. |
ResourceTree.java |
Avoids source refresh after partial project moves. |
Resource.java |
Closes projects after workspace .project deletion. |
Project.java |
Extracts reusable internal project-closing logic. |
File.java |
Centralizes .project identification. |
RefreshLocalVisitor.java |
Tracks projects whose descriptions disappeared. |
FileSystemResourceManager.java |
Closes tracked projects after refresh. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
9923ce5 to
bb8ca9d
Compare
|
@iloveeclipse To your question: The code was done without bug reference AFAICS. John Arthorne on 2002-03-16 in commit f64fa15 ("Moved project description file to content area"), the Eclipse 2.0 change that moved .project out of .metadata into the project folder |
1a6e3bb to
4156699
Compare
|
Any additional concerns @iloveeclipse? |
|
Planning to merge later today. |
eaa7c2f to
bef4791
Compare
ca4b587 to
ed480e5
Compare
When the project description file disappeared, the workspace kept the project open with the in-memory description, logged a refresh error and silently wrote the description back to disk at the next snapshot or on close. Switching to a git branch that no longer contains a project thus left a dirty working tree with a recreated .project file. A refresh that finds the description file deleted, and deleting the file through the workspace, now close the project instead. Closing a project and saving the workspace no longer recreate a missing description file. Opening the project again works once the file is back, as for a project with a missing description on startup. A refresh of the project closes it before visiting any member: deleting a member with linked resources or filters writes the description back to disk, and a refresh canceled after the description file left the workspace tree would otherwise leave the project open with nothing left to rediscover the deletion. Removing linked resources or filters of a project whose description file is gone no longer writes the file back either, which also covers a nested project refreshed through its parent. Deleting the description file closes the project even when the operation is canceled afterwards, also for a nested project deleted through its parent, since the update of the aliases of a deleted resource can no longer be skipped by a cancellation. A project move whose content could only be moved partially now refreshes the destination after the tree has been moved, instead of the source before. The tree always ends up under the destination name, so the source refresh described the destination with the leftovers of the source: files already deleted there were dropped from the tree with their markers even though they exist at the destination, and with this change the source refresh would also have closed the project because its description file is gone. The destination refresh keeps the moved resources and their markers and trims what was never copied. Fixes eclipse-platform#1074 Assisted-by: multiple AI agents and layers of automated tooling 🤖
ed480e5 to
3e0806b
Compare
|
After a failed or partial content move the project is refreshed at the destination once the tree has been moved, so the refresh still happens when the exception has nothing to do with .project. testMoveWithUndeletableSourceContent covers it. |
|
FWIW, I think what's implemented here collides somehow with what I consider as more desirable in #202 . The current change makes that a project cannot be open at all without a .project, while the 2nd asks that any folder could be configured as an open project without a .project necessarily. |
Once or if someone starts working on #202 we are revisit. IMHO the concept of .project is deeply embedded into Eclipse and will be hard to be removed. But I also would like to see this change. |
When the
.projectfile disappears, for example after switching to a git branch that no longer contains the project, the workspace kept the project open and silently wrote the description back to disk at the next snapshot, save or close, leaving a dirty working tree (#1074).A refresh that finds
.projectdeleted, and deleting the file through the workspace, now close the project instead, and closing or saving no longer recreates a missing description file. The project can be reopened once the file is back, just like a project with a missing description on startup. A project refresh closes the project before visiting any member, since deleting a member with linked resources or filters writes the description back to disk, and a refresh canceled after the description file left the workspace tree would otherwise leave the project open with nothing left to rediscover the deletion.A project move whose content could only be moved partially now refreshes the destination after the tree has been moved, instead of refreshing the source before. The tree always ends up under the destination name, so the old source refresh described the destination with the leftovers of the source and dropped moved files and their markers; it would now also close the project because its
.projectis gone. The destination refresh keeps the moved resources with their markers and trims whatever was never copied.Code that deletes every member of a project including
.projectand keeps using it now sees a closed project; five tests in this repository were adjusted accordingly. The fullorg.eclipse.core.tests.resourcessuite passes locally.Fixes #1074