Skip to content

feat(types): ссылка «См.» разбирает путь в нотации конфигуратора - #4374

Merged
nixel2007 merged 3 commits into
developfrom
feat/types-metadata-see-refs
Aug 2, 2026
Merged

feat(types): ссылка «См.» разбирает путь в нотации конфигуратора#4374
nixel2007 merged 3 commits into
developfrom
feat/types-metadata-see-refs

Conversation

@nixel2007

@nixel2007 nixel2007 commented Aug 2, 2026

Copy link
Copy Markdown
Member

Первый шаг по семейству ссылок См. из полигона #4345 — пункты 3.22, 3.24 и 3.25 рекомендации.

Что было

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

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

Что стало

Путь в нотации конфигуратора собирается в имя типа: реестр складывает имена из того же вида объекта метаданных, что стоит в начале ссылки, поэтому Справочник.Справочник1.ТабличнаяЧасть1 превращается в СправочникТабличнаяЧасть.Справочник1.ТабличнаяЧасть1, который уже зарегистрирован вместе со строкой и её колонками.

Разбираются:

  • <Вид>.<Объект>.<ТабличнаяЧасть> — сама табличная часть;
  • <Вид>.<Объект>.<ТабличнаяЧасть>.<Реквизит> — тип реквизита табличной части;
  • <Вид>.<Объект>.<Реквизит> — тип реквизита объекта.

Заодно объявленному типу-коллекции проставляется тип её элемента: Для Каждого по параметру, чей тип объявлен комментарием, иначе не знает, что перебирает.

Проверка

Новый MetadataSeeRefInferenceTest: тип табличной части по ссылке, колонка её строки при обходе Для Каждого, тип реквизита табличной части. Прогнаны types, hover, completion.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MnWpDdNSEFohPZHG6voe6y

Summary by CodeRabbit

  • Bug Fixes
    • Improved type recognition for qualified metadata references, including catalogs, object properties, tabular sections, and tabular-section row properties.
    • Enhanced inferred types for declared collections by identifying their default element types.
    • Preserved correct handling of unassigned variables as Неопределено.
    • Unsupported, ambiguous, or invalid metadata paths now resolve safely without producing incorrect type information.
    • Improved type inference for composite attributes when continuation paths cannot be resolved.

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

Разбираются табличная часть объекта, её реквизит и реквизит самого объекта.

Заодно объявленному типу-коллекции проставляется тип её элемента: «Для Каждого»
по параметру, чей тип объявлен комментарием, иначе не знает, что перебирает.

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
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 50f28089-4e0a-465d-9cf9-916101f7ad74

📥 Commits

Reviewing files that changed from the base of the PR and between be61622 and bf49d54.

⛔ Files ignored due to path filters (1)
  • src/test/resources/types/MetadataSeeRef.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/index/SymbolTypeIndex.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/index/SymbolTypeIndex.java

📝 Walkthrough

Walkthrough

The change adds metadata-path resolution for qualified См. references, including object properties, tabular sections, and row properties. Declared collection types receive default element types. Integration tests verify resolved types and unsupported paths.

Changes

Metadata type inference

Layer / File(s) Summary
Metadata path resolution and type enrichment
src/main/java/com/github/_1c_syntax/bsl/languageserver/types/index/SymbolTypeIndex.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java
SymbolTypeIndex resolves qualified metadata paths through TypeRegistry. ExpressionTypeInferencer attaches default element types to declared collections and proceeds with CFG path analysis.
Metadata inference integration coverage
src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java
Tests verify object attributes, tabular sections, row properties, helper-based type extraction, and unsupported paths.

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

Sequence Diagram(s)

sequenceDiagram
  participant ExpressionTypeInferencer
  participant SymbolTypeIndex
  participant TypeRegistry
  ExpressionTypeInferencer->>SymbolTypeIndex: resolveSeeReference(metadata path)
  SymbolTypeIndex->>TypeRegistry: resolve metadata member type
  TypeRegistry-->>SymbolTypeIndex: return qualified type
  SymbolTypeIndex-->>ExpressionTypeInferencer: return inferred type
Loading

Possibly related PRs

🚥 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 main change: parsing «См.» reference paths in configurator notation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/types-metadata-see-refs

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

🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java (1)

82-93: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for an object property reference.

Add a test for Справочник.<Объект>.<Реквизит>. The current tests do not execute the object-property branch in SymbolTypeIndex.resolveMetadataPath, so a regression in that supported path will not fail this test class.

🤖 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/types/MetadataSeeRefInferenceTest.java`
around lines 82 - 93, Add a test in MetadataSeeRefInferenceTest covering a
Справочник object property reference using the existing document context and
type-resolution helpers. Assert the resolved type matches the referenced
property, exercising the object-property branch in
SymbolTypeIndex.resolveMetadataPath.
🤖 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/types/index/SymbolTypeIndex.java`:
- Around line 404-410: Update the metadata-path handling around the section and
row resolution so paths with extra segments are rejected. Preserve trailing
empty segments when splitting the path, require exactly four segments before
resolving a row property, and only call memberTypes with parts[3] when that
exact-length condition is satisfied; otherwise return TypeSet.EMPTY.

---

Nitpick comments:
In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java`:
- Around line 82-93: Add a test in MetadataSeeRefInferenceTest covering a
Справочник object property reference using the existing document context and
type-resolution helpers. Assert the resolved type matches the referenced
property, exercising the object-property branch in
SymbolTypeIndex.resolveMetadataPath.
🪄 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: e76c84a4-e8ea-4540-a1bb-433788bfc899

📥 Commits

Reviewing files that changed from the base of the PR and between eba4f03 and fb5da57.

⛔ Files ignored due to path filters (1)
  • src/test/resources/types/MetadataSeeRef.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (3)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/index/SymbolTypeIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Test Results

 3 960 files  + 6   3 960 suites  +6   1h 9m 13s ⏱️ - 3m 24s
 4 109 tests + 6   4 038 ✅ + 6   71 💤 ±0  0 ❌ ±0 
24 654 runs  +36  24 224 ✅ +36  430 💤 ±0  0 ❌ ±0 

Results for commit bf49d54. ± Comparison against base commit eba4f03.

♻️ This comment has been updated with latest results.

Путь длиннее «вид.объект.часть.реквизит» больше не разрешается по первым
четырём частям: хвост молча отбрасывался, и «…ТабличнаяЧасть1.Реквизит1.Лишнее»
выдавал тип реквизита. Пустые части при разборе сохраняются.

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

@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.

🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java (1)

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

Assert the TypeSet contract directly.

Line 118 projects TypeSet through names(types) before checking emptiness. Use TypeSet.isEmpty() to keep this assertion focused on the absence of inferred types.

Proposed assertion
-    assertThat(names(types)).isEmpty();
+    assertThat(types.isEmpty()).isTrue();
🤖 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/types/MetadataSeeRefInferenceTest.java`
at line 118, Update the assertion in MetadataSeeRefInferenceTest to call
TypeSet.isEmpty() directly on types instead of projecting through names(types),
while preserving the expectation that no inferred types are present.
🤖 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/types/MetadataSeeRefInferenceTest.java`:
- Line 118: Update the assertion in MetadataSeeRefInferenceTest to call
TypeSet.isEmpty() directly on types instead of projecting through names(types),
while preserving the expectation that no inferred types are present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a8070a51-795d-4620-b5f0-4b20807e2451

📥 Commits

Reviewing files that changed from the base of the PR and between fb5da57 and be61622.

⛔ Files ignored due to path filters (1)
  • src/test/resources/types/MetadataSeeRef.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (3)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/index/SymbolTypeIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/MetadataSeeRefInferenceTest.java
💤 Files with no reviewable changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/inferencer/ExpressionTypeInferencer.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/index/SymbolTypeIndex.java

Части, оставшиеся после объекта метаданных, разбираются по одной: каждая
следующая берётся членом типа, полученного на предыдущей. Ограничение длины
ссылки больше не нужно — путь либо доходит до конца, либо обрывается на
неизвестном или неоднозначном члене.
@nixel2007
nixel2007 enabled auto-merge August 2, 2026 12:11
@nixel2007
nixel2007 disabled the stack merge August 2, 2026 12:11
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@nixel2007
nixel2007 merged commit 6d4caf6 into develop Aug 2, 2026
41 checks passed
@nixel2007
nixel2007 deleted the feat/types-metadata-see-refs branch August 2, 2026 12:36
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