Add semantic highlighting for NStr and StrTemplate functions#3697
Add semantic highlighting for NStr and StrTemplate functions#3697
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 |
Implement NStrAndStrTemplateSemanticTokensSupplier to highlight: - Language keys (ru=, en=) in NStr/НСтр function calls - Placeholders (%1, %2, %(1)) in StrTemplate/СтрШаблон function calls Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
...b/_1c_syntax/bsl/languageserver/semantictokens/NStrAndStrTemplateSemanticTokensSupplier.java
Outdated
Show resolved
Hide resolved
…ighting - Extended MultilingualStringAnalyser with public patterns and utility methods: - isNStrCall() and isStrTemplateCall() static methods - findLanguageKeyPositions() and findPlaceholderPositions() static methods - MatchPosition record for position information - STR_TEMPLATE_PLACEHOLDER_PATTERN for placeholder detection - Updated NStrAndStrTemplateSemanticTokensSupplier to use MultilingualStringAnalyser - Removed duplicate patterns from semantic tokens supplier Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Test Results2 781 files ± 0 2 781 suites ±0 48m 0s ⏱️ +48s Results for commit 4e47072. ± Comparison against base commit 50382d6. This pull request removes 14 and adds 27 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
@copilot почему проект перестал собираться? как починить? |
Fixed. The issue was incorrect Commit: a783cb5 |
|
/buildJar |
|
✅ Собраны JAR-файлы для этого PR по команде Артефакт: 4969848801 Файлы внутри:
|
|
@copilot посмотри, почему тесты падают. |
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
The test failures were caused by optimizations I made to |
|
@copilot эй! Верни свои оптимизации. Откати только изменения в getVariableSymbol |
… unchanged - Added getSymbolAtPosition() method to SymbolTree for hierarchical symbol lookup - Restored ReferenceIndex.getFromSymbol() optimization to use getSymbolAtPosition() - Kept getVariableSymbol(ParserRuleContext) using original range-based lookup to avoid test failures Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Restored the ReferenceIndex optimization ( |
|
/buildJar |
|
✅ Собраны JAR-файлы для этого PR по команде Артефакт: 4970441063 Файлы внутри:
|
There was a problem hiding this comment.
Pull request overview
This PR implements semantic highlighting for NStr (multilingual strings) and StrTemplate (string templates) functions in the BSL Language Server. The implementation consolidates string-related semantic token processing into a new StringSemanticTokensSupplier that handles regular strings, NStr language keys, StrTemplate placeholders, and SDBL query strings.
Key changes:
- Created a centralized string token processing system that detects and highlights language keys (e.g.,
ru=,en=) in NStr calls and placeholders (e.g.,%1,%(2)) in StrTemplate calls - Refactored query token processing from a separate supplier into the string supplier for better cohesion
- Added support for detecting templates stored in variables before being used in StrTemplate calls
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
StringSemanticTokensSupplier.java |
New centralized supplier for all string-related semantic tokens including NStr, StrTemplate, and SDBL queries |
SpecialContextVisitor.java |
Visitor that detects NStr and StrTemplate calls, including variable assignments used as templates |
SdblAstTokenCollector.java |
Visitor for collecting AST-based token overrides for SDBL queries |
SdblTokenTypes.java |
Utility class for mapping SDBL lexer tokens to semantic token types |
MultilingualStringAnalyser.java |
Enhanced with public methods for finding language keys and placeholders, pattern matching changed from find() to matches() |
SymbolsSemanticTokensSupplier.java |
Simplified variable reference handling by removing redundant ReferenceResolver usage |
LexicalSemanticTokensSupplier.java |
Removed string token processing (delegated to StringSemanticTokensSupplier) |
ReferenceIndex.java |
Optimized getFromSymbol() using new SymbolTree.getSymbolAtPosition() method |
SymbolTree.java |
Added getSymbolAtPosition() method for hierarchical symbol lookup |
StringSemanticTokensSupplierTest.java |
Comprehensive test suite with 27 test cases covering all scenarios |
| Supporting classes | New record classes for data structures (StringContext, SubToken, TokenPosition, etc.) |
QuerySemanticTokensSupplier.java |
Deleted (functionality consolidated into StringSemanticTokensSupplier) |
QuerySemanticTokensSupplierTest.java |
Deleted (tests moved to StringSemanticTokensSupplierTest) |
|




NStrAndStrTemplateSemanticTokensSupplierto add semantic highlighting for NStr/НСтр and StrTemplate/СтрШаблонMultilingualStringAnalyserinstead of duplicating patternsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.