Skip to content

Conversation

@nixel2007
Copy link
Member

@nixel2007 nixel2007 commented Dec 29, 2025

Описание

  • Перевод Location и Referene из Value-class в record
  • Оптимизация использования Location#getRange - кэширование, там где Range нужен, и использование деконструированных данных, где можно обойтись без холостого создания Range

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

Closes

Чеклист

Общие

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

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

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

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

Summary by CodeRabbit

  • Refactor

    • Modernized API method naming conventions for improved fluency and readability
    • Streamlined range and location handling with optimized coordinate-based operations
    • Improved internal code structure for better maintainability
  • Tests

    • Added comprehensive test coverage for range comparison and position containment utilities

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 29, 2025 08:22
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

This pull request refactors the codebase from Lombok-based getter methods to Java records and fluent accessor naming conventions. Reference and Location classes are converted to immutable records, while getter methods across multiple classes are renamed to fluent-style accessors (e.g., getFrom()from(), getSelectionRange()selectionRange()). The Ranges utility class gains new coordinate-based comparison and containment methods. All consuming code in diagnostics, providers, semantic tokens, and tests are updated to use the new APIs.

Changes

Cohort / File(s) Summary
Core Model Refactoring
src/main/java/.../references/model/Location.java, Reference.java, Symbol.java
Location converted to record with Location(URI, int, int, int, int) and new getStart() method returning Position. Reference converted to record Record(SourceDefinedSymbol, Symbol, URI, Range, OccurrenceType) with fluent accessors. Symbol comparator enhanced with static import of comparing and added thenComparing(Symbol::symbolName).
Utility API Expansion
src/main/java/.../utils/Ranges.java
Added containsPosition() overloads accepting Position or explicit line/character coordinates. Added compare() method for coordinate-based range comparison. Removed getFirstSignificantTokenRange().
Diagnostic API Updates
src/main/java/.../diagnostics/MissingCommonModuleMethodDiagnostic.java, DeprecatedMethodCallDiagnostic.java, MissedRequiredParameterDiagnostic.java, PrivilegedModuleMethodCallDiagnostic.java, RewriteMethodParameterDiagnostic.java, TransferringParametersBetweenClientAndServerDiagnostic.java, UnusedLocalVariableDiagnostic.java
Updated all Reference accessor calls: getSelectionRange()selectionRange(), getSymbol()symbol(), getFrom()from(), getOccurrenceType()occurrenceType(), getUri()uri().
Provider API Updates
src/main/java/.../providers/CallHierarchyProvider.java, DefinitionProvider.java, HoverProvider.java, RenameProvider.java
Updated Reference accessor calls throughout grouping, mapping, and range retrieval logic to use fluent-style accessors.
Semantic Tokens API Updates
src/main/java/.../semantictokens/MethodCallSemanticTokensSupplier.java, SymbolsSemanticTokensSupplier.java
Updated Reference accessor calls: getSelectionRange()selectionRange(), getOccurrenceType()occurrenceType().
Reference & Repository Updates
src/main/java/.../references/ReferenceIndex.java, ReferenceIndexFiller.java, LocationRepository.java, SourceDefinedSymbolDeclarationReferenceFinder.java, SourceDefinedMethodCallInlayHintSupplier.java
Updated accessor usage across reference filtering, URI extraction, and position retrieval to use fluent method names and Location accessors (uri(), getStart()).
Test Updates
src/test/java/.../references/*Test.java, src/test/java/.../utils/RangesTest.java
Updated all test assertions and mocks to use new Reference accessor methods (from(), symbol(), selectionRange(), uri()) and new Ranges.compare() and containsPosition() methods.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 With getters gone and records here,
Our fluent API now rings clear!
From .from() to .symbol() so neat,
Immutable records, refactoring complete! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.74% 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 summarizes the main changes: converting Location and Reference classes to record types and improving range handling methods, directly reflecting the primary refactoring work.
✨ 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/optimize-location-range

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java (1)

50-56: LGTM! Correct alignment with the new Location record API.

The comparator correctly uses the record's accessors (uri(), startLine(), etc.) and delegates to Ranges.compare for coordinate-based range comparison, avoiding unnecessary Range object allocation.

Consider extracting the comparator to a private static final field to avoid reconstructing the comparator chain on each compareTo call:

🔎 Optional refactor
+  private static final Comparator<SymbolOccurrence> COMPARATOR =
+    comparing(SymbolOccurrence::location, comparing(Location::uri)
+      .thenComparing((l1, l2) -> Ranges.compare(
+        l1.startLine(), l1.startCharacter(), l1.endLine(), l1.endCharacter(),
+        l2.startLine(), l2.startCharacter(), l2.endLine(), l2.endCharacter())))
+    .thenComparing(SymbolOccurrence::occurrenceType)
+    .thenComparing(SymbolOccurrence::symbol);
+
   @Override
   public int compareTo(@Nullable SymbolOccurrence other) {
     if (other == null) {
       return 1;
     }
-
-    return comparing(SymbolOccurrence::location, comparing(Location::uri)
-        .thenComparing((l1, l2) -> Ranges.compare(
-          l1.startLine(), l1.startCharacter(), l1.endLine(), l1.endCharacter(),
-          l2.startLine(), l2.startCharacter(), l2.endLine(), l2.endCharacter())))
-      .thenComparing(SymbolOccurrence::occurrenceType)
-      .thenComparing(SymbolOccurrence::symbol)
-      .compare(this, other);
+    return COMPARATOR.compare(this, other);
   }
src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java (1)

258-278: Correct helper implementation, minor style nit.

The isBefore helper correctly implements strict lexicographic ordering.

There are consecutive blank lines (277-278) that could be reduced to a single blank line for consistency with the rest of the codebase.

🔎 Optional fix
     return character1 < character2;
   }
-
-
 
   /**
    * Натуральный порядок сравнения Range
📜 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 18c093f and 5d1f75d.

📒 Files selected for processing (8)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.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
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java
🧰 Additional context used
📓 Path-based instructions (4)
src/main/java/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/main/java/**/*.java: Follow the Style Guide for code formatting and conventions
Use Lombok annotations to reduce boilerplate code and enable annotation processing in IDE
Write JavaDoc for public APIs and include comments for complex logic
Use meaningful, descriptive names for classes and methods following Java naming conventions
Optimize imports before committing; DO NOT optimize imports across the entire project unless specifically working on that task

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java
src/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Java 17 for language and follow Java naming conventions

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java
src/test/java/**/*Test.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Maintain or improve test coverage and use appropriate test frameworks (JUnit, AssertJ, Mockito)

Files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java
src/main/java/**/diagnostics/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Each diagnostic should have: Java implementation class, resource bundle for localized messages, unit tests, and documentation

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java
🧠 Learnings (1)
📚 Learning: 2025-02-10T17:13:41.452Z
Learnt from: theshadowco
Repo: 1c-syntax/bsl-language-server PR: 3408
File: src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic.java:54-58
Timestamp: 2025-02-10T17:13:41.452Z
Learning: In ProtectedModuleDiagnostic.java, the usage of `Range` field as a diagnostic target is accepted as is, despite being marked as a temporary solution in the comments.

Applied to files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.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). (19)
  • GitHub Check: build
  • GitHub Check: build (17, windows-latest)
  • GitHub Check: build (21, ubuntu-latest)
  • GitHub Check: build (25, ubuntu-latest)
  • GitHub Check: build (25, macOS-latest)
  • GitHub Check: build (17, ubuntu-latest)
  • GitHub Check: build (21, windows-latest)
  • GitHub Check: build (17, macOS-latest)
  • GitHub Check: build (25, windows-latest)
  • GitHub Check: Benchmark
  • GitHub Check: build (21, macOS-latest)
  • GitHub Check: build (21, windows-latest)
  • GitHub Check: build (25, windows-latest)
  • GitHub Check: build (25, ubuntu-latest)
  • GitHub Check: build (25, macOS-latest)
  • GitHub Check: build (17, macOS-latest)
  • GitHub Check: build (17, ubuntu-latest)
  • GitHub Check: build (17, windows-latest)
  • GitHub Check: build (21, ubuntu-latest)
🔇 Additional comments (13)
src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java (1)

333-340: LGTM!

The added blank line improves readability by visually separating the condition check from the addVariableUsage call.

src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java (1)

58-61: LGTM!

The accessor change from getUri() to uri() correctly aligns with the new Java record API for Location.

src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java (3)

39-67: Good test coverage for the new compare method.

The test cases comprehensively cover all comparison scenarios: equal ranges, differences in start line, start character, end line, and end character. This validates the lexicographic ordering logic.


69-106: Thorough edge-case coverage for containsPosition.

The tests correctly verify the half-open interval semantics (start inclusive, end exclusive) across single-line and multi-line ranges, boundary conditions, and positions before/after the range.


108-124: LGTM!

The Position object overload tests complement the coordinate-based tests, ensuring both API variants behave consistently.

src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java (3)

110-117: LGTM! Efficient coordinate-based position check.

Using explicit coordinates avoids allocating a Range object for each filter check, aligning with the PR's optimization goals.


277-278: LGTM!

Correctly updated to use the record accessor uri().


314-315: LGTM!

The use of uri() and the new getStart() method aligns with the updated Location record API.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java (2)

88-95: LGTM! Good caching of the Range object.

Extracting location and locationRange avoids repeated getRange() calls, which is beneficial since Location.getRange() allocates a new Range instance on each invocation.


101-105: LGTM!

Consistent use of the cached locationRange variable.

src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java (1)

39-51: Clean conversion to Java record.

The record type is well-suited for this immutable value object. The secondary constructor and accessor methods provide convenient interoperability with Range and Position types.

Note: Both getRange() and getStart() allocate new objects on each call. Callers in hot paths should cache results if needed (as done in MissingCommonModuleMethodDiagnostic).

src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java (2)

216-256: LGTM! Well-designed coordinate-based overloads.

The new containsPosition overloads correctly implement half-open interval semantics [start, end). The delegation pattern between the two overloads avoids code duplication.


322-351: LGTM! Efficient coordinate-based range comparison.

The method correctly implements lexicographic comparison of ranges by comparing start positions first, then end positions. Using Integer.compare ensures proper -1/0/1 return values.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

Test Results

0 files   -  2 781  0 suites   - 2 781   0s ⏱️ - 51m 37s
0 tests  -  1 116  0 ✅  -  1 116  0 💤 ±0  0 ❌ ±0 
0 runs   - 10 044  0 ✅  - 10 044  0 💤 ±0  0 ❌ ±0 

Results for commit 0b3c3c2. ± Comparison against base commit 18c093f.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (2)
src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SemanticTokensDeltaIntegrationTest.java (2)

85-85: Ineffective await condition.

await().until(() -> true) always succeeds immediately since the condition is already true. This effectively just sleeps for the poll interval (100ms) once. If the intent is to wait for async document processing, you should await on a meaningful condition (e.g., checking document state or token availability).


141-142: Prefer Awaitility over Thread.sleep for consistency.

Using Thread.sleep(500) is less robust than Awaitility and inconsistent with the other tests in this class. Consider using Awaitility with a meaningful condition to wait for the change to be processed.

📜 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 5d1f75d and 7e3c028.

📒 Files selected for processing (24)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SemanticTokensDeltaIntegrationTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SSLSemanticTokensTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
🧰 Additional context used
📓 Path-based instructions (4)
src/main/java/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/main/java/**/*.java: Follow the Style Guide for code formatting and conventions
Use Lombok annotations to reduce boilerplate code and enable annotation processing in IDE
Write JavaDoc for public APIs and include comments for complex logic
Use meaningful, descriptive names for classes and methods following Java naming conventions
Optimize imports before committing; DO NOT optimize imports across the entire project unless specifically working on that task

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java
src/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Java 17 for language and follow Java naming conventions

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SemanticTokensDeltaIntegrationTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SSLSemanticTokensTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java
src/test/java/**/*Test.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Maintain or improve test coverage and use appropriate test frameworks (JUnit, AssertJ, Mockito)

