Skip to content

feat(code-lens): учитывать client resolveSupport для CodeLens (LSP 3.18) - #4385

Merged
nixel2007 merged 7 commits into
1c-syntax:developfrom
BaniBaushev:feat/code-lens-resolve-support
Aug 23, 2026
Merged

nixel2007 merged 7 commits into
1c-syntax:developfrom
BaniBaushev:feat/code-lens-resolve-support

Conversation

@BaniBaushev

@BaniBaushev BaniBaushev commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Описание

По LSP 3.18 клиент может заявить поддержку отложенного резолва линз через textDocument.codeLens.resolveSupport.properties. Если клиент не перечислил там свойство command, полагаться на codeLens/resolve нельзя — команды нужно отдавать сразу.

Теперь CodeLensProvider.getCodeLens проверяет клиентские capabilities:

  • клиент заявил resolveSupport со свойством command — линзы возвращаются неразрешёнными, команда заполняется через codeLens/resolve (прежнее поведение);
  • клиент не заявил resolveSupport (в том числе клиенты без поддержки LSP 3.18 и вообще без capabilities) — каждая линза разрешается сразу, на месте, через тот же resolveCodeLens; поле data при этом очищается, как и при обычном резолве.

Связанные issue

Closes #4155

Summary by CodeRabbit

  • New Features
    • Improved CodeLens compatibility across editor clients.
    • Clients supporting deferred CodeLens resolution receive lenses that resolve on demand.
    • Clients without resolution support now receive fully populated CodeLens commands immediately.
    • Workspace CodeLens refreshes now respect the client’s supported capabilities.
    • Added support for clients with varied CodeLens resolution capability configurations.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@BaniBaushev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bd0a6b59-3b9f-4af3-a37f-99bed105cd13

📥 Commits

Reviewing files that changed from the base of the PR and between 870f69d and 10a465c.

📒 Files selected for processing (2)
  • docs/en/index.md
  • docs/index.md
📝 Walkthrough

Walkthrough

CodeLensProvider caches client capabilities during initialization. It defers command resolution for supported clients and resolves commands eagerly for unsupported clients. Workspace refresh uses the cached capability. Tests cover both paths.

Changes

CodeLens resolve support

Layer / File(s) Summary
Capability-aware CodeLens resolution
src/main/java/.../providers/CodeLensProvider.java
The provider caches CodeLens resolve and workspace refresh support. It returns unresolved lenses when command resolution is supported and eagerly resolves commands otherwise.
Resolution path test coverage
src/test/java/.../providers/CodeLensProviderTest.java
Tests configure different resolve capabilities and verify eager command resolution when command resolution is unavailable.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: nixel2007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the CodeLens resolveSupport change and matches the pull request objectives.
Linked Issues check ✅ Passed The implementation and tests cover capability detection, conditional eager resolution, data clearing, and both supported and unsupported client paths [#4155].
Out of Scope Changes check ✅ Passed The changes are limited to CodeLens capability handling and related tests, with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java`:
- Around line 152-168: Update
testGetCodeLensResolvesCommandsEagerly_ifClientDoesNotSupportCodeLensResolve to
explicitly configure ClientCapabilitiesHolder with CodeLens resolve support
absent before invoking getCodeLens. Add a resolveSupport.properties case
containing a different property but not "command", and retain assertions that
commands are eagerly populated and data is null.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a5eaef11-57ee-421c-9569-0790211dae6a

📥 Commits

Reviewing files that changed from the base of the PR and between d5c24f9 and 9f99590.

📒 Files selected for processing (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java

.flatMap(Collection::stream)
.collect(Collectors.toList());

if (!clientResolvesCommands()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

разве код-ленз сапплаеры этим уже не занимаются? если нет, то ок. хотя я не уверен, что у нас вообще есть сейчас хоть один сапплаер, который команду собирает на резолве, а не при создании линзы, но это надо проверить.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Проверил: нет, сапплаеры этим не занимаются. Все шесть (Cognitive/Cyclomatic complexity, BeanUsages, InjectionPoint, RunAll/RunTest, DebugTest) создают линзы неразрешёнными — при создании заполняется только data, а setCommand() вызывается исключительно в resolve(). Двухфазный контракт прямо описан в javadoc CodeLensSupplier («разрешение линзы (создание объекта CodeLens#setCommand) должно проводиться в два этапа»). Поэтому eager-резолв возможен только здесь, в провайдере, — иначе клиент без resolveSupport получит линзы вообще без команд.

* {@code false}, если клиент не заявил {@code resolveSupport} (в том числе
* не поддерживает LSP 3.18) — тогда команду нужно отдать сразу.
*/
private boolean clientResolvesCommands() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

это надо закэшировать в поле объекта, подписавшись на событие initialized, как делают другие провайдеры (например, completion provider). остальные capability такого рода в этом провайдере тоже можно перенести в кэш в рамках этого PR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java`:
- Around line 121-123: Update the CodeLens capability documentation in
docs/index.md and docs/en/index.md to describe the client-dependent response
mode: clients advertising textDocument.codeLens.resolveSupport.properties with
"command" receive lenses without commands, while other clients receive eagerly
resolved commands. Keep the existing codeLens and codeLens/resolve entries
consistent in both documents.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a503947-1545-4ca6-9163-9b192568f37b

📥 Commits

Reviewing files that changed from the base of the PR and between 9f99590 and 38713c3.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java

@nixel2007
nixel2007 merged commit 42ebea5 into 1c-syntax:develop Aug 23, 2026
23 checks passed
@nixel2007

Copy link
Copy Markdown
Member

Спасибо!

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.

feat(code-lens): учитывать client resolveSupport для CodeLens (LSP 3.18)

2 participants