Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

  • Create SemanticTokensOptions configuration class with configurable template function patterns
  • Add semanticTokens configuration to LanguageServerConfiguration
  • Update SpecialContextVisitor to detect configurable method calls (globalMethodCall, callStatement, complexIdentifier)
  • Update StringSemanticTokensSupplier to inject configuration and pass patterns to visitor
  • Update JSON schema with new configuration section
  • Add unit tests for the new functionality
  • Run full test suite
  • Run code review and address feedback
  • Run CodeQL security check
  • Keep only documented BSL methods in defaults
  • Add local call methods (both Russian and English)
  • Add event listener for configuration updates
  • Move ParsedStrTemplateMethods to separate class
  • Add getParsedStrTemplateMethods() method to SemanticTokensOptions
  • Clean up unnecessary null checks
  • Refactor test file to use SemanticTokensTestHelper
  • Fix imports in SemanticTokensOptions
  • Rewrite ALL tests to use ExpectedToken pattern with helper.assertContainsTokens()
  • Add tests for case-insensitive method name matching (uppercase, mixed case)
  • Implement setter-based caching for ParsedStrTemplateMethods
  • Add volatile for thread safety in StringSemanticTokensSupplier
  • Add SemanticTokensOptionsTest with comprehensive tests
  • Add SemanticTokensOptions tests to LanguageServerConfigurationTest
  • Initialize parsedStrTemplateMethods field directly to avoid null check
Original prompt

Раскрашивать строку внутри вызова функции СтроковыеФункцииКлиентСервер.ПодставитьПараметрыВСтроку так же, как СтрШаблон. Имя функции вынести в конфигурацию по аналогии с references.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Comment @coderabbitai help to get the list of available commands and usage tips.

@nixel2007
Copy link
Member

/buildJar

Copilot AI changed the title [WIP] Refactor parameter insertion in string function Add configurable template function highlighting for semantic tokens Dec 29, 2025
@github-actions
Copy link
Contributor

✅ Собраны JAR-файлы для этого PR по команде /buildJar.

Артефакт: 4982938577

Файлы внутри:

  • bsl-language-server-copilot-refactor-string-function-parameters-0c6881a-exec.jar

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

Test Results

 2 799 files  ±  0   2 799 suites  ±0   52m 32s ⏱️ - 1m 47s
 1 141 tests + 13   1 141 ✅ + 13  0 💤 ±0  0 ❌ ±0 
10 269 runs  +117  10 269 ✅ +117  0 💤 ±0  0 ❌ ±0 

Results for commit e8e067d. ± Comparison against base commit 1cb9cc0.

This pull request removes 8 and adds 17 tests. Note that renamed tests count towards both.
#, count=1
, count=0
, count=1
A, count=1
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [2] content=
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [6] content=
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [7] content=#
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [8] content=
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [2] content=
, count=0
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [6] content=
A, count=1
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [7] content=#
, count=1
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [8] content=
#, count=1
com.github._1c_syntax.bsl.languageserver.semantictokens.StringSemanticTokensSupplierTest ‑ testEnglishSubstituteParametersToStringUpperCase()
com.github._1c_syntax.bsl.languageserver.semantictokens.StringSemanticTokensSupplierTest ‑ testModuleMethodCallMixedCase()
com.github._1c_syntax.bsl.languageserver.semantictokens.StringSemanticTokensSupplierTest ‑ testModuleMethodCallUpperCase()
com.github._1c_syntax.bsl.languageserver.semantictokens.StringSemanticTokensSupplierTest ‑ testNStrUpperCase()
com.github._1c_syntax.bsl.languageserver.semantictokens.StringSemanticTokensSupplierTest ‑ testNStrWithSubstituteParametersToString()
com.github._1c_syntax.bsl.languageserver.semantictokens.StringSemanticTokensSupplierTest ‑ testStrTemplateMixedCase()
…

♻️ This comment has been updated with latest results.

@nixel2007
Copy link
Member

/buildJar

@github-actions
Copy link
Contributor

✅ Собраны JAR-файлы для этого PR по команде /buildJar.

Артефакт: 4986348433

Файлы внутри:

  • bsl-language-server-copilot-refactor-string-function-parameters-b564116-exec.jar

var localMethods = new HashSet<String>();
var moduleMethodPairs = new HashMap<String, Set<String>>();

