Skip to content

feat(description): тип может быть уточнён ссылкой - #406

Merged
nixel2007 merged 5 commits into
developfrom
feat/type-with-reference
Aug 2, 2026
Merged

nixel2007 merged 5 commits into
developfrom
feat/type-with-reference

Conversation

@nixel2007

Copy link
Copy Markdown
Member

Closes #405

Что было

// Параметры:
//  Объект - СтрокаТабличнойЧасти: См. Справочник.Товары.ЕдиницыИзмерения

Читатель отдавал один параметр с именем Справочник.Товары.ЕдиницыИзмерения, а параметр Объект терялся. Обе половины по отдельности разбирались верно — ломалось именно сочетание: за простым типом грамматика допускала двоеточие, но не ссылку, поэтому правило parameter не срабатывало целиком и строка уходила в запасные альтернативы parameterString.

Что стало

simpleType: typeName=(WORD | DOTSWORD) colon=COLON? (SPACE? reference=hyperlink)?;

Ссылка доезжает до описания отдельным свойством — TypeDescription.reference(), необязательное и пустое у всех прочих типов. Голова описания говорит, чем значение является (строка табличной части, а не сама часть), ссылка — откуда взять его состав; как их сложить, решает потребитель.

Запись предписана методической рекомендацией «Типизация кода» для строки табличной части, с оговоркой, что 1C:EDT её пока не поддерживает.

Проверка

Новый TypeWithReferenceTest: обе половины сохраняются, у типа без ссылки reference() пуст. Полный прогон — 536 тестов, падений нет.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y

Запись «СтрокаТабличнойЧасти: См. Справочник.Товары.ЕдиницыИзмерения» ломала
разбор: после типа с двоеточием грамматика ссылку не допускала, правило
параметра не срабатывало целиком, и строка разбиралась по запасным
альтернативам — имя параметра подменялось ссылкой, а сам параметр терялся.

За простым типом разрешена ссылка, и она доезжает до описания отдельным
свойством: голова говорит, чем значение является, ссылка — откуда взять его
состав. Потребитель решает сам, как их сложить.

Closes #405

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

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: 53 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b72e265a-edcf-41cf-a275-934667b945dd

📥 Commits

Reviewing files that changed from the base of the PR and between f63e48d and 10e2f33.

📒 Files selected for processing (1)
  • src/test/java/com/github/_1c_syntax/bsl/parser/description/reader/TypeWithHyperlinkTest.java

Walkthrough

Изменённая грамматика разбирает ссылку после простого типа. SimpleTypeDescription и TypeDescription сохраняют ссылку. MethodDescriptionReader создаёт Hyperlink и передаёт его в описание типа. Добавлены тесты для вариантов с двоеточием, без двоеточия и без ссылки.

Changes

Ссылка уточнения простого типа

Layer / File(s) Summary
Контракт ссылки в описании типа
src/main/antlr/BSLDescriptionParser.g4, src/main/java/com/github/_1c_syntax/bsl/parser/description/TypeDescription.java, src/main/java/com/github/_1c_syntax/bsl/parser/description/SimpleTypeDescription.java
Грамматика принимает необязательную ссылку. TypeDescription добавляет nullable-метод hyperlink(). SimpleTypeDescription хранит ссылку и поддерживает создание объекта с ней.
Сохранение ссылки при разборе
src/main/java/com/github/_1c_syntax/bsl/parser/description/reader/MethodDescriptionReader.java
Читатель сохраняет токены ссылки и её параметры, создаёт Hyperlink с диапазоном исходного текста и передаёт его в SimpleTypeDescription.
Проверка типов со ссылкой
src/test/java/com/github/_1c_syntax/bsl/parser/description/reader/TypeWithHyperlinkTest.java
Тесты проверяют простое имя типа со ссылкой, ссылку без двоеточия и отсутствие ссылки у обычного типа.

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

Possibly related PRs

  • 1c-syntax/bsl-parser#351 — изменения также затрагивают обработку Hyperlink и диапазонов ссылок в MethodDescriptionReader.

Sequence Diagram(s)

sequenceDiagram
  participant BSLDescriptionParser
  participant MethodDescriptionReader
  participant SimpleTypeDescription
  BSLDescriptionParser->>MethodDescriptionReader: разбирает simpleType и hyperlink
  MethodDescriptionReader->>SimpleTypeDescription: передаёт Hyperlink в create
  SimpleTypeDescription-->>MethodDescriptionReader: возвращает TypeDescription с hyperlink()
Loading

Poem

