-
Notifications
You must be signed in to change notification settings - Fork 121
Add configurable template function highlighting for semantic tokens #3714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable template function highlighting for semantic tokens #3714
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit 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 |
Co-authored-by: nixel2007 <[email protected]>
Co-authored-by: nixel2007 <[email protected]>
|
/buildJar |
|
✅ Собраны JAR-файлы для этого PR по команде Артефакт: 4982938577 Файлы внутри:
|
Test Results 2 799 files ± 0 2 799 suites ±0 52m 32s ⏱️ - 1m 47s 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.♻️ This comment has been updated with latest results. |
...github/_1c_syntax/bsl/languageserver/configuration/semantictokens/SemanticTokensOptions.java
Show resolved
Hide resolved
Co-authored-by: nixel2007 <[email protected]>
|
/buildJar |
|
✅ Собраны JAR-файлы для этого PR по команде Артефакт: 4986348433 Файлы внутри:
|
...va/com/github/_1c_syntax/bsl/languageserver/semantictokens/StringSemanticTokensSupplier.java
Outdated
Show resolved
Hide resolved
Co-authored-by: nixel2007 <[email protected]>
...va/com/github/_1c_syntax/bsl/languageserver/semantictokens/StringSemanticTokensSupplier.java
Outdated
Show resolved
Hide resolved
...a/com/github/_1c_syntax/bsl/languageserver/semantictokens/strings/SpecialContextVisitor.java
Outdated
Show resolved
Hide resolved
| var localMethods = new HashSet<String>(); | ||
| var moduleMethodPairs = new HashMap<String, Set<String>>(); | ||
|
|
||
| if (strTemplateMethods == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot почисти код от null. тут не может быть null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Убрал проверки на null, логика парсинга перенесена в SemanticTokensOptions.getParsedStrTemplateMethods() (359b714).
|
@copilot добавь тесты на вызов этих методов в другом регистре. Оно должно корректно работать и раскрашивать строки |
Co-authored-by: nixel2007 <[email protected]>
Co-authored-by: nixel2007 <[email protected]>
Добавил тесты на вызовы методов в разном регистре: СТРШАБЛОН, стрШаблон, НСТР, ПОДСТАВИТЬПАРАМЕТРЫВСТРОКУ, СТРОКОВЫЕФУНКЦИИКЛИЕНТСЕРВЕР.ПОДСТАВИТЬПАРАМЕТРЫВСТРОКУ и т.д. Все корректно работают благодаря |
There was a problem hiding this 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.strTemplateMethodsto specify custom template functions with default support for BSL (Библиотека стандартных подсистем) functions - Extended
SpecialContextVisitorto 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
@EventListenerto 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 |
| @JsonProperty("semanticTokens") | ||
| @Setter(value = AccessLevel.NONE) | ||
| private SemanticTokensOptions semanticTokensOptions = new SemanticTokensOptions(); |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
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.
...va/com/github/_1c_syntax/bsl/languageserver/semantictokens/StringSemanticTokensSupplier.java
Show resolved
Hide resolved
...github/_1c_syntax/bsl/languageserver/configuration/semantictokens/SemanticTokensOptions.java
Show resolved
Hide resolved
| private final SemanticTokensHelper helper; | ||
| private final LanguageServerConfiguration configuration; | ||
|
|
||
| private ParsedStrTemplateMethods parsedStrTemplateMethods; |
Copilot
AI
Dec 30, 2025
There was a problem hiding this comment.
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.
| private ParsedStrTemplateMethods parsedStrTemplateMethods; | |
| private volatile ParsedStrTemplateMethods parsedStrTemplateMethods; |
...github/_1c_syntax/bsl/languageserver/configuration/semantictokens/SemanticTokensOptions.java
Show resolved
Hide resolved
|
@copilot отработай замечания по отсутствию тестов. И реализуй расчёт распарсенных методов через setter, как было предложено. |
Co-authored-by: nixel2007 <[email protected]>
Head branch was pushed to by a user without write access
Добавил setter-based caching для |
...github/_1c_syntax/bsl/languageserver/configuration/semantictokens/SemanticTokensOptions.java
Outdated
Show resolved
Hide resolved
Co-authored-by: nixel2007 <[email protected]>
SemanticTokensOptionsconfiguration class with configurable template function patternssemanticTokensconfiguration toLanguageServerConfigurationSpecialContextVisitorto detect configurable method calls (globalMethodCall, callStatement, complexIdentifier)StringSemanticTokensSupplierto inject configuration and pass patterns to visitorOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.