Skip to content

Conversation

@sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Feb 11, 2025

Description

Replaced the Eclipse LSP CDT restart server utility call with the corresponding class from LSP4E to avoid errors during updating LSP CDT plugin to the master.

Fixes # (IEP-1419)

Type of change

Please delete options that are not relevant.

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

How has this been tested?

Verify that the Language Server works the same way as before.

  • Create New Project -> Build -> no errors in the editor
  • Switch projects -> build -> no errors in the editor
  • Change target -> No -> no errors in the editor

Test Configuration:

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

Dependent components impacted by this PR:

  • Language Server

Checklist

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

Summary by CodeRabbit

  • Chores
    • Updated dependency configuration to support advanced language server capabilities.
  • Refactor
    • Enhanced the integration and processing of language server interactions for improved performance and reliability.

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2025

Walkthrough

This pull request updates two components. The first change modifies the manifest file for the bundle by adding the org.eclipse.lsp4j dependency and reordering the existing org.eclipse.lsp4e entry. The second change updates the language server wrapper handling in a Java class by converting its storage from a Stream to a List and adjusting initialization to use a new accessor method.

Changes

File(s) Change Summary
bundles/com.espressif.idf.core/META-INF/MANIFEST.MF Added dependency org.eclipse.lsp4j in the Require-Bundle section; adjusted the ordering of org.eclipse.lsp4e within the same section.
bundles/.../LspService.java Updated field and constructor signature from Stream<LanguageServerWrapper> to List<LanguageServerWrapper>; changed initialization to call LanguageServiceAccessor.getStartedWrappers(null, true) and process the result accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Configuration
    participant Lsp as LspService
    participant Accessor as LanguageServiceAccessor

    Config ->> Lsp: Instantiate LspService with configuration and wrappers
    Lsp ->> Accessor: getStartedWrappers(null, true)
    Accessor -->> Lsp: Returns stream of LanguageServerWrapper
    Lsp ->> Lsp: Filter wrappers and convert stream to List
Loading

Suggested reviewers

  • kolipakakondal
  • AndriiFilippov
  • alirana01

Poem

I'm a rabbit with a hop and a skip,
In code changes, I joyfully flip.
Dependencies set in neat array,
Language servers now list their play.
Celebrate this tweak with a twitch of my ear—
Happy coding, and a hoppy cheer!
🐇🎉

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

🧹 Nitpick comments (1)
bundles/com.espressif.idf.core/META-INF/MANIFEST.MF (1)

34-35: Consider adding version constraints for LSP dependencies.

To prevent potential compatibility issues, consider adding version constraints for both LSP4E and LSP4J dependencies. This ensures that compatible versions are used and helps prevent breaking changes from future updates.

Example:

- org.eclipse.lsp4e,
- org.eclipse.lsp4j
+ org.eclipse.lsp4e;bundle-version="[0.13.0,1.0.0)",
+ org.eclipse.lsp4j;bundle-version="[0.12.0,1.0.0)"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e60d439 and 93cbd90.

📒 Files selected for processing (2)
  • bundles/com.espressif.idf.core/META-INF/MANIFEST.MF (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/LspService.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build_macos
🔇 Additional comments (5)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/LspService.java (4)

7-7: LGTM!

The added imports are necessary for the updated implementation.

Also applies to: 14-14


23-23: LGTM! Good improvement.

Changing from Stream to List is a better choice as:

  1. Lists are reusable, while Streams can only be consumed once
  2. The collection is used in restartLspServers() which needs to iterate over the wrappers

27-29: LGTM! Successfully migrated to LSP4E.

The changes successfully:

  1. Replace the Eclipse LSP CDT utility with LSP4E's LanguageServiceAccessor
  2. Maintain the filter for CDT language servers
  3. Update the constructor parameter to match the field type change

Also applies to: 32-32


25-30: Add unit tests for the LSP changes.

Given that this change affects core LSP functionality:

  1. Add unit tests to verify the initialization of language server wrappers
  2. Add tests to ensure only CDT language servers are selected
  3. Verify the restart functionality with the new implementation
bundles/com.espressif.idf.core/META-INF/MANIFEST.MF (1)

34-35: LGTM! The dependencies align with the PR objectives.

The addition of org.eclipse.lsp4j and reordering of org.eclipse.lsp4e support the migration from CDT LSP internal dependencies to LSP4E functionality. This change helps prevent potential errors during LSP CDT plugin updates.

However, let's verify the version compatibility of these dependencies.

❌ Verification inconclusive

🏁 Script executed:

#!/bin/bash
# Description: Check the version compatibility between LSP4E and LSP4J

# Get the target platform configuration
fd -t f "target.platform" -x cat {} \; | grep -E "org.eclipse.lsp4[ej]"

# Check if there are any version constraints in other manifest files
fd -t f "MANIFEST.MF" -x grep -l "org.eclipse.lsp4[ej]" {} \; | xargs cat | grep -E "org.eclipse.lsp4[ej].*;bundle-version"

Length of output: 201


I'll run an additional shell script to search all MANIFEST.MF files for "Require-Bundle:" lines as well as any explicit version constraints (using a semicolon after the dependency name) for the LSP dependencies.


🏁 Script executed:

#!/bin/bash
echo "Searching for Require-Bundle lines with LSP dependencies:"
fd -t f "MANIFEST.MF" -x grep -H "Require-Bundle:" {} \;

echo ""
echo "Searching for version constraints for org.eclipse.lsp4e or org.eclipse.lsp4j (if any):"
fd -t f "MANIFEST.MF" -x grep -H "org.eclipse.lsp4[ej];" {} \;

Length of output: 2313


Version Compatibility Requires Manual Verification

Our automated searches did not reveal any explicit version constraints (e.g. using the “;bundle-version” syntax) for the org.eclipse.lsp4e and org.eclipse.lsp4j dependencies in the manifest files. This absence suggests that version resolution for these bundles is likely managed by the overall target platform or OSGi framework rather than being hard-coded here.

Given the importance of ensuring that the correct versions are in use, please manually verify that the versions provided by the target platform meet the compatibility requirements for the LSP4E functionality introduced by this PR.

@kolipakakondal
Copy link
Collaborator

Hi @sigmaaa LGTM. Which version of CDT-LSP plugin required for this?

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Feb 12, 2025

Hi @sigmaaa LGTM. Which version of CDT-LSP plugin required for this?

Hi @kolipakakondal. We are using the API of the LSP CDT 2.0 version

/**
 * @since 2.0
 */
public interface Configuration

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !

Tested under:
OS - Windows 11 / Mac OS

Autocompletion ✅
Function definition path ✅
no new unresolved values found after build completed ✅
LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants