Skip to content

Владелец подчинённого справочника типизируется по метаданным - #4346

Merged
nixel2007 merged 1 commit into
developfrom
feat/catalog-owner-typing
Aug 1, 2026
Merged

Владелец подчинённого справочника типизируется по метаданным#4346
nixel2007 merged 1 commit into
developfrom
feat/catalog-owner-typing

Conversation

@sfaqer

@sfaqer sfaqer commented Aug 1, 2026

Copy link
Copy Markdown
Member

В синтакс-помощнике стандартный реквизит Владелец объявлен типом Неопределено — и для неподчинённого справочника это правда. У подчинённого владельцы известны из Catalog.getOwners(), оттуда и берётся тип; несколько владельцев дают объединение.

Заодно закрыт хвост, из-за которого это не работало бы и с типом: бестиповый стандартный реквизит из mdclasses больше не регистрируется. Дедуп членов идёт по (вид, имя), и такой член затирал объявление платформы вместе с его типом и описанием. Общее правило — не отдавать член, тип которого из метаданных не выводится.

Выделено из #4337, чтобы не тащить в ветку типов форм.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved type resolution for subordinate catalogs and their owner properties.
    • Prevented duplicate standard attributes when platform declarations already provide them.
    • Improved handling of catalog type families and incomplete metadata.
    • Added owner-property information to built-in catalog definitions.
  • Tests

    • Added coverage for catalog owner-property resolution and platform-provided declarations.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Catalog owner type resolution

Layer / File(s) Summary
Owner member specialization
src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypesRegistrar.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java, src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json
Platform declarations define Владелец. CatalogOwnerTypesRegistrar resolves owner references for subordinate catalogs and generic catalog families. ConfigurationTypesProvider delegates specialization and skips unresolved standard attributes that would duplicate platform declarations.
Owner type resolution tests
src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypeTest.java, src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProviderHelpersTest.java
Tests cover subordinate catalogs, catalog families, independent catalogs, platform declarations, and provider wiring.

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

Sequence Diagram(s)

sequenceDiagram
  participant CatalogMetadata
  participant ConfigurationTypesProvider
  participant CatalogOwnerTypesRegistrar
  participant TypeRegistry
  participant PlatformDeclarations
  CatalogMetadata->>ConfigurationTypesProvider: register catalog metadata
  ConfigurationTypesProvider->>CatalogOwnerTypesRegistrar: register catalog owner members
  CatalogOwnerTypesRegistrar->>TypeRegistry: resolve owner reference types
  TypeRegistry-->>CatalogOwnerTypesRegistrar: return registered owner types
  CatalogOwnerTypesRegistrar->>TypeRegistry: register specialized Владелец members
  ConfigurationTypesProvider->>PlatformDeclarations: retain platform declarations for untyped attributes
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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 Заголовок точно описывает основное изменение: типизация реквизита «Владелец» подчинённого справочника по метаданным.
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 💡 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/catalog-owner-typing

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/types/registry/ConfigurationTypesProvider.java`:
- Around line 708-723: Update registerOwnerMembers so owner reference types are
resolved only after all catalog reference types have been registered, using a
deferred or second-pass registration flow. Ensure catalogs processed before
their owners still register the Владелец override, and add a regression test
covering that metadata ordering.
🪄 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: ee5177b7-7995-4259-9763-7ffb64e8bf39

📥 Commits

Reviewing files that changed from the base of the PR and between 6fb9c39 and 31e83fd.

📒 Files selected for processing (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypeTest.java

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Test Results

 3 888 files  + 6   3 888 suites  +6   1h 3m 0s ⏱️ - 3m 56s
 3 936 tests + 4   3 894 ✅ + 4   42 💤 ±0  0 ❌ ±0 
23 616 runs  +24  23 360 ✅ +24  256 💤 ±0  0 ❌ ±0 

Results for commit 6b74679. ± Comparison against base commit 6fb9c39.

♻️ This comment has been updated with latest results.

@sfaqer
sfaqer force-pushed the feat/catalog-owner-typing branch from 31e83fd to 36dc5f9 Compare August 1, 2026 05:44

@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: 3

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

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

Add regression coverage for owner order and multiple owners.

Force a fixture order where the subordinate catalog is processed before its owner. The current test can pass with the previous eager implementation when the owner registers first.

Add a catalog with multiple owners. Assert that Владелец contains every owner reference type.

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/types/registry/CatalogOwnerTypeTest.java`
around lines 46 - 104, Extend the catalog-owner test fixture and tests to cover
both registration order and multiple owners: ensure the subordinate catalog is
processed before its owner, then verify memberTypes for Владелец still resolves
the owner reference lazily. Add a catalog with multiple owners and assert that
its Владелец member contains every expected owner reference type, using the
existing CatalogOwnerTypeTest helpers and AssertJ style.

Source: Coding guidelines

src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json (1)

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

Update both locale docs for the catalog Владелец/Owner property.

This registry entry changes the type contract for the catalog reference’s owner property. Add/adjust coverage in docs/ and docs/en/ that Владелец/Owner resolves as Неопределено/Undefined for non-subordinate catalogs, and resolves to the catalog object type for subordinate catalogs.

🤖 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/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json`
around lines 2823 - 2827, Update the documentation entries for the catalog
Владелец/Owner property in both docs/ and docs/en/ to describe its conditional
type: Неопределено/Undefined for non-subordinate catalogs and the catalog object
type for subordinate catalogs. Keep the locale-specific terminology consistent
with the registry entry.

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.

Inline comments:
In
`@src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json`:
- Around line 3481-3488: Update the “Владелец” property definition in the
СправочникСсылка built-in type registry to include accessMode set to READ,
matching the other standard properties in the block and keeping the property
non-writable.
- Around line 3481-3488: Update the “Владелец” property declaration in the
builtin platform types registry to replace the generic description field with
localized descriptionRu and descriptionEn fields, preserving the existing
Russian text and providing its English equivalent so localized hover and
documentation output retain the owner description.
- Around line 2823-2827: Update the `Владелец` property declaration in
`builtin-platform-types.json` so its `description` states that the owner
reference applies only to subordinate catalogs, matching the corresponding
reference declaration; preserve the existing `returnType` and other metadata.

---

Nitpick comments:
In
`@src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json`:
- Around line 2823-2827: Update the documentation entries for the catalog
Владелец/Owner property in both docs/ and docs/en/ to describe its conditional
type: Неопределено/Undefined for non-subordinate catalogs and the catalog object
type for subordinate catalogs. Keep the locale-specific terminology consistent
with the registry entry.

In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypeTest.java`:
- Around line 46-104: Extend the catalog-owner test fixture and tests to cover
both registration order and multiple owners: ensure the subordinate catalog is
processed before its owner, then verify memberTypes for Владелец still resolves
the owner reference lazily. Add a catalog with multiple owners and assert that
its Владелец member contains every expected owner reference type, using the
existing CatalogOwnerTypeTest helpers and AssertJ style.
🪄 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: 38ff23d9-2734-4e9a-9170-38a997eed402

📥 Commits

Reviewing files that changed from the base of the PR and between 31e83fd and 36dc5f9.

⛔ Files ignored due to path filters (4)
  • src/test/resources/metadata/catalogOwners/Catalogs/Справочник1.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Catalogs/Справочник2.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Configuration.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Languages/Русский.xml is excluded by !src/test/resources/**
📒 Files selected for processing (3)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypeTest.java

@sfaqer
sfaqer force-pushed the feat/catalog-owner-typing branch 2 times, most recently from 7cc25c8 to 940e22c Compare August 1, 2026 07:21

@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/registry/CatalogOwnerTypeTest.java (1)

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

Add a test for a catalog with multiple owners.

The PR requires a union type when Catalog.getOwners() returns multiple owners. The current tests only assert one owner type. A broken implementation that keeps only the first owner will pass.

Add metadata with two owners. Assert both qualified reference types, preferably with containsExactlyInAnyOrder(...).

🤖 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/registry/CatalogOwnerTypeTest.java`
around lines 73 - 85, Extend the catalog test metadata to define a catalog with
two owners, then add a test covering its owner member through the relevant type
path. Assert both qualified owner reference types with
containsExactlyInAnyOrder, ensuring the implementation preserves every value
returned by Catalog.getOwners() rather than only the first.
🤖 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/registry/CatalogOwnerTypeTest.java`:
- Around line 73-85: Extend the catalog test metadata to define a catalog with
two owners, then add a test covering its owner member through the relevant type
path. Assert both qualified owner reference types with
containsExactlyInAnyOrder, ensuring the implementation preserves every value
returned by Catalog.getOwners() rather than only the first.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4961db5-a11b-4c76-aff0-d4882f7e22f8

📥 Commits

Reviewing files that changed from the base of the PR and between 36dc5f9 and 940e22c.

⛔ Files ignored due to path filters (4)
  • src/test/resources/metadata/catalogOwners/Catalogs/Справочник1.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Catalogs/Справочник2.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Configuration.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Languages/Русский.xml is excluded by !src/test/resources/**
📒 Files selected for processing (5)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypesRegistrar.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypeTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProviderHelpersTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json

…нным

В синтакс-помощнике стандартный реквизит Владелец объявлен типом
Неопределено — и для неподчинённого справочника это правда. У подчинённого
владельцы известны из Catalog.getOwners(), оттуда и берётся тип (несколько
владельцев дают объединение).

Заодно бестиповый стандартный реквизит из mdclasses больше не регистрируется:
он перекрывал объявление платформы, у которой есть и тип, и описание.
@sfaqer
sfaqer force-pushed the feat/catalog-owner-typing branch from 940e22c to 6b74679 Compare August 1, 2026 07:54

@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/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypesRegistrar.java (1)

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

Move call-order rationale out of this Javadoc.

The Javadoc explains that getChildrenByMdoRef() returns an immutable hash map whose iteration order JDK randomizes across runs, and that this is why owner types resolve lazily inside the member source. This is information about caller-side traversal order, not about the contract of registerOwnerMembers itself.

The coding guidelines require Javadoc to describe the contract (parameters, result, invariants, side effects) but not callers or call order; such details belong in the caller, tests, package-info, or documentation. The test file already places equivalent reasoning correctly in a comment on PATH_TO_METADATA (CatalogOwnerTypeTest.java, lines 46-55), which duplicates this explanation.

Trim this Javadoc to the contract (what the method does and the "why lazy" invariant), and keep the traversal-order rationale only in the test comment or a package-info.java.

As per coding guidelines, "Javadoc классов и методов должен описывать контракт: параметры, результат, инварианты и побочные эффекты, но не вызывающие стороны, порядок вызовов или CLI-сценарии; сведения о вызовах хранить у вызывающей стороны, в тестах, package-info или документации."

🤖 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/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypesRegistrar.java`
around lines 56 - 76, The Javadoc for registerOwnerMembers contains caller
traversal-order details that do not belong in the method contract. Trim it to
describe the direct owner-type replacement for subordinate catalogs, handling
multiple owners as a union, and the invariant that owner types resolve lazily
within the member source; remove references to getChildrenByMdoRef(), hash-map
iteration, configuration traversal, and registration timing.

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/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypesRegistrar.java`:
- Around line 56-76: The Javadoc for registerOwnerMembers contains caller
traversal-order details that do not belong in the method contract. Trim it to
describe the direct owner-type replacement for subordinate catalogs, handling
multiple owners as a union, and the invariant that owner types resolve lazily
within the member source; remove references to getChildrenByMdoRef(), hash-map
iteration, configuration traversal, and registration timing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 75274779-82be-4d84-8356-544ba44c807d

📥 Commits

Reviewing files that changed from the base of the PR and between 940e22c and 6b74679.

⛔ Files ignored due to path filters (4)
  • src/test/resources/metadata/catalogOwners/Catalogs/Справочник1.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Catalogs/Справочник2.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Configuration.xml is excluded by !src/test/resources/**
  • src/test/resources/metadata/catalogOwners/Languages/Русский.xml is excluded by !src/test/resources/**
📒 Files selected for processing (5)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypesRegistrar.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/CatalogOwnerTypeTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProviderHelpersTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProviderHelpersTest.java
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/types/registry/builtin-platform-types.json
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java

@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

@nixel2007
nixel2007 merged commit 50d66d6 into develop Aug 1, 2026
41 of 42 checks passed
@nixel2007
nixel2007 deleted the feat/catalog-owner-typing branch August 1, 2026 16:05
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.

2 participants