From f4bd3ddc8dec204104c898d20aacbce76ba23243 Mon Sep 17 00:00:00 2001 From: Denys Almazov Date: Fri, 3 Nov 2023 14:49:19 +0200 Subject: [PATCH] fix: comparing launch targets based on idfTatget attr --- .../idf/debug/gdbjtag/openocd/ui/TabDebugger.java | 7 +++++-- .../idf/launch/serial/ui/internal/CMakeMainTab2.java | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java index 77cc24a75..4a3ed0d08 100644 --- a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java @@ -100,6 +100,7 @@ public class TabDebugger extends AbstractLaunchConfigurationTab // ------------------------------------------------------------------------ + private static final String LAUNCH_TARGET_NAME_ATTR = "com.espressif.idf.launch.serial.core.idfTarget"; //$NON-NLS-1$ private static final int JOB_DELAY_MS = 100; private static final String TAB_NAME = "Debugger"; //$NON-NLS-1$ private static final String TAB_ID = Activator.PLUGIN_ID + ".ui.debuggertab"; //$NON-NLS-1$ @@ -274,7 +275,9 @@ protected IStatus run(IProgressMonitor monitor) { ILaunchTargetManager launchTargetManager = Activator.getService(ILaunchTargetManager.class); ILaunchTarget selectedTarget = Stream.of(launchTargetManager.getLaunchTargets()) - .filter(target -> target.getId().contentEquals((targetName))).findFirst() + .filter(target -> target.getAttribute(LAUNCH_TARGET_NAME_ATTR, + StringUtil.EMPTY).equals(targetName)) + .findFirst() .orElseGet(() -> null); launchBarManager.setActiveLaunchTarget(selectedTarget); } @@ -547,7 +550,7 @@ private ILaunchTarget findSuitableTargetForSelectedItem(String selectedItem) for (ILaunchTarget target : targets) { - String idfTarget = target.getAttribute("com.espressif.idf.launch.serial.core.idfTarget", //$NON-NLS-1$ + String idfTarget = target.getAttribute(LAUNCH_TARGET_NAME_ATTR, null); String targetSerialPort = target .getAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT, ""); //$NON-NLS-1$ diff --git a/bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java b/bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java index f0e6eba93..9e420b681 100644 --- a/bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java +++ b/bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java @@ -85,6 +85,7 @@ @SuppressWarnings("restriction") public class CMakeMainTab2 extends GenericMainTab { + private static final String LAUNCH_TARGET_NAME_ATTR = "com.espressif.idf.launch.serial.core.idfTarget"; //$NON-NLS-1$ private static final int JOB_DELAY_MS = 100; private static final String EMPTY_CONFIG_OPTIONS = "%s" + File.separator + "%s -s %s"; //$NON-NLS-1$ //$NON-NLS-2$ private Combo flashOverComboButton; @@ -742,7 +743,7 @@ private ILaunchTarget findSuitableTargetForSelectedItem(String selectedItem) { ILaunchTarget suitableTarget = null; for (ILaunchTarget target : targets) { - String idfTarget = target.getAttribute("com.espressif.idf.launch.serial.core.idfTarget", null); //$NON-NLS-1$ + String idfTarget = target.getAttribute(LAUNCH_TARGET_NAME_ATTR, null); String targetSerialPort = target.getAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT, StringUtil.EMPTY); if (idfTarget.contentEquals(selectedItem)) { @@ -869,9 +870,10 @@ protected IStatus run(IProgressMonitor monitor) { .getAttribute(IDFLaunchConstants.TARGET_FOR_JTAG, StringUtil.EMPTY); if (!targetName.isEmpty()) { ILaunchTargetManager launchTargetManager = Activator.getService(ILaunchTargetManager.class); - ILaunchTarget selectedTarget = Stream.of(launchTargetManager.getLaunchTargets()) - .filter(target -> target.getId().contentEquals((targetName))).findFirst() - .orElseGet(() -> null); + ILaunchTarget selectedTarget = Stream + .of(launchTargetManager.getLaunchTargets()).filter(target -> target + .getAttribute(LAUNCH_TARGET_NAME_ATTR, StringUtil.EMPTY).equals(targetName)) + .findFirst().orElseGet(() -> null); launchBarManager.setActiveLaunchTarget(selectedTarget); }