Repository navigation
feat(code-lens): учитывать client resolveSupport для CodeLens (LSP 3.18) - #4385
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCodeLensProvider 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. ChangesCodeLens resolve support
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.javasrc/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java
| .flatMap(Collection::stream) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| if (!clientResolvesCommands()) { |
There was a problem hiding this comment.
разве код-ленз сапплаеры этим уже не занимаются? если нет, то ок. хотя я не уверен, что у нас вообще есть сейчас хоть один сапплаер, который команду собирает на резолве, а не при создании линзы, но это надо проверить.
There was a problem hiding this comment.
Проверил: нет, сапплаеры этим не занимаются. Все шесть (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() { |
There was a problem hiding this comment.
это надо закэшировать в поле объекта, подписавшись на событие initialized, как делают другие провайдеры (например, completion provider). остальные capability такого рода в этом провайдере тоже можно перенести в кэш в рамках этого PR
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java
|
Спасибо! |
Описание
По 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