feat: модификатор async для объявлений и вызовов методов#3947
Conversation
Поле async добавлено в AbstractMethodSymbol (помещается в существующий 1-байтовый padding-gap layout'a, размер объекта не растёт — проверено JOL), заполняется в MethodSymbolComputer из declaration.ASYNC_KEYWORD(). isAsync() будет использоваться семантическими токенами как источник истины — без повторного спуска в parse tree. Co-Authored-By: Claude Opus 4.7 <[email protected]>
В легенду добавлен SemanticTokenModifiers.Async. Объявления async-методов получают модификатор Async (комбинируется со Static у методов «статических» модулей: CommonModule / ManagerModule / OScript-module). Сайт вызова async-метода тоже помечается Async (через MethodSymbol.isAsync на разрешённой ссылке) — независимо от того, является ли владелец «статическим». Co-Authored-By: Claude Opus 4.7 <[email protected]>
📝 WalkthroughWalkthroughDetect ASYNC in function/procedure declarations, store async on method symbols, advertise Async in the semantic token legend, and emit Async modifiers for method declarations and call sites. Tests added/updated for both declarations and call-site tokens. ChangesAsync method semantic token support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java (1)
148-200: ⚡ Quick winAdd one test for combined
Static + Asyncdeclaration modifiers.Async-only and static-only are covered, but the declared behavior allows both modifiers together. Add a targeted assertion to lock this contract and prevent regressions in modifier composition.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java` around lines 148 - 200, Add a new unit test (e.g., testStaticAndAsyncModifiersOnDeclaration) that constructs a BSL snippet with both Static and Async modifiers (for both a function and/or procedure variant), call helper.getDecodedTokens(bsl, supplier), and assert via helper.assertContainsTokens that the declared symbol (use ExpectedToken) is emitted with Set.of(SemanticTokenModifiers.Static, SemanticTokenModifiers.Async) and the correct SemanticTokenTypes.Function or SemanticTokenTypes.Method and the expected identifier text; reference helper.getDecodedTokens, ExpectedToken, SemanticTokenModifiers.Static, SemanticTokenModifiers.Async, SemanticTokenTypes.Function/SemanticTokenTypes.Method and helper.assertContainsTokens to locate relevant code paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java`:
- Around line 148-200: Add a new unit test (e.g.,
testStaticAndAsyncModifiersOnDeclaration) that constructs a BSL snippet with
both Static and Async modifiers (for both a function and/or procedure variant),
call helper.getDecodedTokens(bsl, supplier), and assert via
helper.assertContainsTokens that the declared symbol (use ExpectedToken) is
emitted with Set.of(SemanticTokenModifiers.Static, SemanticTokenModifiers.Async)
and the correct SemanticTokenTypes.Function or SemanticTokenTypes.Method and the
expected identifier text; reference helper.getDecodedTokens, ExpectedToken,
SemanticTokenModifiers.Static, SemanticTokenModifiers.Async,
SemanticTokenTypes.Function/SemanticTokenTypes.Method and
helper.assertContainsTokens to locate relevant code paths.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 47311c43-3659-4077-966e-d30330569123
📒 Files selected for processing (9)
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractMethodSymbol.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SemanticTokensLegendConfiguration.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.javasrc/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.javasrc/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplierTest.javasrc/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java
- Массивы модификаторов вынесены в статик-поля обоих suppliers (NO/ASYNC/STATIC/STATIC_ASYNC) — без аллокации на каждый токен. - Удалены лишние подробности из javadoc MethodSymbol.isAsync. Co-Authored-By: Claude Opus 4.7 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java (1)
49-55: ⚖️ Poor tradeoffConsider extracting duplicated modifier constants to a shared utility.
The four modifier array constants (
NO_MODIFIERS,ASYNC_MODIFIERS,STATIC_MODIFIERS,STATIC_ASYNC_MODIFIERS) and the helper method logic are duplicated betweenSymbolsSemanticTokensSupplierandMethodCallSemanticTokensSupplier. Extracting them toSemanticTokensHelperor a new utility class would eliminate the duplication.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java` around lines 49 - 55, Extract the duplicated modifier constants and helper logic into a new utility class (e.g., SemanticTokensHelper) and replace the arrays and helper usages in both SymbolsSemanticTokensSupplier and MethodCallSemanticTokensSupplier with references to the new class; specifically move NO_MODIFIERS, ASYNC_MODIFIERS, STATIC_MODIFIERS, STATIC_ASYNC_MODIFIERS and any helper method that builds or selects modifier arrays from SymbolsSemanticTokensSupplier and MethodCallSemanticTokensSupplier into SemanticTokensHelper, make them public/static, and update the callers in both classes to use SemanticTokensHelper.NO_MODIFIERS, SemanticTokensHelper.ASYNC_MODIFIERS, etc., ensuring imports and visibility are adjusted accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java`:
- Around line 49-55: Extract the duplicated modifier constants and helper logic
into a new utility class (e.g., SemanticTokensHelper) and replace the arrays and
helper usages in both SymbolsSemanticTokensSupplier and
MethodCallSemanticTokensSupplier with references to the new class; specifically
move NO_MODIFIERS, ASYNC_MODIFIERS, STATIC_MODIFIERS, STATIC_ASYNC_MODIFIERS and
any helper method that builds or selects modifier arrays from
SymbolsSemanticTokensSupplier and MethodCallSemanticTokensSupplier into
SemanticTokensHelper, make them public/static, and update the callers in both
classes to use SemanticTokensHelper.NO_MODIFIERS,
SemanticTokensHelper.ASYNC_MODIFIERS, etc., ensuring imports and visibility are
adjusted accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d3bddfdc-202b-4656-ae47-8ed8c32a00f5
📒 Files selected for processing (3)
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.javasrc/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
💤 Files with no reviewable changes (1)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java
|
Test Results 2 868 files 2 868 suites 1h 13m 23s ⏱️ Results for commit 6e057ab. |


Summary
MethodSymbol.isAsync()— флагАсинхтеперь часть модели метода (AbstractMethodSymbol), заполняется вMethodSymbolComputerизdeclaration.ASYNC_KEYWORD(). По object layout добавление бесплатно: новоеbooleanполе садится в существующий 1-байтовый padding-gap (HotSpot 25, compressed oops + compressed klass, 8-byte align — проверено JOL), размер объекта 80 → 80 байт.SemanticTokenModifiers.Async.SymbolsSemanticTokensSupplierпомечает имяАсинх-метода в декларации модификаторомasync(комбинируется соstaticдля CommonModule / ManagerModule / OScript-module).MethodCallSemanticTokensSupplierпомечает имя в сайте вызоваАсинх-метода модификаторомasync— черезmethodSymbol.isAsync()у разрешённой ссылки, без повторного спуска в parse tree.staticиasyncмогут комбинироваться.Test plan
MethodSymbolComputerTest: новыйtestNonAsyncMethodHasNoAsyncFlag+ расширены существующие async-тесты проверкамиisAsync()SymbolsSemanticTokensSupplierTest:testAsyncModifierOnAsyncFunctionDeclaration,testAsyncModifierOnAsyncProcedureDeclaration,testAsyncModifierAbsentOnRegularMethodMethodCallSemanticTokensSupplierTest:testAsyncModifierOnCallToAsyncMethod,testAsyncModifierAbsentOnCallToRegularMethod./gradlew test --tests "*.semantictokens.*" --tests "*.SemanticTokensProviderTest"— зелёно🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests