From ca15b327104071187c0d979f6ad0d33c57869ea6 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Fri, 9 Oct 2026 12:13:30 +0200 Subject: [PATCH] Remove unused ToolConfigurationContextMenuHandler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Configure Tools entry for .agent.md editors is contributed declaratively in plugin.xml, and nothing references this class anymore. Assisted-by: multiple AI agents and layers of automated tooling 🤖 --- .../ToolConfigurationContextMenuHandler.java | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/handlers/ToolConfigurationContextMenuHandler.java diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/handlers/ToolConfigurationContextMenuHandler.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/handlers/ToolConfigurationContextMenuHandler.java deleted file mode 100644 index 1ef1ff15..00000000 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/handlers/ToolConfigurationContextMenuHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -package com.microsoft.copilot.eclipse.ui.handlers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.CompoundContributionItem; -import org.eclipse.ui.menus.CommandContributionItem; -import org.eclipse.ui.menus.CommandContributionItemParameter; -import org.eclipse.ui.texteditor.ITextEditor; - -import com.microsoft.copilot.eclipse.core.CopilotCore; -import com.microsoft.copilot.eclipse.ui.CopilotImages; -import com.microsoft.copilot.eclipse.ui.utils.UiUtils; - -/** - * Context menu contribution handler for .agent.md files. Adds "Configure Tools..." menu item when right-clicking in an - * .agent.md file. - */ -public class ToolConfigurationContextMenuHandler extends CompoundContributionItem { - - @Override - protected IContributionItem[] getContributionItems() { - try { - if (!shouldShowContextMenu()) { - return new IContributionItem[0]; - } - - List items = new ArrayList<>(); - - // Add separator before our menu items - items.add(new Separator("com.microsoft.copilot.eclipse.ui.toolConfig.start")); - - // Create submenu for Copilot tool configuration - MenuManager submenu = new MenuManager("Copilot", - CopilotImages.getImageDescriptor(CopilotImages.IMG_GITHUB_COPILOT), - "com.microsoft.copilot.eclipse.ui.toolConfigMenu"); - - // Add "Configure Tools..." command - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - CommandContributionItemParameter param = new CommandContributionItemParameter(window, null, - "com.microsoft.copilot.eclipse.commands.configureTools", CommandContributionItem.STYLE_PUSH); - param.label = "Configure Tools..."; - param.icon = CopilotImages.getImageDescriptor(CopilotImages.IMG_CHAT_TOOLS); - - submenu.add(new CommandContributionItem(param)); - items.add(submenu); - - // Add separator after our menu items - items.add(new Separator("com.microsoft.copilot.eclipse.ui.toolConfig.end")); - - return items.toArray(IContributionItem[]::new); - - } catch (Exception e) { - CopilotCore.LOGGER.error("Error creating tool configuration context menu", e); - return new IContributionItem[0]; - } - } - - /** - * Check if the context menu should be shown. Returns true if we're in an .agent.md file. - */ - private boolean shouldShowContextMenu() { - try { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - return false; - } - - IEditorPart activeEditor = window.getActivePage().getActiveEditor(); - if (!(activeEditor instanceof ITextEditor)) { - return false; - } - - ITextEditor textEditor = (ITextEditor) activeEditor; - - // Check if it's an .agent.md file - IFile file = textEditor.getEditorInput().getAdapter(IFile.class); - return file != null && UiUtils.isAgentFile(file); - - } catch (Exception e) { - CopilotCore.LOGGER.error("Error checking if context menu should be shown", e); - return false; - } - } -} \ No newline at end of file