Skip to content

feat(semantictokens): не красить методы модулей конфигурации как defaultLibrary#4136

Merged
nixel2007 merged 3 commits into
developfrom
feature/semantictokens-config-method-defaultlibrary
Jun 16, 2026
Merged

feat(semantictokens): не красить методы модулей конфигурации как defaultLibrary#4136
nixel2007 merged 3 commits into
developfrom
feature/semantictokens-config-method-defaultlibrary

Conversation

@nixel2007

@nixel2007 nixel2007 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Follow-up к #3996 (п.3 — симметрия для методов).

Проблема

Модификатор LSP defaultLibrary означает «символ из стандартной библиотеки/платформы». Экспортные методы модулей конфигурации (общих модулей, менеджеров, объектов) — это код разработчика, а не платформенный API, поэтому defaultLibrary им не положен — так же, как и собственным реквизитам в #3996.

Вызовы методов общих модулей (ОбщегоНазначения.X()) уже красились корректно: они проходят через ReferenceIndex и MethodCallSemanticTokensSupplier, который defaultLibrary не вешает.

А вот методы модулей менеджеров/объектов, вызванные у типизированной переменной, резолвятся по типу через TypeService.memberAt, в ReferenceIndex не попадают и потому красились PlatformMemberMethodCallSemanticTokensSupplier как Method + DefaultLibrary — неверно:

// Параметры:
//  Менеджер - СправочникМенеджер.Справочник1
Процедура Тест(Менеджер)
    Менеджер.ТестЭкспортная(); // было Method + DefaultLibrary → стало просто Method
КонецПроцедуры

Что сделано

  1. ConfigurationModuleMembersProvider.toMethodMember — членам, построенным из экспортных методов модулей конфигурации, выставляется standardLibrary = false.
  2. PlatformMemberMethodCallSemanticTokensSupplier.modifiers()defaultLibrary вешается только при standardLibrary; для членов конфигурации остаётся обычный Method (а async-методы получают только Async).

Тесты

PlatformMemberMethodCallSemanticTokensSupplierTest:

  • testManagerModuleExportMethodNotColoredAsDefaultLibrary — интеграционный (красный до фикса: метод имел DefaultLibrary);
  • testModifiersForConfigurationDescriptor / testModifiersForAsyncConfigurationDescriptor — все четыре ветки modifiers() покрыты.

Прогон: semantictokens / types / hover / completion — зелёные. Регрессий в MethodCallSemanticTokensSupplier / GlobalScopeSemanticTokensSupplier / ConfigurationManagerChainInference нет.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved syntax highlighting accuracy for method calls by properly distinguishing between platform standard library methods and custom configuration methods.
    • Fixed semantic token coloring for properties and methods—configuration members no longer incorrectly receive platform library highlighting modifiers.
    • Corrected highlighting behavior for asynchronous methods based on their source (platform vs. configuration).

…ultLibrary

Симметрия к правке для реквизитов (#3996): экспортные методы модулей
конфигурации (общих модулей, менеджеров, объектов и т.п.) — не платформенный
API, поэтому модификатор LSP `defaultLibrary` им не положен.

Вызовы методов общих модулей (`ОбщегоНазначения.X()`) уже красились корректно —
они идут через ReferenceIndex и `MethodCallSemanticTokensSupplier` (без
defaultLibrary). Но методы модулей менеджеров/объектов, вызванные у
типизированной переменной (`Менеджер.ТестЭкспортная()`), резолвятся по типу,
в ReferenceIndex не попадают и красились `PlatformMemberMethodCallSemanticTokensSupplier`
как Method + DefaultLibrary — неверно.

- ConfigurationModuleMembersProvider.toMethodMember: членам выставляется
  standardLibrary = false.
- PlatformMemberMethodCallSemanticTokensSupplier.modifiers(): DefaultLibrary
  вешается только при standardLibrary; async-методы получают только Async.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b74eaf79-f540-474c-a7f3-862bc990369b

📥 Commits

Reviewing files that changed from the base of the PR and between fff92c4 and 5e66b81.

📒 Files selected for processing (4)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/model/MemberDescriptor.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/BuiltinTypesJsonLoader.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/GlobalScopeProvider.java
💤 Files with no reviewable changes (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/BuiltinTypesJsonLoader.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/GlobalScopeProvider.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/types/registry/ConfigurationTypesProvider.java

📝 Walkthrough

Walkthrough

MemberDescriptor.standardLibrary default changes from true to false. Platform member providers (BslContextPlatformTypesProvider, BuiltinTypesJsonLoader, GlobalScopeProvider) now explicitly set withStandardLibrary(true). ConfigurationTypesProvider removes explicit false overrides. PlatformMemberMethodCallSemanticTokensSupplier applies DefaultLibrary modifier only when standardLibrary is true. Four new tests verify the conditional behavior.

Changes

Conditional DefaultLibrary Modifier Based on standardLibrary Flag

Layer / File(s) Summary
MemberDescriptor default and factory method updates
src/main/java/.../types/model/MemberDescriptor.java
Compat constructors changed to pass standardLibrary=false instead of true; event() factory explicitly sets withStandardLibrary(true); javadoc updated to document false as default for configuration members.
Mark platform members with withStandardLibrary(true) across providers
src/main/java/.../registry/BslContextPlatformTypesProvider.java, src/main/java/.../registry/BuiltinTypesJsonLoader.java, src/main/java/.../registry/GlobalScopeProvider.java
Fixes method-chain parentheses in BslContextPlatformTypesProvider to correctly apply .withStandardLibrary(true) to context properties, methods, events, and enum values. BuiltinTypesJsonLoader wraps each member descriptor with .withStandardLibrary(true). GlobalScopeProvider adds .withStandardLibrary(true) to global function descriptors.
Configuration members rely on false default; StandardAttribute gets true
src/main/java/.../registry/ConfigurationTypesProvider.java
Removes explicit .withStandardLibrary(false) from tabular section and common attribute members; applies .withStandardLibrary(true) only for StandardAttribute instances in buildAttributeMembers.
Propagate flag through member specialization
src/main/java/.../registry/MetadataCollectionSpecializer.java
materializeChildMember and withElementReturnType now pass template.standardLibrary() to newly created MemberDescriptor constructors.
Conditional DefaultLibrary modifier in supplier
src/main/java/.../semantictokens/PlatformMemberMethodCallSemanticTokensSupplier.java
Adds private modifier constant arrays for async-only and empty cases; modifiers(MemberDescriptor) branches on standardLibrary() to return DefaultLibrary-inclusive, async-only, or empty modifier sets.
Tests for conditional modifier behavior
src/test/java/.../semantictokens/PlatformMemberMethodCallSemanticTokensSupplierTest.java, src/test/java/.../semantictokens/PlatformMemberPropertyAccessSemanticTokensSupplierTest.java
Four new tests cover configuration manager export method (no DefaultLibrary), platform manager method (retains DefaultLibrary), and modifiers() unit tests for non-async and async configuration descriptors. Existing tests updated with explicit withStandardLibrary(true). Property access test updated to expect no DefaultLibrary for configuration-sourced structure fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • 1c-syntax/bsl-language-server#3950: Modifies PlatformMemberMethodCallSemanticTokensSupplier and its tests for platform accessCall method tokenization with DefaultLibrary, which this PR extends by conditioning DefaultLibrary on standardLibrary().
  • 1c-syntax/bsl-language-server#3953: Shares the same PlatformMemberMethodCallSemanticTokensSupplier modifier logic and test structure around async and DefaultLibrary selection.
  • 1c-syntax/bsl-language-server#4132: Introduces MemberDescriptor.standardLibrary flag propagation and uses it in property access semantic token suppliers, directly related to this PR's method call token supplier changes.

Suggested reviewers

  • theshadowco

Poem

🐇 Hop, hop, the tokens glow,
But not for config — only platform's show!
standardLibrary=false by default now stands,
While platform providers wave their marking hands.
DefaultLibrary? Only for those who truly belong!
The rabbit checks the flag and hops along. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.81% 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 accurately describes the main change: preventing configuration module methods from being colored as defaultLibrary in semantic tokens.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feature/semantictokens-config-method-defaultlibrary

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 and usage tips.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Test Results

 3 468 files  ± 0   3 468 suites  ±0   1h 46m 11s ⏱️ + 3m 40s
 3 481 tests + 3   3 463 ✅ + 3   18 💤 ±0  0 ❌ ±0 
20 886 runs  +18  20 774 ✅ +18  112 💤 ±0  0 ❌ ±0 

Results for commit 7d29a6f. ± Comparison against base commit e9bcb35.

♻️ This comment has been updated with latest results.

…му заявлять явно

По ревью: модификатор `defaultLibrary` — это «из стандартной библиотеки/платформы»,
поэтому платформенность должна заявляться явно, а не выключаться у конфигурации.

- MemberDescriptor: compat-конструкторы и фабрики (method/property/event/
  genericProperty) теперь дают standardLibrary = false.
- Платформенные источники проставляют true явно: BslContextPlatformTypesProvider
  (свойства/методы/события/значения перечислений), BuiltinTypesJsonLoader,
  GlobalScopeProvider (глобальные функции), EventHandlerResolver (события
  OneScript-классов), стандартные реквизиты в ConfigurationTypesProvider.
- MetadataCollectionSpecializer: materializeChildMember/withElementReturnType
  проносят флаг шаблона — платформенные методы менеджеров/коллекций
  (Справочники.X.НайтиПоКоду) не теряют defaultLibrary.
- Конфигурационные источники больше не объявляют false явно (он и так дефолт).

Тест-стражи: платформенный метод менеджера сохраняет defaultLibrary; поле
структуры (ключ задан разработчиком) красится обычным Property без defaultLibrary.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

…nt() в фабрике

- event(): фабрика сразу проставляет standardLibrary = true (события всегда
  платформенные), убраны явные withStandardLibrary(true) в EventHandlerResolver;
- из пакета types убран термин defaultLibrary (домен semantic tokens):
  переформулированы javadoc/комментарии в MemberDescriptor и ConfigurationTypesProvider;
- удалены лишние/очевидные комментарии у withStandardLibrary(true/false)
  в BuiltinTypesJsonLoader, GlobalScopeProvider, ConfigurationModuleMembersProvider.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@nixel2007
nixel2007 merged commit 6c473b6 into develop Jun 16, 2026
19 of 20 checks passed
@nixel2007
nixel2007 deleted the feature/semantictokens-config-method-defaultlibrary branch June 16, 2026 18: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