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

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Jun 21, 2024

Description

Changed the default debug config name and icon.

Fixes # (IEP-1204)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • Create a project -> check the debug configuration

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • Enhancements

    • Updated icon reference for launch configuration in the Eclipse plugin to improve visual consistency.
  • Improvements

    • Enhanced exception handling in project setup wizard for smoother user experience.
    • Added new logic for creating modified debug configurations, facilitating better project debugging setup.

Copy link

coderabbitai bot commented Jun 21, 2024

Walkthrough

The recent changes focus on updating icon references and enhancing exception handling in an Eclipse plugin. Specifically, icon paths for debugging features were revised, and methods handling project creation and configuration have been refined to improve robustness and clarity. These updates help ensure visual consistency and better error management in project setup workflows.

Changes

File Path Change Summary
.../plugin.xml Updated the icon path for the launch configuration type image.
.../NewIDFProjectWizard.java Altered exception handling in the updateClangdFile method and updated logic in createDefaultDebugConfig method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EclipsePlugin as Eclipse Plugin
    participant FileSystem as File System

    User ->> EclipsePlugin: Initiate New Project Wizard
    EclipsePlugin ->> FileSystem: Update clangd file
    FileSystem -->> EclipsePlugin: Clangd file updated (or exception thrown)
    EclipsePlugin ->> EclipsePlugin: Handle any exceptions
    EclipsePlugin ->> EclipsePlugin: Create or update debug configuration
    EclipsePlugin ->> FileSystem: Save new debug configuration
    FileSystem -->> EclipsePlugin: Configuration saved
    EclipsePlugin -->> User: Wizard finishes setup
Loading

Poem

In the heart of code, where bytes do tread,
Icons changed, now debug's fed.
Exceptions handled, neat and bright,
Configs set for the coder's delight.
Here's to progress, both seen and unseen,
In our little realm where code does gleam. 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cf7455e and 7eb6658.

Files selected for processing (2)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java (2 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml

Comment on lines 175 to 177
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();
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

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

LGTM!

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

Tested under:
OS - Windows 10

Can't see icon:
image

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7eb6658 and b60abeb.

Files selected for processing (1)
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml (1 hunks)

@@ -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

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

Able to see icon.
When creating new Debug config - the name remains "Configuration"
image

Do, you think we should change it to make it more uniformly ?

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

Hi @sigmaaa Thanks for the PR. Changes looks great. There are few UX issues. Please check the comments.

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().doSave();
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();
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.

@kolipakakondal
Copy link
Collaborator

@sigmaaa hi !

Able to see icon. When creating new Debug config - the name remains "Configuration" image

Do, you think we should change it to make it more uniformly ?

We can address this as well.

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Jul 5, 2024

@sigmaaa hi !

Able to see icon. When creating new Debug config - the name remains "Configuration" image

Do, you think we should change it to make it more uniformly ?

I haven't found an easy way to change the default name for the additional new debug configuration (when we creating it manually). Dependency classes that we don't have access to correspond to the default configuration name.
Also, from the user's perspective is less important than the default debug configuration, which comes with project creation, since in most cases we need only one debug config for a project.
Second reason: When a user manually creates an additional debug configuration, it means that they understand what the configuration is responding to and they also have an option to rename it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (2)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java (2)

177-178: Remove the space before "Debug".

This will avoid adding double spaces if the original name ends with a space after removing "Configuration".

-  String debugConfigName = originalName.substring(0, originalName.lastIndexOf("Configuration")) + "Debug";
+  String debugConfigName = originalName.substring(0, originalName.lastIndexOf("Configuration")).trim() + "Debug";

179-179: Refresh the project after renaming to avoid sync issues.

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

+  wizard.getWorkingCopy().copy(debugConfigName).doSave();
+  project.refreshLocal(IProject.DEPTH_INFINITE, null);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b60abeb and ce1acd7.

Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java (2 hunks)

Comment on lines +175 to +179
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

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);
}

Comment on lines +144 to +151
private void updateClangdFile(IProject project)
{
try {
try
{
new ClangdConfigFileHandler().update(project);
} catch (Exception e) {
}
catch (Exception e)
{
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)
{

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

LGTM 👍

@kolipakakondal kolipakakondal merged commit c69061c into master Jul 10, 2024
7 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1204 branch July 10, 2024 01:42
@kolipakakondal kolipakakondal added this to the v3.1.0 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants