Skip to content

feat: модификатор async для объявлений и вызовов методов#3947

Merged
nixel2007 merged 3 commits into
developfrom
feature/async-method-semantic-tokens
May 26, 2026
Merged

feat: модификатор async для объявлений и вызовов методов#3947
nixel2007 merged 3 commits into
developfrom
feature/async-method-semantic-tokens

Conversation

@nixel2007

@nixel2007 nixel2007 commented May 26, 2026

Copy link
Copy Markdown
Member

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, testAsyncModifierAbsentOnRegularMethod
  • MethodCallSemanticTokensSupplierTest: testAsyncModifierOnCallToAsyncMethod, testAsyncModifierAbsentOnCallToRegularMethod
  • ./gradlew test --tests "*.semantictokens.*" --tests "*.SemanticTokensProviderTest" — зелёно

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Async methods/functions are now tracked and expose an async attribute used by the language server.
    • Semantic tokens now include an Async modifier for declarations and calls, combined with existing Static modifier where applicable.
  • Tests

    • Added tests verifying Async modifier presence on async declarations and call sites, and absence on regular methods.

Review Change Stack

nixel2007 and others added 2 commits May 26, 2026 13:27
Поле 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]>
Copilot AI review requested due to automatic review settings May 26, 2026 12:10
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

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

Changes

Async method semantic token support

Layer / File(s) Summary
Async symbol model contract
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractMethodSymbol.java, src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java
AbstractMethodSymbol adds a new async boolean field; MethodSymbol interface adds isAsync() method to expose async declaration status.
Async detection and symbol propagation
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java, src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java
MethodSymbolComputer#visitFunction and visitProcedure detect ASYNC and pass the boolean through createMethodSymbol(...), which sets .async(async) on ConstructorSymbol and RegularMethodSymbol. Tests verify async flag presence and absence.
Semantic token legend infrastructure
src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SemanticTokensLegendConfiguration.java
Registers SemanticTokenModifiers.Async in the legend to advertise async modifier support.
Async modifier on method declarations
src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java, src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java
SymbolsSemanticTokensSupplier computes Static/Async modifier combinations via methodModifiers(...) and applies them to method declaration tokens; tests validate Async presence/absence.
Async modifier on method calls
src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java, src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplierTest.java
MethodCallSemanticTokensSupplier pattern-matches MethodSymbol references and computes Static/Async modifiers via methodCallModifiers(...) for call-site tokens; tests validate Async presence/absence on calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • 1c-syntax/bsl-language-server#3946: Both PRs adjust async (Асинх) handling in MethodSymbolComputer#visitFunction/visitProcedure, with this PR propagating async state while the related PR refines method description/parameter parsing for async methods.
  • 1c-syntax/bsl-language-server#3945: This PR propagates async flag to constructor/method symbol infrastructure introduced in that PR.
  • 1c-syntax/bsl-language-server#3359: Both PRs extend createMethodSymbol(...) signature and touch the same method-symbol creation path.

Suggested labels

hacktoberfest-accepted

Suggested reviewers

  • theshadowco
  • sfaqer

Poem

🐰 I sniffed the ASYNC in code tonight,

Symbols now glow with a gentle light,
Declarations hum and calls reply,
Асинх flags flutter — oh my, oh my!
The rabbit hops off, semantic delight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding async modifier support for method declarations and calls, which is consistently reflected across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/async-method-semantic-tokens

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java (1)

148-200: ⚡ Quick win

Add one test for combined Static + Async declaration 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6999d62 and 69fa578.

📒 Files selected for processing (9)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractMethodSymbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SemanticTokensLegendConfiguration.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplierTest.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplierTest.java

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@nixel2007 nixel2007 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@claude обратай замечания

- Массивы модификаторов вынесены в статик-поля обоих suppliers
  (NO/ASYNC/STATIC/STATIC_ASYNC) — без аллокации на каждый токен.
- Удалены лишние подробности из javadoc MethodSymbol.isAsync.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/SymbolsSemanticTokensSupplier.java (1)

49-55: ⚖️ Poor tradeoff

Consider 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 between SymbolsSemanticTokensSupplier and MethodCallSemanticTokensSupplier. Extracting them to SemanticTokensHelper or 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

📥 Commits

Reviewing files that changed from the base of the PR and between 69fa578 and 6e057ab.

📒 Files selected for processing (3)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/semantictokens/MethodCallSemanticTokensSupplier.java
  • src/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

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
8.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 868 files   2 868 suites   1h 13m 23s ⏱️
 2 501 tests  2 501 ✅ 0 💤 0 ❌
15 006 runs  15 006 ✅ 0 💤 0 ❌

Results for commit 6e057ab.

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