Skip to content

Conversation

@Kakueeen
Copy link
Contributor

@Kakueeen Kakueeen commented Jun 11, 2025

  • Updated the LSP client to include a validity check for the client before performing actions.
  • Added a new method isValid() to the Client class to return the validity status.
  • Modified the selectLspServer method to check if the client is valid before proceeding.
  • Updated the context menu actions in LanguageClientHandler to enable or disable based on the client's validity.
  • Introduced a new member variable isClientValid in ClientPrivate to track the client's state.

Log: This change improves the robustness of the LSP client interactions by ensuring actions are only available when the client is in a valid state.
Bug: https://pms.uniontech.com/bug-view-319109.html

Summary by Sourcery

Enhance LSP client robustness by tracking and exposing a validity state, conditionally initializing servers, and disabling related UI actions when the client is invalid

Enhancements:

  • Track client validity in ClientPrivate with a new isClientValid flag
  • Expose validity state via a new Client::isValid() method
  • Mark the client as valid upon processing any server response result
  • Skip redundant server selection and initialization in selectLspServer when client is already valid
  • Only invoke initRequest in LSPClientManager if the client is invalid
  • Disable language server–dependent context menu actions when the client is not valid

- Updated the LSP client to include a validity check for the client before performing actions.
- Added a new method `isValid()` to the `Client` class to return the validity status.
- Modified the `selectLspServer` method to check if the client is valid before proceeding.
- Updated the context menu actions in `LanguageClientHandler` to enable or disable based on the client's validity.
- Introduced a new member variable `isClientValid` in `ClientPrivate` to track the client's state.

Log: This change improves the robustness of the LSP client interactions by ensuring actions are only available when the client is in a valid state.
Bug: https://pms.uniontech.com/bug-view-319109.html
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepin-mozart, Kakueeen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot deepin-ci-robot merged commit 8534046 into linuxdeepin:master Jun 11, 2025
10 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Kakueeen - I've reviewed your changes - here's some feedback:

  • Currently you set isClientValid on any JSON result—consider limiting it to initResult so the client isn’t marked valid prematurely.
  • Add logic to reset isClientValid in error/shutdown handlers (e.g. calledError or exitResult) to avoid stale valid states after failures.
  • The UI code repeats act->setEnabled(isClientValid) for each menu action—consider centralizing or looping over the relevant actions to reduce duplication.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants