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-922 Original Launch Configuration disappears after creating the new one. #851

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Nov 6, 2023

Description

Looks like launchBarManager.launchObjectRemoved(projectEntry.getKey()); is not necessary to call from launchConfigurationRemoved method. It was added in IEP-442 PR. I've tested the mentioned test cases there and looks fine without these changes, so I removed this override method.
Also, I've made small refactoring by using computeIfAbsence to make other methods more clear

Fixes # (IEP-922)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Test 1:

  • create new workspace -> new project -> when adding new configuration click cancel -> old launch configuration is selected and available in the configuration's lists
    Test 2:
  • other manipulations that affect the launch bar i.e. closing the project, restarting IDE, adding new project, etc.

Test Configuration:

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

Dependent components impacted by this PR:

  • Launch Bar
  • Configuration list

Checklist

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

Summary by CodeRabbit

  • Refactor
    • Simplified the process of initializing and retrieving launch configurations.
  • Chores
    • Removed unused import statements and methods.

Copy link

coderabbitai bot commented Nov 6, 2023

Walkthrough

The IDFCoreLaunchConfigProvider class in the IDF launch serial core bundle has been refactored. The changes include the removal of certain import statements and the launchConfigurationRemoved method, and modifications to the getLaunchConfiguration and launchConfigurationAdded methods to use the computeIfAbsent method for launch configuration initialization and retrieval.

Changes

File Path Change Summary
.../idf/launch/serial/core/IDFCoreLaunchConfigProvider.java Removed import statements for org.eclipse.launchbar.core.ILaunchBarManager and com.espressif.idf.core.IDFCorePlugin. Removed launchConfigurationRemoved method. Modified getLaunchConfiguration and launchConfigurationAdded methods to use computeIfAbsent for launch configuration initialization and retrieval.

Poem

🍂 As the leaves fall, so do old ways,
In the code, a new method plays.
computeIfAbsent now holds the sway,
Making launch configurations stay.

🐇 Hop, hop, hop, goes the CodeRabbit,
Celebrating changes in its habit.
On this day, in history's cabinet,
Marie Curie was born, a true science habit.

🎉 So let's celebrate this day,
With code refactored in a smarter way.
And remember, as we code and play,
To shine like Curie, in our own way. 🌟


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 05ea8a4 and 53320a1.
Files selected for processing (1)
  • bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/core/IDFCoreLaunchConfigProvider.java (5 hunks)

Comment on lines 27 to 35
IProject project = descriptor.getAdapter(IProject.class);
if (project != null)
{
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs == null)
{
projectConfigs = new HashMap<>();
configs.put(project, projectConfigs);
}

String targetConfig = descriptor.getName();
configuration = projectConfigs.get(targetConfig);
configuration = configs.computeIfAbsent(project, key -> new HashMap<>()).get(targetConfig);
if (configuration == null)
{
// do we already have one with the descriptor?
Copy link

Choose a reason for hiding this comment

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

Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [27-42]

The computeIfAbsent method is used to simplify the initialization and retrieval of launch configurations. This is a good use of Java 8's Map API and improves the readability of the code.

Comment on lines 71 to 75
}
if (configuration.exists())
{
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs == null)
{
projectConfigs = new HashMap<>();
configs.put(project, projectConfigs);
}

projectConfigs.put(configuration.getName(), configuration);
configs.computeIfAbsent(project, key -> new HashMap<>()).put(configuration.getName(), configuration);
}
Copy link

Choose a reason for hiding this comment

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

The computeIfAbsent method is used to simplify the initialization and storage of launch configurations. This is a good use of Java 8's Map API and improves the readability of the code.

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi!

Tested under:
OS - Windows 10

LGTM 👍

Copy link
Collaborator Author

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

self reviewed

@kolipakakondal kolipakakondal added this to the v2.12.0 milestone Nov 15, 2023
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.

LGTM

@kolipakakondal kolipakakondal merged commit 4616eea into master Nov 15, 2023
7 checks passed
@kolipakakondal kolipakakondal deleted the IEP-922 branch November 15, 2023 06:35
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.

3 participants