feat(completion): паритет completion item — пользовательские методы и конструкторы как платформенные#4129
Conversation
Локальные (source-defined) процедуры/функции в no-dot completion показывали только имя, тогда как платформенные (Сообщить и пр.) — сигнатуру «(Пар1, Пар2?)», тип возврата и документацию. Теперь пользовательские методы выглядят так же: сигнатура строится из MethodSymbol.getParameters() (необязательные помечаются «?»), тип возврата — из doc-comment'а (Возвращаемое значение:), документация — из назначения метода (+ причина устаревания). Используются те же applyDetail/setDocumentation, что и для платформенных методов, поэтому раскладка по labelDetails/detail идентична. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
📝 WalkthroughWalkthrough
ChangesLocal method completion: detail and documentation enrichment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProviderTest.java (1)
251-293: ⚡ Quick winAdd a local-method test for the
labelDetailsSupport=truebranch.Line 287 currently asserts only flat
detail. Since the new local-method path now routes throughapplyDetail, add a companion assertion/test whereenableLabelDetailsSupport(true)is enabled and verifylabelDetails.detail/descriptionare populated whiledetailis null.As per coding guidelines, “Always run tests before submitting changes and maintain or improve test coverage using appropriate test frameworks (JUnit, AssertJ, Mockito)”.
🤖 Prompt for 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. In `@src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProviderTest.java` around lines 251 - 293, Add a new test method similar to noDotCompletionLocalMethodHasSignatureAndDocumentationLikePlatform that tests the labelDetailsSupport enabled path. Enable labelDetailsSupport to true before calling completionProvider.getCompletion, then assert that the completion item's labelDetails field (specifically labelDetails.detail and labelDetails.description) contains the expected signature and documentation, while the flat detail field is null. This ensures the local method completion properly populates structured label details when support is enabled.Source: Coding guidelines
🤖 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.
Nitpick comments:
In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProviderTest.java`:
- Around line 251-293: Add a new test method similar to
noDotCompletionLocalMethodHasSignatureAndDocumentationLikePlatform that tests
the labelDetailsSupport enabled path. Enable labelDetailsSupport to true before
calling completionProvider.getCompletion, then assert that the completion item's
labelDetails field (specifically labelDetails.detail and
labelDetails.description) contains the expected signature and documentation,
while the flat detail field is null. This ensures the local method completion
properly populates structured label details when support is enabled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 70bd5ac9-12d3-4531-8d63-f37cd695d197
📒 Files selected for processing (2)
src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProvider.javasrc/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProviderTest.java
Регрессионный тест: dot-completion метода общего модуля (source-defined) показывает сигнатуру, тип возврата и документацию так же, как платформенные методы (ОбщегоНазначения.ЗначениеВМассиве → «(Значение): Массив» + описание). Эта ветка (member через MemberDescriptor/buildMemberItem) уже была богатой — тест фиксирует паритет, чтобы он не сломался. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Конструкторы после `Новый` форматировали сигнатуру вручную: без пометки «?» у необязательных параметров, показывали параметры только первой перегрузки и писали detail напрямую (минуя labelDetails). Теперь — теми же applyDetail/formatParameterList/formatSignaturesCount, что и методы: «(Пар?)», «N вариантов» при нескольких перегрузках и раскладка в labelDetails при поддержке клиентом. Тип возврата не показываем — результат конструктора это сам класс, он уже дублируется label'ом. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|



Цель
Сделать completion item'ы пользовательских/source-defined символов визуально идентичными платформенным (сигнатура, тип возврата, документация, раскладка labelDetails).
Что сделано
1. Локальные методы текущего модуля (no-dot completion).
Раньше показывали только имя. Теперь — сигнатура
(Пар1, Пар2?)изMethodSymbol.getParameters(), тип возврата из doc-comment'а (Возвращаемое значение:) и документация (назначение + причина устаревания), через те жеapplyDetail/setDocumentation, что и платформенные методы.2. Конструкторы после
Новый.Сигнатура форматировалась вручную: без
?у необязательных параметров, только параметры первой перегрузки,detailнапрямую (минуя labelDetails). Теперь — теми жеapplyDetail/formatParameterList/formatSignaturesCount, что и методы:(Пар?),N вариантовпри нескольких перегрузках, labelDetails при поддержке клиентом. Тип возврата не показываем (результат конструктора — сам класс, дублирует label).Аудит остальных веток
Перебрал все места создания
CompletionItem. Ветки, порождающие методы, теперь все богатые:MemberDescriptor/buildMemberItem) — были богатыми, добавлен тест-страж.Бедными осознанно остаются не-методы: локальные переменные (в BSL не типизированы — нужен вывод типов, отдельная задача), ключевые слова, имена типов/неймспейсов.
Тесты
noDotCompletionLocalMethodHasSignatureAndDocumentationLikePlatform— локальный метод:(Имя, Приветствие?): Строка+ документация (red→green).dotCompletionCommonModuleMethodHasSignatureAndDocumentationLikePlatform— метод общего модуля:(Значение): Массив+ документация (страж паритета).newCompletionConstructorSignatureMatchesPlatformMethodFormat—(КоличествоЭлементов?)(red→green).newCompletionConstructorOverloadsShownAsCountLikePlatformMethod— несколько перегрузок → счётчик вариантов (red→green).newCompletionConstructorUsesLabelDetailsWhenClientSupportsThem— labelDetails при поддержке клиентом (red→green).Весь
CompletionProviderTestзелёный.🤖 Generated with Claude Code