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 2 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 @@ public boolean performFinish()
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,13 @@ private void createDefaultDebugConfig()

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

wizard.performFinish();

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

Choose a reason for hiding this comment

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

We can remove the space before the " Debug" here as this will add the double space considering originalName.substring(0, originalName.lastIndexOf("Configuration")) will still return the project name ends with space after removing "Configuration" from the originalName

wizard.getWorkingCopy().copy(debugConfigName).doSave();
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();
String debugConfigName = originalName.substring(0, originalName.lastIndexOf("Configuration")) + " Debug"; //$NON-NLS-1$ //$NON-NLS-2$
wizard.getWorkingCopy().copy(debugConfigName).doSave();
String originalName = wizard.getWorkingCopy().getName();
if (originalName.contains("Configuration")) {
String debugConfigName = originalName.substring(0, originalName.lastIndexOf("Configuration")) + " Debug"; //$NON-NLS-1$ //$NON-NLS-2$
wizard.getWorkingCopy().copy(debugConfigName).doSave();
} else {
Logger.log("Expected substring 'Configuration' not found in: " + originalName);
}

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.

}
catch (CoreException e)
{
Expand Down
Loading