Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 21, 2025

  • Create NStrAndStrTemplateSemanticTokensSupplier to add semantic highlighting for NStr/НСтр and StrTemplate/СтрШаблон
    • Detect calls to NStr/НСтр and highlight language keys (ru=, en=) in string parameters
    • Detect calls to StrTemplate/СтрШаблон and highlight placeholders (%1, %2, %(1)) in string parameters
  • Add tests for the new semantic tokens supplier (10 test cases)
  • Verify the implementation with existing tests (all semantic tokens tests pass)
  • Run code review and security checks (no security issues found)
  • Refactor to use MultilingualStringAnalyser instead of duplicating patterns

Summary

This PR implements semantic syntax highlighting for NStr/НСтр and StrTemplate/СтрШаблон function calls:

NStr/НСтр Highlighting

Language keys in multilingual strings are highlighted as Property:

НСтр("ru='Привет'; en='Hello'")  // 'ru' and 'en' are highlighted

StrTemplate/СтрШаблон Highlighting

Placeholders in template strings are highlighted as Parameter:

СтрШаблон("Имя: %1, Версия: %2", Имя, Версия)  // '%1' and '%2' are highlighted

Implementation

Extended MultilingualStringAnalyser with:

  • Public static patterns for method detection and placeholder matching
  • Static utility methods: isNStrCall(), isStrTemplateCall(), findLanguageKeyPositions(), findPlaceholderPositions()
  • MatchPosition record for returning position information

The implementation follows the existing patterns in the codebase and reuses the MultilingualStringAnalyser as requested.

Original prompt

This section details on the original issue you should resolve

<issue_title>Раскраска Нстр и СтрШаблон</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 21, 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.


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

Implement NStrAndStrTemplateSemanticTokensSupplier to highlight:
- Language keys (ru=, en=) in NStr/НСтр function calls
- Placeholders (%1, %2, %(1)) in StrTemplate/СтрШаблон function calls

Co-authored-by: nixel2007 <[email protected]>
Copilot AI changed the title [WIP] Resolve coloring issue for Nstr and StrShablon Add semantic highlighting for NStr and StrTemplate functions Dec 21, 2025
Copilot AI requested a review from nixel2007 December 21, 2025 10:29
*/
@Component
@RequiredArgsConstructor
public class NStrAndStrTemplateSemanticTokensSupplier implements SemanticTokensSupplier {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot используй MultilingualStringAnalyser. Расширь его при необходимости

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored to use MultilingualStringAnalyser. Extended it with:

  • isNStrCall() and isStrTemplateCall() static methods
  • findLanguageKeyPositions() and findPlaceholderPositions() static methods
  • MatchPosition record for position info
  • STR_TEMPLATE_PLACEHOLDER_PATTERN (same pattern as in IncorrectUseOfStrTemplateDiagnostic)

Commit: 5c618ee

…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 <[email protected]>
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