Skip to content

Conversation

@theshadowco
Copy link
Member

@theshadowco theshadowco commented Mar 26, 2025

Описание

Скорректировано формирование и использование ссылок mdoref.

Связанные задачи

Closes

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами
  • Обязательные действия перед коммитом выполнены (запускал команду gradlew precommit)

Для диагностик

  • Описание диагностики заполнено для обоих языков (присутствуют файлы для обоих языков, для русского заполнено все подробно, перевод на английский можно опустить)

Дополнительно

Summary by CodeRabbit

  • Refactor

    • Simplified metadata reference resolution across analysis, diagnostics, hover, references and call‑hierarchy, consolidating lookups and inlining previous helper calls for clearer behavior.
    • Cleaned up and streamlined internal reference construction logic for more consistent diagnostics and symbol information.
  • Tests

    • Updated test scaffolding to reflect the consolidated metadata reference API.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 26, 2025

Walkthrough

Refactors MDO reference resolution by adding DocumentContext.getMdoRef() and delegating many former MdoRefBuilder/MdoReference call sites to it; introduces getMdoRefLocal(MD) helper in diagnostics, simplifies MdoRefBuilder logic, inlines/removes several diagnostic helpers, and applies local type inference (var) in multiple classes.

Changes

Cohort / File(s) Summary
Core Context
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java
Added public String getMdoRef() delegating to MdoRefBuilder.getMdoRef(this).
Server / Module Contexts
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputer.java
Removed MdoRefBuilder import usages; replaced calls with documentContext.getMdoRef() and applied var in locals.
CLI / Reporters
src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/AnalyzeCommand.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/FileInfo.java
Simplified MDO ref retrieval; removed unused imports; FileInfo now derives MDO ref from optional MD.
Diagnostics — base helper
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMetadataDiagnostic.java
Added protected getMdoRefLocal(MD mdo) delegating to configuration.getMdoRefLocal(mdo).
Diagnostics — ref usage & inlining
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/* (DenyIncompleteValuesDiagnostic.java, ForbiddenMetadataNameDiagnostic.java, MetadataObjectNameLengthDiagnostic.java, ProtectedModuleDiagnostic.java, SameMetadataObjectAndChildNamesDiagnostic.java, MissingEventSubscriptionHandlerDiagnostic.java, PrivilegedModuleMethodCallDiagnostic.java, ScheduledJobHandlerDiagnostic.java, WrongDataPathForFormElementsDiagnostic.java, WrongHttpServiceHandlerDiagnostic.java)
Replaced many getMdoReference().getMdoRef() / MdoRefBuilder usages with getMdoRef() or getMdoRefLocal(mdo); several helper methods removed/inlined; some method signatures updated to accept MD rather than MdoReference.
Hover / Description
src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/DescriptionFormatter.java
Removed MdoRefBuilder import; use documentContext.getMdoRef(); multiple local vars converted to var.
Providers / References
src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java
Replaced MdoRefBuilder calls with owner().getMdoRef() or documentContext.getMdoRef(); introduced MD import in some files; applied var in locals.
MdoRefBuilder
src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MdoRefBuilder.java
Simplified complex-identifier handling and removed large prior logic paths; adjusted public API for complex identifier overload; removed unused imports and helpers.
Tests / Types
src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputerTest.java, src/main/java/com/github/_1c_syntax/bsl/types/MdoReference.java
Tests updated to use MdoReference.create(...) and to stub documentContext.getMdoRef(); added factory MdoReference.create(String) used in test.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Component
    participant DC as DocumentContext
    participant MRB as MdoRefBuilder
    participant Config as Configuration

    Note over Caller,DC: Old: many callers invoked MdoRefBuilder directly
    Caller->>MRB: MdoRefBuilder.getMdoRef(documentContext)
    MRB-->>Caller: mdoRef

    Note over Caller,DC: New: callers call DocumentContext.getMdoRef()
    Caller->>DC: documentContext.getMdoRef()
    DC->>MRB: (delegates) getMdoRef(this)
    MRB-->>DC: mdoRef
    DC-->>Caller: mdoRef

    Note over Diagnostics,Config: Locale-aware diagnostic name resolution
    Diagnostics->>Config: configuration.getMdoRefLocal(mdo)
    Config-->>Diagnostics: locale-specific mdoRef
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review MdoRefBuilder simplified logic for complex identifier cases (possible behavioral regressions).
  • Verify all call-site updates from MdoReference / MdoRefBuilder to MD / DocumentContext.getMdoRef() are consistent.
  • Confirm method signature changes (MD vs MdoReference) have no missed references or test gaps.
  • Check diagnostic messages using getMdoRefLocal(MD) for locale correctness.

Possibly related PRs

Suggested reviewers

  • nixel2007

Poem

🐰
I hopped through refs both far and wide,
Gathered MDOs to place inside,
DocumentContext now keeps the key,
Diagnostics sing in harmony,
Type hints trimmed—I'm pleased to glide ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.95% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 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 refactoring: optimizing MDO reference link formation and fixing related issues throughout the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/optMdoRefBuilder

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2103458 and 2ef8bc7.

📒 Files selected for processing (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnostic.java (1 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/DescriptionFormatter.java (8 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/DescriptionFormatter.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnostic.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Benchmark
  • GitHub Check: Analyse
  • GitHub Check: build
  • GitHub Check: build (25, macOS-latest)
  • GitHub Check: build (25, ubuntu-latest)
  • GitHub Check: build (17, macOS-latest)
  • GitHub Check: build (21, ubuntu-latest)
  • GitHub Check: build (25, windows-latest)
  • GitHub Check: build (21, macOS-latest)
  • GitHub Check: build (21, windows-latest)
  • GitHub Check: build (17, ubuntu-latest)
  • GitHub Check: build (17, windows-latest)

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.

@theshadowco theshadowco force-pushed the feature/optMdoRefBuilder branch from d9dfbf3 to b11b1d6 Compare March 27, 2025 08:21
@sonarqubecloud
Copy link

@theshadowco theshadowco force-pushed the feature/optMdoRefBuilder branch from b11b1d6 to 2103458 Compare November 12, 2025 11:33
@sonarqubecloud
Copy link

@nixel2007 nixel2007 merged commit bd7a478 into develop Nov 12, 2025
56 checks passed
@nixel2007 nixel2007 deleted the feature/optMdoRefBuilder branch November 12, 2025 18:21
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.

3 participants