if (strTemplateMethods == null) {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot почисти код от null. тут не может быть null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Убрал проверки на null, логика парсинга перенесена в SemanticTokensOptions.getParsedStrTemplateMethods() (359b714).

@nixel2007
Copy link
Member

@copilot добавь тесты на вызов этих методов в другом регистре. Оно должно корректно работать и раскрашивать строки

Copy link
Contributor Author

Copilot AI commented Dec 30, 2025

@copilot перепиши ВСЕ тесты в тестовом файле на использование хелпера и ExpectedToken

Переписал все тесты на использование ExpectedToken и методов helper.assertContainsTokens() (c003a24). Теперь все тесты используют единый паттерн как в других сапплаерах.

Copy link
Contributor Author

Copilot AI commented Dec 30, 2025

@copilot добавь тесты на вызов этих методов в другом регистре. Оно должно корректно работать и раскрашивать стро�...

Добавил тесты на вызовы методов в разном регистре: СТРШАБЛОН, стрШаблон, НСТР, ПОДСТАВИТЬПАРАМЕТРЫВСТРОКУ, СТРОКОВЫЕФУНКЦИИКЛИЕНТСЕРВЕР.ПОДСТАВИТЬПАРАМЕТРЫВСТРОКУ и т.д. Все корректно работают благодаря toLowerCase(Locale.ENGLISH) в SpecialContextVisitor (e8e067d).

@nixel2007 nixel2007 marked this pull request as ready for review December 30, 2025 09:17
Copilot AI review requested due to automatic review settings December 30, 2025 09:17
@nixel2007 nixel2007 enabled auto-merge December 30, 2025 09:17
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 adds configurable template function highlighting for semantic tokens, enabling users to specify custom string template functions (like СтроковыеФункцииКлиентСервер.ПодставитьПараметрыВСтроку) that should have placeholder highlighting similar to the built-in СтрШаблон/StrTemplate function.

Key Changes:

  • Introduced new configuration option semanticTokens.strTemplateMethods to specify custom template functions with default support for BSL (Библиотека стандартных подсистем) functions
  • Extended SpecialContextVisitor to detect configurable method calls including local calls, module method calls (both in statements and expressions), with case-insensitive matching
  • Implemented event-driven configuration updates with @EventListener to react to configuration changes

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
StringSemanticTokensSupplierTest.java Comprehensive test coverage refactored to use SemanticTokensTestHelper, including tests for configurable template functions with various call patterns and case variations
schema.json Added JSON schema definition for new semanticTokens configuration section with strTemplateMethods array property
SpecialContextVisitor.java Extended visitor to detect configurable template function calls in three contexts (global, call statement, complex identifier) with case-insensitive method name matching
StringSemanticTokensSupplier.java Integrated configuration injection, added event listener for configuration updates, and initialization logic to cache parsed method patterns
SemanticTokensOptions.java New configuration class defining the strTemplateMethods property with default BSL function patterns and parsing logic to separate local/module methods
ParsedStrTemplateMethods.java Record class to hold pre-parsed method patterns for efficient lookup (local methods set and module-to-methods map)
package-info.java Package documentation for the new semantictokens configuration package
LanguageServerConfiguration.java Integrated SemanticTokensOptions into main configuration with property copying for configuration updates

Comment on lines +106 to +108
@JsonProperty("semanticTokens")
@Setter(value = AccessLevel.NONE)
private SemanticTokensOptions semanticTokensOptions = new SemanticTokensOptions();
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The LanguageServerConfigurationTest should be updated to include verification that SemanticTokensOptions is properly initialized and configured. Similar to how InlayHintOptions and CodeLensOptions are tested in testPartialInitialization(), add assertions to verify that the new semanticTokensOptions field is correctly loaded from configuration files and has appropriate defaults.

Copilot uses AI. Check for mistakes.
private final SemanticTokensHelper helper;
private final LanguageServerConfiguration configuration;

private ParsedStrTemplateMethods parsedStrTemplateMethods;
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The field parsedStrTemplateMethods can be accessed concurrently from multiple threads (via getSemanticTokens()) while being updated by the event handler (handleEvent()), which could lead to race conditions or visibility issues. Consider making this field volatile to ensure thread-safe visibility of updates, or use a proper synchronization mechanism.

Suggested change
private ParsedStrTemplateMethods parsedStrTemplateMethods;
private volatile ParsedStrTemplateMethods parsedStrTemplateMethods;

Copilot uses AI. Check for mistakes.
@nixel2007
Copy link
Member

@copilot отработай замечания по отсутствию тестов. И реализуй расчёт распарсенных методов через setter, как было предложено.

auto-merge was automatically disabled December 30, 2025 09:49

Head branch was pushed to by a user without write access

Copy link
Contributor Author

Copilot AI commented Dec 30, 2025

@copilot отработай замечания по отсутствию тестов. И реализуй расчёт распарсенных методов через setter, как было пр�...

Добавил setter-based caching для ParsedStrTemplateMethods, volatile для потокобезопасности, и новые тесты: SemanticTokensOptionsTest с 8 тестами и тесты в LanguageServerConfigurationTest.testPartialInitialization() (bc8faac).

@nixel2007 nixel2007 enabled auto-merge December 30, 2025 10:13
@nixel2007 nixel2007 merged commit e5b5781 into develop Dec 30, 2025
39 checks passed
@nixel2007 nixel2007 deleted the copilot/refactor-string-function-parameters branch December 30, 2025 10:27
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