Я兔ик ссылку в тип принёс,
Парсер разобрал вопрос.
Тип и цель теперь хранятся,
Тесты строго проверяются.
Прыг-скок — двоеточие не теряется!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Разбор ссылки добавлен, но вместо требуемого TypeDescription.reference() реализован аксессор TypeDescription.hyperlink(). Переименовать или дополнить аксессор до TypeDescription.reference() и обновить связанные тесты и вызовы.
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Заголовок точно описывает добавление поддержки уточнения простого типа ссылкой.
Description check ✅ Passed Описание относится к исправлению разбора параметров с простым типом и уточняющей ссылкой.
Out of Scope Changes check ✅ Passed Изменения ограничены грамматикой, моделью описания, чтением ссылок и тестами для указанного сценария.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/type-with-reference

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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/parser/description/reader/TypeWithReferenceTest.java (1)

49-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Добавьте проверку параметров ссылки.

MethodDescriptionReader сохраняет referenceParamsToken, но тест не проверяет это значение. Добавьте пример со ссылкой вида См. Справочник.Товары.ЕдиницыИзмерения(Параметр) и проверьте reference.params().

🤖 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/parser/description/reader/TypeWithReferenceTest.java`
around lines 49 - 71, Расширьте тест typeRefinedByReferenceKeepsBothParts и
входную строку ссылкой с параметром: «См.
Справочник.Товары.ЕдиницыИзмерения(Параметр)». Сохраните проверки имени и типа,
а в проверке type.reference() дополнительно проверьте reference.params() и
убедитесь, что параметр ссылки сохранён как «Параметр».
🤖 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/antlr/BSLDescriptionParser.g4`:
- Line 148: Update the simpleType rule so the optional hyperlink reference is
allowed only when preceded by a colon; require COLON before reference=hyperlink
while preserving simple types without any reference.

---

Nitpick comments:
In
`@src/test/java/com/github/_1c_syntax/bsl/parser/description/reader/TypeWithReferenceTest.java`:
- Around line 49-71: Расширьте тест typeRefinedByReferenceKeepsBothParts и
входную строку ссылкой с параметром: «См.
Справочник.Товары.ЕдиницыИзмерения(Параметр)». Сохраните проверки имени и типа,
а в проверке type.reference() дополнительно проверьте reference.params() и
убедитесь, что параметр ссылки сохранён как «Параметр».
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b096afb0-ac42-45a3-9de1-46d7fa66e020

📥 Commits

Reviewing files that changed from the base of the PR and between 1f8795a and 08b5394.

📒 Files selected for processing (5)
  • src/main/antlr/BSLDescriptionParser.g4
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/SimpleTypeDescription.java
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/TypeDescription.java
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/reader/MethodDescriptionReader.java
  • src/test/java/com/github/_1c_syntax/bsl/parser/description/reader/TypeWithReferenceTest.java

Comment thread src/main/antlr/BSLDescriptionParser.g4 Outdated
nixel2007 and others added 3 commits August 2, 2026 12:03
Без разделителя запись «Тип См. Ссылка» рекомендацией не предусмотрена, а
грамматика принимала её наравне с «Тип: См. Ссылка».

Заодно аннотация обнуляемости приведена к той, что используется в проекте.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y
Отдельного имени для уточняющей ссылки заводить незачем: это та же ссылка, что
и у гиперссылочного типа, поэтому у описания типа один аксессор на оба случая.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y
Параметр помечен обнуляемым, сборка ссылки вынесена из вложенного тернарника,
в тесте нет ни устаревшего сборщика списка, ни утверждения, истинного на пустом
списке.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/parser/description/reader/TypeWithHyperlinkTest.java`:
- Around line 82-85: Усилить проверку в TypeWithHyperlinkTest: явно убедиться,
что types содержит отдельный элемент с Variant.HYPERLINK, а его hyperlink() не
пуст и соответствует ожидаемому значению ссылки. Не полагаться только на
filteredOn(...).allSatisfy(...), поскольку пустой результат не проверяется.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1fde0014-bb73-4912-baa8-a755786515f6

📥 Commits

Reviewing files that changed from the base of the PR and between 08b5394 and f63e48d.

📒 Files selected for processing (5)
  • src/main/antlr/BSLDescriptionParser.g4
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/SimpleTypeDescription.java
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/TypeDescription.java
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/reader/MethodDescriptionReader.java
  • src/test/java/com/github/_1c_syntax/bsl/parser/description/reader/TypeWithHyperlinkTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/antlr/BSLDescriptionParser.g4
  • src/main/java/com/github/_1c_syntax/bsl/parser/description/reader/MethodDescriptionReader.java

Прежняя проверка проходила и на пустом наборе — то есть и в случае, если бы
ссылка потерялась вовсе. Теперь ожидается ровно один гиперссылочный тип со своей
ссылкой, а простые типы остаются без неё.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@nixel2007
nixel2007 merged commit f3b6ef1 into develop Aug 2, 2026
18 checks passed
@nixel2007
nixel2007 deleted the feat/type-with-reference branch August 2, 2026 11:26
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.

Запись «Тип: См. Ссылка» теряет параметр

1 participant