Files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SemanticTokensDeltaIntegrationTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SSLSemanticTokensTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java
src/main/java/**/diagnostics/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Each diagnostic should have: Java implementation class, resource bundle for localized messages, unit tests, and documentation

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java
🧠 Learnings (4)
📚 Learning: 2025-02-10T17:13:41.452Z
Learnt from: theshadowco
Repo: 1c-syntax/bsl-language-server PR: 3408
File: src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic.java:54-58
Timestamp: 2025-02-10T17:13:41.452Z
Learning: In ProtectedModuleDiagnostic.java, the usage of `Range` field as a diagnostic target is accepted as is, despite being marked as a temporary solution in the comments.

Applied to files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
📚 Learning: 2025-12-28T11:15:32.357Z
Learnt from: nixel2007
Repo: 1c-syntax/bsl-language-server PR: 0
File: :0-0
Timestamp: 2025-12-28T11:15:32.357Z
Learning: In PR #3706 about semantic token optimization, I incorrectly stated that the algorithm in findSuffixMatchWithOffset correctly handles inline text insertions (text insertion without line breaks). The actual bug is that when lineOffset=0, tokens after the insertion point have the same deltaLine but different deltaStart, and the old algorithm failed to match them because it checked deltaStart equality. PR #3707 fixes this by allowing deltaStart to differ for the boundary token when lineOffset==0.

Applied to files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SemanticTokensDeltaIntegrationTest.java
📚 Learning: 2025-11-19T09:02:03.154Z
Learnt from: theshadowco
Repo: 1c-syntax/bsl-language-server PR: 3610
File: src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplier.java:26-26
Timestamp: 2025-11-19T09:02:03.154Z
Learning: В проекте bsl-language-server используется кастомная версия ANTLR4 от 1c-syntax (io.github.1c-syntax:antlr4), которая включает базовый класс org.antlr.v4.runtime.Tokenizer с методами getAst() и getTokens(). SDBLTokenizer и BSLTokenizer наследуются от этого базового класса.

Applied to files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SSLSemanticTokensTest.java
📚 Learning: 2024-12-27T17:03:11.817Z
Learnt from: nixel2007
Repo: 1c-syntax/bsl-language-server PR: 3364
File: src/main/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinder.java:125-127
Timestamp: 2024-12-27T17:03:11.817Z
Learning: В методе `findAnnotation` класса `AnnotationReferenceFinder` уже проверяется, что у аннотации ровно один параметр, поэтому в `getAnnotationName` не требуется отдельная проверка на пустой список.

