eclipse.platform icon indicating copy to clipboard operation
eclipse.platform copied to clipboard

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

Open laeubi opened this issue 1 year ago • 9 comments

Currently if I remove a git repository I getting asked if I want to remove the associated projects from the workspace.

If I delete a .project file (e.g. from git staging view or on the filesystem or Project/Package Explorer) it can happen that eclipse create an (empty) one again or complains that the file is missing.

I therefore think that deleting the .project file should trigger a similar action like when one deletes the project itself (e.g. select it in the project explorer and choose delete).

laeubi avatar Jan 04 '24 14:01 laeubi

I also suffer sometimes similar: When someone else deleted a project in the git repository the .project file is recreated and shown in git staging area.

jukzi avatar Jan 05 '24 16:01 jukzi

I also suffer sometimes similar: When someone else deleted a project in the git repository the .project file is recreated and shown in git staging area.

Guess how I found out :-D

laeubi avatar Jan 05 '24 16:01 laeubi

Yes it’s kind of annoying. Better the project is closed than to recreate a .project file.

merks avatar Jan 05 '24 19:01 merks

If I delete a .project file (e.g. from git staging view or on the filesystem or Project/Package Explorer) it can happen that eclipse create an (empty) one again or complains that the file is missing.

I'm curious about that. Did you manage to get steps to reproduce and a stack trace about what re-creates the .project ? Note that this topic has relations with https://github.com/eclipse-platform/eclipse.platform/issues/202

I agree with @merks that closing the project without notice is probably best, so people can delete or try to reopen it when needed, without popup to interrupt them on a branch switch.

mickaelistria avatar Jan 08 '24 08:01 mickaelistria

Just use any eclipse-platform repo:

  1. create a new branch (DELETE_TEST) and delete a project, commit everything
  2. switch to the main branch and import the just deleted project
  3. Now right click on the repo and choose team switch > DELETE_TEST

You will end up with a closed project and a dirty working tree, eclipse probably also complains that the important project info was deleted and instead it created a dummy. Now you can switch back and probably now get complains from git that your need to commit or revert your "changes".

I think the main problem is that a closed project is even needing a physical .project file.

From users POV I would want if project file is removed (ResourceChangeListener?) the project either removed from the workspace completely or a closed project does not create a dummy file.

laeubi avatar Jan 08 '24 09:01 laeubi

The same of course can happen if you pull a change from someone else that deleted a project, by the way it would be really great if Egit could "plug in" somehow in eclipse to "help" with managing the projects, that's really a bit frustrating when switching between branches that have added/deleted projects, for example it would of course be nice if I switch to the other branch I'm getting asked if I wanted the just delted / closed project to be imported/added back ...

laeubi avatar Jan 08 '24 09:01 laeubi

it would be really great if Egit could "plug in" somehow in eclipse to "help" with managing the projects

*sigh* it does that. grafik

Bananeweizen avatar Jan 09 '24 19:01 Bananeweizen

it does that.

Than it obviously not work ... or does something different. I have defiantly enabled this option on my Tycho workspace but it never has made anything better nor I noticed anything similar on other projects where I regularly switch branches...

Also I never seen I got asked if a new project approaches when pulling a branch...

laeubi avatar Jan 10 '24 07:01 laeubi

Just a recent example if one want to try it out, here I have deleted a now obsolete project, pulling the p2 repo in my IDE after the change was merged results in:

grafik

the stacktrace in the error log is this:

org.eclipse.core.internal.resources.ResourceException: Errors occurred while refreshing resources with the local file system.
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.refreshResource(FileSystemResourceManager.java:1024)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.refresh(FileSystemResourceManager.java:1004)
	at org.eclipse.core.internal.resources.Resource.refreshLocal(Resource.java:1601)
	at org.eclipse.core.internal.refresh.RefreshJob.runInWorkspace(RefreshJob.java:227)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Contains: The project description file (.project) for 'org.eclipse.equinox.p2.tests.reconciler.product' is missing.  This file contains important information about the project.  The project will not function properly until this file is restored.
java.lang.Exception: The project description file (.project) for 'org.eclipse.equinox.p2.tests.reconciler.product' is missing.  This file contains important information about the project.  The project will not function properly until this file is restored.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:951)
	at org.eclipse.core.internal.resources.Project.updateDescription(Project.java:1420)
	at org.eclipse.core.internal.resources.File.updateMetadataFiles(File.java:402)
	at org.eclipse.core.internal.localstore.RefreshLocalVisitor.visit(RefreshLocalVisitor.java:306)
	at org.eclipse.core.internal.localstore.UnifiedTree.accept(UnifiedTree.java:119)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.refreshResource(FileSystemResourceManager.java:1021)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.refresh(FileSystemResourceManager.java:1004)
	at org.eclipse.core.internal.resources.Resource.refreshLocal(Resource.java:1601)
	at org.eclipse.core.internal.refresh.RefreshJob.runInWorkspace(RefreshJob.java:227)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

I now have a dirty working tree with an empty project file created:

grafik

and the project remains in the workspace: grafik

Git tracking of projects is enabled grafik

Now if I switch to an older branch, the project is restored, if I then switch again back to the master branch the project ends up in a closed project and no error occurs.

Now try to open the project results again in an ugly error dialog

grafik

And this exception

java.lang.Exception: The project description file (.project) for 'org.eclipse.equinox.p2.tests.reconciler.product' is missing.  This file contains important information about the project.  The project will not function properly until this file is restored.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:951)
	at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:953)
	at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:828)
	at org.eclipse.core.internal.resources.Project.open(Project.java:1100)
	at org.eclipse.ui.actions.OpenResourceAction$1.doOpenWithReferences(OpenResourceAction.java:233)
	at org.eclipse.ui.actions.OpenResourceAction$1.runInWorkspace(OpenResourceAction.java:279)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

In this case no project file is created and the project remains closed, while from a user perspective it would be much more reasonable to either create one (because I wanted to open the project) or at least ask to do so, alternatively just create something "in memory" and have some way for the user to make it permanent (e.g. open a dirty editor the user can save).

laeubi avatar Feb 12 '24 05:02 laeubi