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-1277 Create .clang_format #1022

Merged
merged 5 commits into from
Aug 2, 2024
Merged

IEP-1277 Create .clang_format #1022

merged 5 commits into from
Aug 2, 2024

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Jul 19, 2024

Description

Creating the .clang-format file with the default settings with a new project. Also, if .clang-format file is missing, it's adding automatically after the build

Fixes # (IEP-1277)

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 new project -> check .clang-format file
  • Delete .clang-format file -> build the project -> check .clang-format file

Test Configuration:

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

Dependent components impacted by this PR:

  • Formatting

Checklist

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

Summary by CodeRabbit

  • New Features

    • Introduced a new constant for Clang format file management, enhancing configuration options.
    • Added a new handler for .clang-format file to streamline formatting setup in projects.
    • Improved project setup wizard to accommodate both Clang configurations and formatting files.
  • Bug Fixes

    • Minor formatting cleanup in the LSP service implementation to enhance code readability.

Copy link

coderabbitai bot commented Jul 19, 2024

Warning

Rate limit exceeded

@sigmaaa has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 19 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between ef51793 and 46a6356.

Walkthrough

This update enhances Clang file management within the project framework. It introduces a new constant, CLANG_FORMAT_FILE, and the ClangFormatFileHandler class for effective handling of the .clang-format file. The project wizard has been modified to update multiple Clang-related files, improving the project setup process. Collectively, these changes enhance usability and ensure consistent code formatting across projects.

Changes

File Summary
ILSPConstants.java Added new constant CLANG_FORMAT_FILE for Clang format configuration management.
IDFBuildConfiguration.java, ClangFormatFileHandler.java Introduced ClangFormatFileHandler import; updated build method to include formatting capabilities and manage the .clang-format file.
LspService.java Removed an extraneous blank line in updateLspQueryDrivers method for cleaner code.
NewIDFProjectWizard.java Renamed updateClangdFile to updateClangFiles, enhancing functionality to handle multiple Clang configurations during project setup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Wizard as NewIDFProjectWizard
    participant ConfigHandler as ClangFormatFileHandler
    participant Build as IDFBuildConfiguration

    User->>Wizard: Create new project
    Wizard->>ConfigHandler: Update Clang files
    ConfigHandler-->>Wizard: Ensure .clang-format exists
    Wizard->>Build: Trigger build process
    Build->>ConfigHandler: Call update for formatting
    Build-->>User: Complete project setup
Loading

🐰 In the fields where code does play,
A new format comes into sway.
With handlers to keep styles in line,
Our projects will surely shine!
Hopping through code, so neat and bright,
Formatting's now a delight! 🌼


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 Configuration 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 43dbad9 and 8df0e5a.

Files selected for processing (5)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/ILSPConstants.java (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java (2 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/LspService.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java (3 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/LspService.java
Additional comments not posted (10)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/ILSPConstants.java (1)

14-14: Add a new constant for .clang-format file.

The new constant CLANG_FORMAT_FILE is consistent with the existing constants and follows the same pattern.

bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java (5)

29-32: Constructor initializes fields correctly.

The constructor correctly initializes the project and clangFormatPath fields.


40-50: Method update handles file creation and updating correctly.

The method correctly handles the creation and updating of the .clang-format file with default settings.


52-57: Method createYamlOptions sets YAML formatting options correctly.

The method correctly sets the DumperOptions for YAML formatting.


59-63: Method writeYamlFile writes data to the file correctly.

The method correctly writes the provided data to the .clang-format file using YAML format.


73-86: Method createNewClangFormatFile handles file creation and existence check correctly.

The method correctly ensures the .clang-format file exists and creates it if it does not, with appropriate error handling and project refresh.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java (2)

114-114: Call to updateClangFiles is correct.

The method now correctly calls updateClangFiles instead of updateClangdFile.


145-150: Method updateClangFiles correctly handles updating Clangd and Clang format files.

The method now correctly includes the ClangFormatFileHandler to update the .clang-format file, with appropriate error handling.

bundles/com.espressif.idf.core/src/com/espressif/idf/core/build/IDFBuildConfiguration.java (2)

88-88: Import statement for ClangFormatFileHandler looks good.

The import statement is correctly added and necessary for the new functionality.


343-343: Integration of ClangFormatFileHandler in the build process looks good.

The new instance and method call are correctly placed to enhance the build process. Ensure that the update method handles errors gracefully.

@AndriiFilippov
Copy link
Collaborator

AndriiFilippov commented Jul 22, 2024

@sigmaaa hi !

Tested under:
OS - Windows 10
ESP-IDF: v5.2

Creating the .clang-format file with the default settings with a new project. ✔️
Also, if .clang-format file is missing, it's adding automatically after the build. ✔️

.clangd-format file works. do see content:

BasedOnStyle: LLVM
IndentWidth: 4

added ColumnLimit: 10 - build project - open .c file:

image

LGTM 👍

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8df0e5a and e75349b.

Files selected for processing (2)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/.clang-format-project (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java (1 hunks)
Files skipped from review due to trivial changes (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/.clang-format-project
Additional comments not posted (3)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java (3)

1-15: LGTM!

The class definition and imports look good.


16-22: LGTM!

The constructor correctly initializes the clangFormatFile field.


23-39: LGTM!

The update method correctly handles the creation of the .clang-format file and includes proper exception handling.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e75349b and ef51793.

Files selected for processing (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java

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 0066004 into master Aug 2, 2024
5 of 6 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1277 branch August 2, 2024 08: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.

3 participants