Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-1204 Change the default name for the debug configuration #1000

Merged
merged 3 commits into from
Jul 10, 2024
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
2 changes: 1 addition & 1 deletion bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage
configTypeID="com.espressif.idf.debug.gdbjtag.openocd.launchConfigurationType"
icon="icons/obj16/ESP-IDF GDB OpenOCD Debugging.png"
icon="platform:/plugin/org.eclipse.debug.ui/icons/full/eview16/debug_persp.png"
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Icon file does not exist

The icon file debug_persp.png specified in the path "platform:/plugin/org.eclipse.debug.ui/icons/full/eview16/debug_persp.png" does not exist in the repository. Please verify the path or ensure that the file is added to the repository.

  • File: bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml
  • Line: 42
Analysis chain

Verify the visibility of the new icon.

The icon path has been updated to "platform:/plugin/org.eclipse.debug.ui/icons/full/eview16/debug_persp.png". However, there is a user comment indicating that the icon is not visible. Please verify the visibility of the new icon and ensure the path is correct.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the visibility of the new icon.

# Test: Check if the icon file exists in the specified path.
icon_path="platform:/plugin/org.eclipse.debug.ui/icons/full/eview16/debug_persp.png"
if [ -f "$icon_path" ]; then
  echo "Icon file exists."
else
  echo "Icon file does not exist."
fi

Length of output: 231



Script:

#!/bin/bash
# Description: Search for the debug_persp.png file within the org.eclipse.debug.ui plugin directory.

# Locate the directory containing the org.eclipse.debug.ui plugin
plugin_dir=$(fd -t d -g "org.eclipse.debug.ui")

# Search for the debug_persp.png file within the located plugin directory
if [ -n "$plugin_dir" ]; then
  fd "debug_persp.png" "$plugin_dir"
else
  echo "org.eclipse.debug.ui plugin directory not found."
fi

Length of output: 171



Script:

#!/bin/bash
# Description: Search for the debug_persp.png file in the entire repository.

# Search for the debug_persp.png file in the entire repository
fd "debug_persp.png"

Length of output: 20

id="com.espressif.idf.debug.gdbjtag.openocd.launchConfigurationTypeImage" />
</extension>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@
return performFinish;
}

