Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Copy link
Collaborator Author

@sigmaaa sigmaaa Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to write this attribute like this. Maybe we can use a single class in the core package to store all attributes there

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use IDFLaunchConstants.ATTR_IDF_TARGET

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$
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
}

Expand Down