From a1cd8a948f6d788e0c59fb81f11f1ff4f96facaf Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Tue, 17 Jun 2025 14:07:47 -0400 Subject: [PATCH] Remove workaround for egit not providing path information for show in terminal (#1208) To fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=460277 many years ago some workarounds were added to the terminal to allow adapting git inputs to locations to open a terminal with. Since that workaround was added it is no longer necessary because egit now adapts objects and provides selections in a way that means we don't need it anymore. In particular https://github.com/eclipse-egit/egit/commit/316d0971adb9d9a14ea2a3f31bec41fd1b877d9e adapts inputs to Files that we know how to open with. Fixes https://github.com/eclipse-cdt/cdt/issues/1202 --- releng/CDT.setup | 4 - releng/org.eclipse.cdt.target/cdt.target | 4 - .../META-INF/MANIFEST.MF | 4 +- .../terminal/view/ui/view/TerminalsView.java | 25 ------ .../view/showin/GitShowInContextHandler.java | 87 ------------------- 5 files changed, 1 insertion(+), 123 deletions(-) delete mode 100644 terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/showin/GitShowInContextHandler.java diff --git a/releng/CDT.setup b/releng/CDT.setup index 26532d41b28..3bcfd246b31 100644 --- a/releng/CDT.setup +++ b/releng/CDT.setup @@ -243,8 +243,6 @@ includeBinaryEquivalents="false"> - - - - - - diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF b/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF index 4ec4609f718..55ba5b71838 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF +++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/META-INF/MANIFEST.MF @@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.9.400,4)", org.eclipse.core.resources;bundle-version="[3.22.200,4)";resolution:=optional, org.eclipse.core.variables;bundle-version="[3.6.500,4)", org.eclipse.debug.ui;bundle-version="[3.18.800,4)";resolution:=optional, - org.eclipse.egit.ui;bundle-version="[7.3.0,8)";resolution:=optional, org.eclipse.tm.terminal.view.core;bundle-version="[4.10.0,5.0.0)", org.eclipse.tm.terminal.control;bundle-version="[5.6.0,6.0.0)", org.eclipse.ui;bundle-version="[3.207.200,4)", @@ -40,6 +39,5 @@ Export-Package: org.eclipse.tm.terminal.view.ui.actions, org.eclipse.tm.terminal.view.ui.services, org.eclipse.tm.terminal.view.ui.streams, org.eclipse.tm.terminal.view.ui.tabs, - org.eclipse.tm.terminal.view.ui.view, - org.eclipse.tm.terminal.view.ui.view.showin;x-internal:=true + org.eclipse.tm.terminal.view.ui.view Automatic-Module-Name: org.eclipse.tm.terminal.view.ui diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/TerminalsView.java b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/TerminalsView.java index 99623e40fb6..a1838db6137 100644 --- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/TerminalsView.java +++ b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/TerminalsView.java @@ -60,7 +60,6 @@ import org.eclipse.tm.terminal.view.ui.nls.Messages; import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager; import org.eclipse.tm.terminal.view.ui.tabs.TabFolderMenuHandler; import org.eclipse.tm.terminal.view.ui.tabs.TabFolderToolbarHandler; -import org.eclipse.tm.terminal.view.ui.view.showin.GitShowInContextHandler; import org.eclipse.ui.IMemento; import org.eclipse.ui.ISources; import org.eclipse.ui.IViewSite; @@ -622,21 +621,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa // Get the selection from the context ISelection selection = context.getSelection(); - // If the selection is not set or empty, look at the input element of - // the show in context. - if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) { - Object input = context.getInput(); - // If coming from the EGit repository viewer, the input element is - // org.eclipse.egit.ui.internal.history.HistoryPageInput - if ("org.eclipse.egit.ui.internal.history.HistoryPageInput".equals(input.getClass().getName())) { //$NON-NLS-1$ - Bundle bundle = Platform.getBundle("org.eclipse.egit.ui"); //$NON-NLS-1$ - if (bundle != null && bundle.getState() != Bundle.UNINSTALLED - && bundle.getState() != Bundle.STOPPING) { - selection = GitShowInContextHandler.getSelection(input); - } - } - } - // The selection must contain elements that can be adapted to IResource, File or IPath if (selection instanceof IStructuredSelection && !selection.isEmpty()) { boolean isValid = true; @@ -706,15 +690,6 @@ public class TerminalsView extends ViewPart implements ITerminalsView, IShowInTa continue; } - // The EGit repository view can also set a RepositoryTreeNode (and subclasses) - // "org.eclipse.egit.ui.internal.repository.tree...." - if (element.getClass().getName().startsWith("org.eclipse.egit.ui.internal.repository.tree")) { //$NON-NLS-1$ - bundle = Platform.getBundle("org.eclipse.egit.ui"); //$NON-NLS-1$ - if (bundle != null && bundle.getState() != Bundle.UNINSTALLED - && bundle.getState() != Bundle.STOPPING) { - adapted = GitShowInContextHandler.getPath(element); - } - } if (adapted != null) { if (!elements.contains(adapted)) elements.add(adapted); diff --git a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/showin/GitShowInContextHandler.java b/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/showin/GitShowInContextHandler.java deleted file mode 100644 index 9d453bbe750..00000000000 --- a/terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/view/showin/GitShowInContextHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015, 2018 Wind River Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License 2.0 which accompanies this distribution, and is - * available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.terminal.view.ui.view.showin; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; - -/** - * Git show in context handler implementation. - */ -@SuppressWarnings("restriction") -public class GitShowInContextHandler { - - /** - * Converts the data from the input object into a selection. - * - * @param input The input element. Must not be null. - * @return The selection or null. - */ - public static ISelection getSelection(Object input) { - Assert.isNotNull(input); - - List elements = new ArrayList<>(); - - if (input instanceof org.eclipse.egit.ui.internal.history.HistoryPageInput) { - org.eclipse.egit.ui.internal.history.HistoryPageInput inp = (org.eclipse.egit.ui.internal.history.HistoryPageInput) input; - - if (inp.isSingleFile()) { - elements.add(inp.getSingleFile()); - } else { - File[] fl = inp.getFileList(); - if (fl != null && fl.length > 0) { - for (File f : fl) { - if (f.canRead() && !elements.contains(f)) { - elements.add(f); - } - } - } - - IResource[] rl = inp.getItems(); - if (rl != null && rl.length > 0) { - for (IResource r : rl) { - if (r.isAccessible() && !elements.contains(r)) { - elements.add(r); - } - } - } - } - } - - return elements.isEmpty() ? null : new StructuredSelection(elements); - } - - /** - * Returns the path of the given element. - * - * @param element The element. Must not be null. - * @return The path or null. - */ - public static IPath getPath(Object element) { - Assert.isNotNull(element); - - IPath path = null; - - if (element instanceof org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) { - path = ((org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) element).getPath(); - } - - return path; - } -}