Skip to content

Commit 5669571

Browse files
authored
fix: comparing launch targets based on idfTatget attr (#850)
1 parent afc222d commit 5669571

File tree

2 files changed

+11
-6
lines changed
  • bundles
    • com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui
    • com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal

2 files changed

+11
-6
lines changed

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/TabDebugger.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public class TabDebugger extends AbstractLaunchConfigurationTab
100100

101101
// ------------------------------------------------------------------------
102102

103+
private static final String LAUNCH_TARGET_NAME_ATTR = "com.espressif.idf.launch.serial.core.idfTarget"; //$NON-NLS-1$
103104
private static final int JOB_DELAY_MS = 100;
104105
private static final String TAB_NAME = "Debugger"; //$NON-NLS-1$
105106
private static final String TAB_ID = Activator.PLUGIN_ID + ".ui.debuggertab"; //$NON-NLS-1$
@@ -274,7 +275,9 @@ protected IStatus run(IProgressMonitor monitor)
274275
{
275276
ILaunchTargetManager launchTargetManager = Activator.getService(ILaunchTargetManager.class);
276277
ILaunchTarget selectedTarget = Stream.of(launchTargetManager.getLaunchTargets())
277-
.filter(target -> target.getId().contentEquals((targetName))).findFirst()
278+
.filter(target -> target.getAttribute(LAUNCH_TARGET_NAME_ATTR,
279+
StringUtil.EMPTY).equals(targetName))
280+
.findFirst()
278281
.orElseGet(() -> null);
279282
launchBarManager.setActiveLaunchTarget(selectedTarget);
280283
}
@@ -547,7 +550,7 @@ private ILaunchTarget findSuitableTargetForSelectedItem(String selectedItem)
547550

548551
for (ILaunchTarget target : targets)
549552
{
550-
String idfTarget = target.getAttribute("com.espressif.idf.launch.serial.core.idfTarget", //$NON-NLS-1$
553+
String idfTarget = target.getAttribute(LAUNCH_TARGET_NAME_ATTR,
551554
null);
552555
String targetSerialPort = target
553556
.getAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT, ""); //$NON-NLS-1$

bundles/com.espressif.idf.launch.serial.ui/src/com/espressif/idf/launch/serial/ui/internal/CMakeMainTab2.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585

8686
@SuppressWarnings("restriction")
8787
public class CMakeMainTab2 extends GenericMainTab {
88+
private static final String LAUNCH_TARGET_NAME_ATTR = "com.espressif.idf.launch.serial.core.idfTarget"; //$NON-NLS-1$
8889
private static final int JOB_DELAY_MS = 100;
8990
private static final String EMPTY_CONFIG_OPTIONS = "%s" + File.separator + "%s -s %s"; //$NON-NLS-1$ //$NON-NLS-2$
9091
private Combo flashOverComboButton;
@@ -742,7 +743,7 @@ private ILaunchTarget findSuitableTargetForSelectedItem(String selectedItem) {
742743
ILaunchTarget suitableTarget = null;
743744

744745
for (ILaunchTarget target : targets) {
745-
String idfTarget = target.getAttribute("com.espressif.idf.launch.serial.core.idfTarget", null); //$NON-NLS-1$
746+
String idfTarget = target.getAttribute(LAUNCH_TARGET_NAME_ATTR, null);
746747
String targetSerialPort = target.getAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT,
747748
StringUtil.EMPTY);
748749
if (idfTarget.contentEquals(selectedItem)) {
@@ -869,9 +870,10 @@ protected IStatus run(IProgressMonitor monitor) {
869870
.getAttribute(IDFLaunchConstants.TARGET_FOR_JTAG, StringUtil.EMPTY);
870871
if (!targetName.isEmpty()) {
871872
ILaunchTargetManager launchTargetManager = Activator.getService(ILaunchTargetManager.class);
872-
ILaunchTarget selectedTarget = Stream.of(launchTargetManager.getLaunchTargets())
873-
.filter(target -> target.getId().contentEquals((targetName))).findFirst()
874-
.orElseGet(() -> null);
873+
ILaunchTarget selectedTarget = Stream
874+
.of(launchTargetManager.getLaunchTargets()).filter(target -> target
875+
.getAttribute(LAUNCH_TARGET_NAME_ATTR, StringUtil.EMPTY).equals(targetName))
876+
.findFirst().orElseGet(() -> null);
875877
launchBarManager.setActiveLaunchTarget(selectedTarget);
876878
}
877879

0 commit comments

Comments
 (0)