Skip to content

fix(completion): сохранять типы полей элемента Соответствия в автокомплите#4208

Merged
nixel2007 merged 3 commits into
developfrom
claude/collection-autocomplete-bug-1zsoxe
Jul 1, 2026
Merged

fix(completion): сохранять типы полей элемента Соответствия в автокомплите#4208
nixel2007 merged 3 commits into
developfrom
claude/collection-autocomplete-bug-1zsoxe

Conversation

@nixel2007

@nixel2007 nixel2007 commented Jun 25, 2026

Copy link
Copy Markdown
Member

При автодополнении по элементу Соответствие из КлючИЗначение (переменная
цикла Для Каждого Элемент Из ...) у предложений Ключ/Значение пропадали
типы из JsDoc (Строка/Число) и описания.

Причина: в dotCompletion сначала добавлялись члены типа из реестра
(платформенные КлючИЗначение.Ключ/.Значение — без типа), а затем
декларированные поля через putIfAbsent, который оставлял уже добавленный
бестиповый платформенный член. Комментарий в коде декларировал обратный
приоритет, но порядок обработки ему противоречил.

Теперь поля «открытого» объекта данных обрабатываются ПЕРЕД членами типа,
поэтому задокументированное поле приоритетнее одноимённого дефолтного члена.
Поле кладётся полным TypeSet (как в DereferenceMemberMatcher), а не только
головным ref.

Closes #4206

Co-Authored-By: Claude Opus 4.8 [email protected]
Claude-Session: https://claude.ai/code/session_017JsLkTx1s33wvzgFZn2FgV

Summary by CodeRabbit

  • Bug Fixes
    • Improved code completion so local fields retain full type hints, making completion details more accurate.
    • Ensured declared local entries appear before platform members when both are available.
    • Enhanced map/loop element completion to preserve expected key/value type hints and descriptions.
  • Tests
    • Added automated coverage for map element completion to verify labels, type details, and localized documentation.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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

Run ID: 3aa7fa4a-56e7-4847-8246-7e3a3bb1c866

📥 Commits

Reviewing files that changed from the base of the PR and between 8378dbb and 36fbcc9.

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

Walkthrough

CompletionProvider now preserves full local-field type information when building dot completions. A new test class verifies that map element completions expose typed details and documentation for Ключ and Значение.

Changes

Map element completion typing

Layer / File(s) Summary
Declared local field completions
src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProvider.java
Declared local fields are inserted before platform members, and their completion descriptors use the full TypeSet with an UNKNOWN fallback.
Map element completion tests
src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/MapElementCompletionTest.java
A new test class loads a document with an Элемент. marker, requests completions, and checks typed detail and documentation for Ключ and Значение.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preserving map element field types in completion.
Linked Issues check ✅ Passed The code now prioritizes declared fields and preserves the full TypeSet, which matches the requested completion fix for Ключ and Значение.
Out of Scope Changes check ✅ Passed The changes are limited to the completion fix and a targeted regression test, with no obvious unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/collection-autocomplete-bug-1zsoxe

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/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProvider.java`:
- Around line 447-472: The per-ref interleaving in CompletionProvider’s type
collection can still let an untyped platform member win over a documented field
when typeSet has multiple refs. Update the logic in CompletionProvider to do a
two-pass merge: first iterate all refs and add local/documented fields from
getLocalFields() to members, then iterate all refs again to add platform members
from typeService.getMembers(). Keep using the existing symbols members,
localFieldNames, owners, and MemberDescriptor.property so documented fields
always take precedence regardless of ref order.
🪄 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

Run ID: 5fa60033-92bb-4937-b2a4-275082136323

📥 Commits

Reviewing files that changed from the base of the PR and between 287be25 and 53d2569.

⛔ Files ignored due to path filters (1)
  • src/test/resources/types/MapElementCompletion.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CompletionProvider.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/MapElementCompletionTest.java

@nixel2007

Copy link
Copy Markdown
Member Author

/buildJar

@github-actions

Copy link
Copy Markdown
Contributor

✅ Собраны JAR-файлы для этого PR по команде /buildJar.

Артефакт: 7890250715

Файлы внутри:

  • bsl-language-server-claude-collection-autocomplete-bug-1zsoxe-19c20f2-exec.jar

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Test Results

 3 582 files   3 582 suites   1h 44m 27s ⏱️
 3 535 tests  3 517 ✅  18 💤 0 ❌
21 210 runs  21 098 ✅ 112 💤 0 ❌

Results for commit 36fbcc9.

♻️ This comment has been updated with latest results.

claude added 2 commits July 1, 2026 06:40
…плите

При автодополнении по элементу `Соответствие из КлючИЗначение` (переменная
цикла `Для Каждого Элемент Из ...`) у предложений `Ключ`/`Значение` пропадали
типы из JsDoc (`Строка`/`Число`) и описания.

Причина: в `dotCompletion` сначала добавлялись члены типа из реестра
(платформенные `КлючИЗначение.Ключ`/`.Значение` — без типа), а затем
декларированные поля через `putIfAbsent`, который оставлял уже добавленный
бестиповый платформенный член. Комментарий в коде декларировал обратный
приоритет, но порядок обработки ему противоречил.

Теперь поля «открытого» объекта данных обрабатываются ПЕРЕД членами типа,
поэтому задокументированное поле приоритетнее одноимённого дефолтного члена.
Поле кладётся полным `TypeSet` (как в `DereferenceMemberMatcher`), а не только
головным ref.

Closes #4206

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_017JsLkTx1s33wvzgFZn2FgV
…union

По замечанию CodeRabbit: при чередовании поле/член внутри одного цикла по ref'ам
у union-ресивера бестиповый платформенный член одного ref мог быть добавлен
раньше одноимённого задокументированного поля другого ref и затенить его через
putIfAbsent. Теперь сначала собираются все декларированные поля по всем ref'ам,
затем все члены типов — задокументированное поле приоритетнее независимо от
порядка обхода.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_017JsLkTx1s33wvzgFZn2FgV
@nixel2007
nixel2007 force-pushed the claude/collection-autocomplete-bug-1zsoxe branch from 19c20f2 to 8378dbb Compare July 1, 2026 06:40
По замечанию SonarCloud: сложность dotCompletion выросла до 12 (> 10, java:S1541),
а два прохода по typeSet.refs() ловились как S3047 («объедините циклы»). Оба
прохода вынесены в методы collectDeclaredFields и collectTypeMembers —
цикломатическая сложность dotCompletion снижена, а разнесение по методам
сохраняет двухпроходный порядок (поле приоритетнее одноимённого члена), который
объединять в один цикл нельзя.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_017JsLkTx1s33wvzgFZn2FgV
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@nixel2007
nixel2007 merged commit 95516cf into develop Jul 1, 2026
37 checks passed
@nixel2007
nixel2007 deleted the claude/collection-autocomplete-bug-1zsoxe branch July 1, 2026 16:52
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.

[BUG] Проблемы в подсказках для переменной типа Соответствие из КлючИЗначение

2 participants