Skip to content

Close a project when its .project file is deleted - #2895

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:close-project-without-description
Sep 22, 2026
Merged

vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:close-project-without-description

Conversation

@vogella

@vogella vogella commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

When the .project file 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 .project deleted, 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 .project is 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 .project and keeps using it now sees a closed project; five tests in this repository were adjusted accordingly. The full org.eclipse.core.tests.resources suite passes locally.

Fixes #1074

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  +  3      54 suites  +3   57m 29s ⏱️ + 2m 31s
 4 823 tests + 12   4 801 ✅ + 13   22 💤 ±0  0 ❌  - 1 
12 360 runs  +297  12 207 ✅ +298  153 💤 ±0  0 ❌  - 1 

Results for commit 3e0806b. ± Comparison against base commit 6e4cd9b.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the close-project-without-description branch 2 times, most recently from 8d66678 to 9923ce5 Compare September 3, 2026 07:56
@vogella
vogella requested a balanced review from Copilot September 3, 2026 08:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 .project deletion 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.

@vogella
vogella force-pushed the close-project-without-description branch from 9923ce5 to bb8ca9d Compare September 3, 2026 23:17
@vogella

vogella commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@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

@vogella
vogella force-pushed the close-project-without-description branch 3 times, most recently from 1a6e3bb to 4156699 Compare September 9, 2026 11:23
@vogella

vogella commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Any additional concerns @iloveeclipse?

@vogella

vogella commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Planning to merge later today.

@vogella
vogella force-pushed the close-project-without-description branch 2 times, most recently from eaa7c2f to bef4791 Compare September 14, 2026 16:42
@vogella
vogella force-pushed the close-project-without-description branch 2 times, most recently from ca4b587 to ed480e5 Compare September 21, 2026 19:20
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 🤖
@vogella
vogella force-pushed the close-project-without-description branch from ed480e5 to 3e0806b Compare September 21, 2026 19:31
@vogella

vogella commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

@vogella
vogella merged commit a4cbd84 into eclipse-platform:master Sep 22, 2026
18 checks passed
@mickaelistria

Copy link
Copy Markdown
Contributor

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.

@vogella
vogella deleted the close-project-without-description branch September 23, 2026 06:59
@vogella

vogella commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete the project file should ask to remove the project from workspace

4 participants