From 35ad8d33017989bb579f7ee4583a5dcf5ec3a900 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Mon, 6 Apr 2026 12:36:33 +0200 Subject: [PATCH 1/2] Defer expensive project reference computation during selection changes CloseUnrelatedProjectsAction.getSelectedResources() calls computeRelated() which triggers buildConnectedComponents() and getReferencedProjects() for every project in the workspace. This is expensive because it can trigger classpath container resolution. Previously, the inherited updateSelection() called getSelectedResources() on every selection change, causing this expensive computation to run on the UI thread during startup and navigation. This blocked the IDE. Override updateSelection() to perform only a cheap enablement check: verify the selection contains at least one open IProject. The expensive computeRelated() call is deferred to getSelectedResources(), which is only invoked when the action is actually executed via run(). This is correct because getSelectedResources() already handles the selectionDirty flag and recomputes projectsToClose lazily when needed. Fixes https://github.com/eclipse-platform/eclipse.platform.ui/issues/2636 --- .../actions/CloseUnrelatedProjectsAction.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java index 2e0901417b56..08ab770d744a 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java @@ -30,6 +30,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.IShellProvider; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Shell; @@ -130,6 +131,25 @@ public CloseUnrelatedProjectsAction(IShellProvider provider){ initAction(); } + /** + * Overrides to avoid calling the expensive + * {@link #computeRelated(List)} during selection changes. Uses only + * the raw selection to determine enablement. + */ + @Override + protected boolean updateSelection(IStructuredSelection s) { + selectionDirty = true; + if (!selectionIsOfType(IResource.PROJECT)) { + return false; + } + for (IResource resource : super.getSelectedResources()) { + if (resource instanceof IProject project && project.isOpen()) { + return true; + } + } + return false; + } + @Override public void run() { if (promptForConfirmation()) { From 8c4d499c8d86a9f56b572ba35eaad569019c0210 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Tue, 7 Apr 2026 17:14:55 +0200 Subject: [PATCH 2/2] Fix Javadoc warning: use @code instead of @link for private method Replace {@link #computeRelated(List)} with {@code computeRelated(List)} since computeRelated is private and not visible at the protected visibility level of updateSelection(). --- .../org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java index 08ab770d744a..54eebcb244b0 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java @@ -133,7 +133,7 @@ public CloseUnrelatedProjectsAction(IShellProvider provider){ /** * Overrides to avoid calling the expensive - * {@link #computeRelated(List)} during selection changes. Uses only + * {@code computeRelated(List)} during selection changes. Uses only * the raw selection to determine enablement. */ @Override