private void updateClangdFile(IProject project)
private void updateClangdFile(IProject project)
{
try {
try
{
new ClangdConfigFileHandler().update(project);
} catch (Exception e) {
}
catch (Exception e)
{
Comment on lines +144 to +151
Copy link

Choose a reason for hiding this comment

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

Refine exception handling in updateClangdFile method.

Currently, the method catches a generic Exception which might not be the best practice as it can mask other unexpected issues. Consider catching more specific exceptions related to the operations being performed.

-  catch (Exception e)
+  catch (IOException | CoreException e)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void updateClangdFile(IProject project)
{
try {
try
{
new ClangdConfigFileHandler().update(project);
} catch (Exception e) {
}
catch (Exception e)
{
private void updateClangdFile(IProject project)
{
try
{
new ClangdConfigFileHandler().update(project);
}
catch (IOException | CoreException e)
{

Logger.log(e);
}
}
Expand All @@ -165,12 +168,15 @@

PageChangingEvent pageChangingEvent = new PageChangingEvent(wizard, wizard.getStartingPage(), editPage);
editPage.handlePageChanging(pageChangingEvent);

wizard.performFinish();

try
{
wizard.getWorkingCopy().doSave();
String originalName = wizard.getWorkingCopy().getName();
int configPartIndex = originalName.lastIndexOf("Configuration"); //$NON-NLS-1$
String debugConfigName = configPartIndex != -1 ? originalName.substring(0, configPartIndex) + "Debug" //$NON-NLS-1$
: originalName;
wizard.getWorkingCopy().copy(debugConfigName).doSave();
Copy link
Collaborator

Choose a reason for hiding this comment

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

After rename, you might need to refresh the project to avoid sync issues with file system project state.

Here is the case:

  1. Create a project
  2. Delete a project
  3. Choose to delete all configurations in the popup window
  4. Still you will see "project Debug" configurations in the configuration drop-down

Copy link
Collaborator

Choose a reason for hiding this comment

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

do not see this issue during test.

Comment on lines +175 to +179
Copy link

Choose a reason for hiding this comment

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

Improve reliability of debug configuration name creation.

The method assumes the presence of the substring "Configuration" in the original name. This could lead to errors if "Configuration" is not part of the original name. Adding a check before performing the substring operation would enhance the robustness of this method.

-  String debugConfigName = originalName.substring(0, originalName.lastIndexOf("Configuration")) + "Debug";
+  if (originalName.contains("Configuration")) {
+      String debugConfigName = originalName.substring(0, originalName.lastIndexOf("Configuration")) + "Debug";
+      wizard.getWorkingCopy().copy(debugConfigName).doSave();
+  } else {
+      Logger.log("Expected substring 'Configuration' not found in: " + originalName);
+  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String originalName = wizard.getWorkingCopy().getName();
int configPartIndex = originalName.lastIndexOf("Configuration"); //$NON-NLS-1$
String debugConfigName = configPartIndex != -1 ? originalName.substring(0, configPartIndex) + "Debug" //$NON-NLS-1$
: originalName;
wizard.getWorkingCopy().copy(debugConfigName).doSave();
String originalName = wizard.getWorkingCopy().getName();
int configPartIndex = originalName.lastIndexOf("Configuration"); //$NON-NLS-1$
if (originalName.contains("Configuration")) {
String debugConfigName = originalName.substring(0, configPartIndex) + "Debug"; //$NON-NLS-1$
wizard.getWorkingCopy().copy(debugConfigName).doSave();
} else {
Logger.log("Expected substring 'Configuration' not found in: " + originalName);
}

}
catch (CoreException e)
{
Expand All @@ -192,7 +198,7 @@
}

IDFProjectGenerator generator = new IDFProjectGenerator(manifest, selectedTemplate, true,
projectCreationWizardPage.getSelectedTarget());

Check warning on line 201 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java

View workflow job for this annotation

GitHub Actions / spotbugs

NP_NULL_ON_SOME_PATH

Possible null pointer dereference of NewIDFProjectWizard.projectCreationWizardPage in com.espressif.idf.ui.wizard.NewIDFProjectWizard.getGenerator()
Raw output
There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception cannot ever be executed; deciding that is beyond the ability of SpotBugs.
generator.setProjectName(projectCreationWizardPage.getProjectName());
if (!projectCreationWizardPage.useDefaults())
{
Expand All @@ -207,73 +213,73 @@
private String target;

public TargetSwitchJob(String target)
{
super(TARGET_SWITCH_JOB);
this.target = target;
launchBarManager = UIPlugin.getService(ILaunchBarManager.class);
}

private Job findInternalJob()
{
for (Job job : Job.getJobManager().find(null))
{
if (job.getName().equals(InternalDebugCoreMessages.CoreBuildLaunchBarTracker_Job))
{
return job;
}
}

return null;
}

@Override
protected IStatus run(IProgressMonitor monitor)
{
Job job = findInternalJob();
if (job != null)
{
try
{
job.join();
}
catch (InterruptedException e1)
{
Logger.log(e1);
}
}

Display.getDefault().syncExec(() -> {
ILaunchTarget launchTarget = findSuitableTargetForSelectedTargetString();
try
{
launchBarManager.setActiveLaunchTarget(launchTarget);
}
catch (CoreException e)
{
Logger.log(e);
}
});

return Status.OK_STATUS;

}

private ILaunchTarget findSuitableTargetForSelectedTargetString()
{
ILaunchTargetManager launchTargetManager = UIPlugin.getService(ILaunchTargetManager.class);
ILaunchTarget[] targets = launchTargetManager
.getLaunchTargetsOfType(IDFLaunchConstants.ESP_LAUNCH_TARGET_TYPE);

for (ILaunchTarget iLaunchTarget : targets)
{
String idfTarget = iLaunchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, null);
if (idfTarget.contentEquals(target))
{
return iLaunchTarget;
}
}

return null;

Check warning on line 282 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java

View workflow job for this annotation

GitHub Actions / spotbugs

SIC_INNER_SHOULD_BE_STATIC

Should com.espressif.idf.ui.wizard.NewIDFProjectWizard$TargetSwitchJob be a _static_ inner class?
Raw output
This class is an inner class, but does not use its embedded reference to the object which created it.  This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.  If possible, the class should be made static.
}
}
}
Loading