Applied to files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java
🧬 Code graph analysis (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/RelatedInformation.java (1)
  • RelatedInformation (36-54)
🔇 Additional comments (36)
src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java (1)

31-31: LGTM! Clean static import usage.

The static import of comparing and its direct usage in the comparator chain improves readability without changing behavior.

Also applies to: 64-69

src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java (1)

72-72: LGTM! Reference API accessor updates are correct.

The migration from get-style (getSelectionRange(), getSymbol(), getFrom()) to fluent-style accessors (selectionRange(), symbol(), from()) is consistent with the record-based Reference API refactor.

Also applies to: 81-84, 188-188

src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java (1)

55-55: LGTM! Reference accessor update is correct.

The change from getSelectionRange() to selectionRange() aligns with the record-based Reference API.

src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java (1)

68-68: LGTM! Reference accessor updates are correct.

The migration to symbol() and selectionRange() is consistent with the record-based Reference API refactor.

Also applies to: 74-74

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java (1)

70-70: LGTM! Reference accessor update is correct.

The change from getOccurrenceType() to occurrenceType() aligns with the record-based Reference API.

src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java (1)

114-115: LGTM! Reference accessor updates are correct.

The migration to from(), symbol(), and selectionRange() (both method references and direct calls) is consistent with the record-based Reference API refactor.

Also applies to: 144-147

src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java (1)

89-93: LGTM! Reference accessor updates are correct.

The migration from getOccurrenceType() and getSelectionRange() to occurrenceType() and selectionRange() is consistent with the record-based Reference API refactor, correctly applied to both occurrence type branches.

src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java (1)

65-66: LGTM! Accessor updates are correct.

The transition from getSymbol()symbol() and getSelectionRange()selectionRange() aligns with the Reference record refactoring and Java record conventions.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java (1)

56-62: LGTM! Consistent accessor migration.

All Reference accessor calls updated correctly: symbol(), from(), and selectionRange() replace their getter equivalents. Logic remains unchanged.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java (1)

51-53: LGTM! Test assertions updated correctly.

Test assertions now use the fluent-style accessors from(), symbol(), and selectionRange(), maintaining test coverage for the refactored API.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java (1)

63-63: LGTM! Test and mock updates are correct.

Both test assertions and mock setup now use uri() instead of getUri(), maintaining consistency with the refactored Reference API.

Also applies to: 72-72, 111-111

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java (1)

62-64: LGTM! Accessor updates are correct.

The diagnostic now uses selectionRange() and symbol() accessors, consistent with the Reference record refactoring.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java (1)

93-93: LGTM! All accessor updates are consistent.

The diagnostic correctly uses uri(), selectionRange(), and symbol() accessors throughout, maintaining the existing logic while adopting the new API.

Also applies to: 105-106

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java (1)

61-64: LGTM! Comprehensive test coverage with new accessors.

All test assertions throughout the file consistently use the fluent-style accessors: from(), symbol(), symbol().getName(), symbol().getSymbolKind(), and selectionRange(). The test coverage is preserved with the updated API.

Also applies to: 83-86, 105-108, 148-151, 186-186, 228-228, 244-244, 322-324

src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java (1)

81-81: LGTM! Rename provider correctly updated.

The provider now uses uri() for grouping references by document and selectionRange() for obtaining edit ranges, maintaining the rename functionality with the new accessor API.

Also applies to: 105-105, 111-111

src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SemanticTokensDeltaIntegrationTest.java (1)

46-52: Good integration test structure.

Well-designed integration tests covering delta semantic token scenarios with proper LSP workflow simulation. The test class appropriately handles both delta and full token response paths.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java (2)

109-112: LGTM - accessor updates align with Reference record migration.

The test assertions correctly use the new record accessor methods (uri(), from(), symbol(), selectionRange()) consistent with the Reference refactoring to a Java record.


130-133: Accessor updates consistent with the Reference record API.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java (4)

183-184: Accessor update aligns with Reference record API.


200-201: Consistent with the Reference record migration.


206-211: Correct usage of from() accessor.


232-235: LGTM - RelatedInformation creation uses correct record accessors.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java (4)

106-108: Sorting logic correctly updated.

The comparator correctly uses the selectionRange() accessor from the Reference record.


129-131: Accessor update for occurrence type check.


148-160: Correct accessor usage for position extraction.

Both defRef.selectionRange().getStart() and nextRef.selectionRange().getStart() correctly chain the record accessor with the Range method.


176-191: LGTM - Diagnostic creation uses correct record accessors.

The reference.selectionRange() and nodeForIssue.selectionRange() calls properly use the new Reference record API.

src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java (3)

32-47: Clean migration to Java record.

The conversion from Lombok @Value class to a Java record is well-executed. The record preserves immutability, provides automatic accessor methods, and maintains all existing functionality. Good use of Javadoc @param tags to document the record components.


49-61: Existing helper methods preserved correctly.

The getSourceDefinedSymbol(), isSourceDefinedSymbolReference(), and toLocation() methods are correctly retained and work with the record's component accessors.


63-75: Factory methods provide convenient construction.

The of() factory methods properly parse the Location's URI and extract the Range, providing a clean API for creating Reference instances.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java (3)

73-80: Method reference updates align with record accessors.

The test correctly uses Reference::symbol and Reference::selectionRange method references with AssertJ's extracting().


152-164: Comprehensive accessor coverage in assertions.

Properly validates symbol, from, and occurrenceType using the new record accessors.


317-320: URI filtering uses correct accessor.

The ref.uri().equals() filter pattern is correctly applied across multiple test methods.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java (4)

159-162: LGTM - Comprehensive accessor updates.

All four accessor calls (from(), symbol(), selectionRange(), uri()) correctly use the new Reference record API.


176-199: Multiple reference assertions correctly updated.

The filtering by reference.uri() and subsequent assertions on from(), symbol(), selectionRange(), and uri() are consistent with the record migration.


214-239: Accessor updates consistent throughout test methods.


247-249: Correct usage in containsRange filter.

The reference.selectionRange() accessor is properly used with Ranges.containsRange().

@nixel2007 nixel2007 changed the title Refactor Location class to use record type and improve range handling methods Refactor Location and Reference classes to use record type and improve range handling methods Dec 29, 2025
@nixel2007 nixel2007 force-pushed the feature/optimize-location-range branch from 7e3c028 to 0b3c3c2 Compare December 29, 2025 08:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java (1)

110-115: Consider removing explicit lambda parameter type.

The explicit type annotation (SymbolOccurrence symbolOccurrence) can be simplified using type inference for cleaner code.

🔎 Proposed simplification
-      .filter((SymbolOccurrence symbolOccurrence) -> {
+      .filter(symbolOccurrence -> {
         var location = symbolOccurrence.location();
         return Ranges.containsPosition(
           location.startLine(), location.startCharacter(), location.endLine(), location.endCharacter(),
           position);
       })
📜 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 7e3c028 and 0b3c3c2.

📒 Files selected for processing (22)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
🧰 Additional context used
📓 Path-based instructions (4)
src/main/java/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/main/java/**/*.java: Follow the Style Guide for code formatting and conventions
Use Lombok annotations to reduce boilerplate code and enable annotation processing in IDE
Write JavaDoc for public APIs and include comments for complex logic
Use meaningful, descriptive names for classes and methods following Java naming conventions
Optimize imports before committing; DO NOT optimize imports across the entire project unless specifically working on that task

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
src/main/java/**/diagnostics/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Each diagnostic should have: Java implementation class, resource bundle for localized messages, unit tests, and documentation

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
src/**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Java 17 for language and follow Java naming conventions

Files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java
src/test/java/**/*Test.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Maintain or improve test coverage and use appropriate test frameworks (JUnit, AssertJ, Mockito)

Files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java
🧠 Learnings (2)
📚 Learning: 2024-12-27T17:03:11.817Z
Learnt from: nixel2007
Repo: 1c-syntax/bsl-language-server PR: 3364
File: src/main/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinder.java:125-127
Timestamp: 2024-12-27T17:03:11.817Z
Learning: В методе `findAnnotation` класса `AnnotationReferenceFinder` уже проверяется, что у аннотации ровно один параметр, поэтому в `getAnnotationName` не требуется отдельная проверка на пустой список.

Applied to files:

  • src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java
📚 Learning: 2025-02-10T17:13:41.452Z
Learnt from: theshadowco
Repo: 1c-syntax/bsl-language-server PR: 3408
File: src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic.java:54-58
Timestamp: 2025-02-10T17:13:41.452Z
Learning: In ProtectedModuleDiagnostic.java, the usage of `Range` field as a diagnostic target is accepted as is, despite being marked as a temporary solution in the comments.

Applied to files:

  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
🔇 Additional comments (14)
src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java (4)

155-155: LGTM!

The migration from getFrom() to from() is consistent with the Reference record conversion and fluent accessor naming conventions.


277-277: LGTM!

The migration from getUri() to uri() is consistent with the Location record conversion and fluent accessor naming conventions.


314-315: LGTM! Good optimization.

The migration to fluent accessors (uri()) and the direct access to start position via getStart() avoids creating an unnecessary Range object, which aligns with the PR's optimization objectives.


329-329: LGTM!

The migration from getFrom() to from() is consistent with the Reference record conversion and fluent accessor naming conventions.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java (1)

62-64: LGTM! Accessor migration is correct.

The changes correctly update from getter-style to fluent record accessors (selectionRange(), symbol()). The logic remains intact.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java (1)

107-107: LGTM! Consistent accessor updates.

All accessor calls have been correctly migrated to the fluent record style across sorting, filtering, and diagnostic creation.

src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java (1)

81-81: LGTM! Rename provider correctly updated.

All accessor calls migrated to fluent style, including method references. The rename functionality is preserved.

src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java (1)

72-84: LGTM! Inlay hint supplier properly updated.

The migration to fluent accessors is consistent throughout. The addition of .toList() on line 76 is idiomatic for Java 17.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java (1)

51-53: LGTM! Test assertions correctly updated.

All test expectations now use the fluent record accessors, maintaining the same verification logic.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/AnnotationReferenceFinderTest.java (1)

61-64: LGTM! Comprehensive test updates.

All test assertions across the file have been correctly migrated to use fluent record accessors. Test coverage and verification logic remain intact.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java (1)

63-72: LGTM! Test and mocks properly updated.

Both test assertions and mock configuration have been consistently updated to use the fluent uri() accessor.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java (1)

56-62: LGTM! Diagnostic correctly refactored.

All accessor calls migrated to fluent record style. The diagnostic logic for detecting deprecated method calls remains correct.

src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java (2)

74-74: LGTM! Consistent API updates to fluent accessor naming.

All test assertions correctly updated from getter methods (getSymbol(), getFrom(), getSelectionRange(), getOccurrenceType()) to fluent-style accessors (symbol(), from(), selectionRange(), occurrenceType()), consistent with the Reference record type conversion. Test logic and coverage remain unchanged.

Also applies to: 79-79, 153-153, 158-158, 163-163, 211-211, 235-235, 260-260, 265-265


318-318: LGTM! Stream filter operations correctly updated.

All stream filter predicates consistently updated from ref.getUri() to ref.uri(), maintaining the same filtering logic while using the new fluent accessor API.

Also applies to: 327-327, 360-360, 370-370, 402-402, 411-411, 443-443, 453-453

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Location class from a Lombok value class to a Java record and optimizes range handling by introducing deconstructed parameter methods in the Ranges utility class. The changes reduce unnecessary Range object creation by allowing direct use of coordinate values where the full Range object isn't needed.

Key Changes:

  • Converted Location and Reference classes from Lombok value classes to Java records
  • Added new overloaded methods in Ranges class to work with deconstructed coordinates (startLine, startCharacter, endLine, endCharacter)
  • Updated all references to use record accessor methods (e.g., getUri()uri(), getFrom()from())

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Location.java Converted from Lombok value class to record with deconstructed coordinates
Reference.java Converted from Lombok value class to record
Ranges.java Added deconstructed parameter variants of containsPosition() and compare() methods
RangesTest.java Added comprehensive tests for new deconstructed methods
SymbolOccurrence.java Updated comparator to use deconstructed Location coordinates
ReferenceIndex.java Updated to use deconstructed Location coordinates for position checks
Various provider/diagnostic files Updated to use record accessor methods instead of getter methods
Various test files Updated to use record accessor methods in assertions

@nixel2007 nixel2007 requested a review from Copilot December 29, 2025 08:39
@nixel2007 nixel2007 enabled auto-merge December 29, 2025 08:40
@nixel2007 nixel2007 merged commit 182aea9 into develop Dec 29, 2025
47 checks passed
@nixel2007 nixel2007 deleted the feature/optimize-location-range branch December 29, 2025 08:58
@sonarqubecloud
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Comment on lines +277 to +278


Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

There are two consecutive blank lines (277-278) that should be reduced to a single blank line to maintain consistent code style. In Java, typically only one blank line is used to separate method declarations.

Suggested change

Copilot uses AI. Check for mistakes.
public ParserRuleContext visitModuleVarDeclaration(BSLParser.ModuleVarDeclarationContext ctx) {
findVariableSymbol(ctx.var_name().getText()).ifPresent(s -> {
if (notVariableInitialization(ctx, s)) {

Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

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

There is an unnecessary blank line after the opening brace of the if statement. This blank line should be removed to maintain consistent code formatting and readability.

Suggested change

Copilot uses AI. Check for mistakes.
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