Skip to content

fix(symbols): описание и параметры асинхронных методов#3946

Merged
nixel2007 merged 3 commits into
developfrom
fix/async-method-description
May 26, 2026
Merged

fix(symbols): описание и параметры асинхронных методов#3946
nixel2007 merged 3 commits into
developfrom
fix/async-method-description

Conversation

@nixel2007
Copy link
Copy Markdown
Member

@nixel2007 nixel2007 commented May 26, 2026

Summary

  • Для методов с Асинх (например, Асинх Функция Foo()) не парсился MethodDescription: поиск комментариев в Trees.getComments шёл назад от FUNCTION_KEYWORD/PROCEDURE_KEYWORD и обрывался на пробеле между Асинх и ключевым словом (Trees.isBlankLine трактует WHITE_SPACE на той же строке как пустую). Из-за этого пропадало описание метода, описания параметров в hover и блок описания в semantic tokens.
  • В MethodSymbolComputer.visitFunction / visitProcedure стартовый токен для поиска комментариев теперь ASYNC_KEYWORD, если он есть; начало range символа метода также сдвигается на Асинх, когда нет аннотаций.

Test plan

  • Новые тесты MethodSymbolComputerTest#testAsyncFunctionDescription и #testAsyncProcedureDescription (сначала падали, после фикса — зелёные)
  • ./gradlew test --tests "...MethodSymbolComputerTest" — зелёно
  • Прогон смежных тестов (context.computer.*, hover.*, semantictokens.*, SemanticTokensProviderTest, HoverProviderTest) — зелёно

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection and symbol computation for async functions and procedures, ensuring method range starts account for async keyword, annotations, and compiler directives.
  • Tests

    • Added tests verifying symbol metadata, method/parameter descriptions, annotation recognition, compiler-directive handling, and correct method range computation for async declarations.

Review Change Stack

Copilot AI review requested due to automatic review settings May 26, 2026 10:40
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ecad97f0-7c43-4c4d-a8ad-c4b580140f39

📥 Commits

Reviewing files that changed from the base of the PR and between a4b6c54 and afccaa5.

📒 Files selected for processing (2)
  • 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

📝 Walkthrough

Walkthrough

MethodSymbolComputer centralizes range-start selection into selectStartNode(...); visitFunction and visitProcedure now prefer ASYNC_KEYWORD as startOfMethod when present (or annotation marker), and the chosen token is passed into createMethodSymbol. New tests cover async functions/procedures, annotations, and compiler directives.

Changes

ASYNC Symbol Detection

Layer / File(s) Summary
Start node selection helper
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java
Adds selectStartNode(...) to choose the method range start from the first annotation & marker, ASYNC_KEYWORD, or the function/procedure keyword.
visitFunction: async-aware startOfMethod
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java
visitFunction uses selectStartNode, derives startOfMethod from ASYNC_KEYWORD when present, and passes it to createMethodSymbol.
visitProcedure: async-aware startOfMethod
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java
visitProcedure mirrors the function changes: uses selectStartNode, prefers ASYNC_KEYWORD for startOfMethod, and forwards it to createMethodSymbol.
Tests for async methods and annotations
src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java
Adds four tests: testAsyncFunctionDescription, testAsyncProcedureDescription, testAsyncMethodWithAnnotation, and testAsyncMethodWithCompilerDirective validating names, descriptions, parameter docs, annotation counts, compiler directive kind, and computed method ranges.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 1c-syntax/bsl-language-server#3359: Both PRs update MethodSymbolComputer's method-start computation to begin at annotation markers and thread start tokens into createMethodSymbol.

Poem

🐰 I hopped through tokens, async and bright,

Picked annotations, then ASYNC for light,
Functions and procedures now start just right,
Tests bobbed along in joyful sight,
A carrot-shaped commit — code takes flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% 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 PR title directly addresses the main change: fixing method descriptions and parameters for async methods (асинхронных методов), which matches the core fix in MethodSymbolComputer.
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 fix/async-method-description

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@nixel2007 nixel2007 enabled auto-merge May 26, 2026 10:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Исправление парсинга описания и параметров для асинхронных методов (Асинх Функция/Процедура) за счёт корректного выбора стартового токена при поиске doc-комментариев и расширения range символа метода на Асинх (когда нет аннотаций).

Changes:

  • Изменён стартовый токен для поиска комментариев в visitFunction/visitProcedure: используется ASYNC_KEYWORD, если он присутствует.
  • Скорректировано начало range метода: при отсутствии аннотаций начало сдвигается на Асинх.
  • Добавлены тесты, покрывающие описания/параметры для асинхронной функции и процедуры.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java Выбор ASYNC_KEYWORD как стартового токена и сдвиг range на Асинх для корректного извлечения doc-комментариев
src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java Добавлены тесты на наличие описания и описаний параметров для Асинх Функция/Процедура

Comment on lines 104 to 108
if (!declaration.annotation().isEmpty()) {
startNode = declaration.annotation().getFirst().AMPERSAND();
} else if (asyncKeyword != null) {
startNode = asyncKeyword;
}
Comment on lines 146 to 150
if (!declaration.annotation().isEmpty()) {
startNode = declaration.annotation().getFirst().AMPERSAND();
} else if (asyncKeyword != null) {
startNode = asyncKeyword;
}
nixel2007 and others added 2 commits May 26, 2026 13:02
Для методов с ключевым словом Асинх (например, `Асинх Функция Foo()`)
не парсился MethodDescription: поиск комментариев шёл от FUNCTION_KEYWORD
назад и прерывался на пробеле между Асинх и Функция (Trees.isBlankLine
трактует WHITE_SPACE на той же строке как пустую). Из-за этого пропадало
описание метода, описания параметров в hover, и блок описания не
попадал в semantic tokens.

Чиним: если у декларации есть ASYNC_KEYWORD, используем его как стартовый
токен для поиска комментариев и сдвигаем начало range символа метода на
этот же токен.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Замечания PR #3946:
- Выбор startNode переписан как самостоятельный helper selectStartNode
  с явной цепочкой приоритетов «аннотация → Асинх → ключевое слово»
  и комментарием о грамматике
  (preprocessor | compilerDirective | annotation)* ASYNC_KEYWORD? PROCEDURE_KEYWORD|FUNCTION_KEYWORD.
- Добавлены тесты для двух непокрытых комбинаций:
  * Асинх + аннотация (&После) — range начинается с AMPERSAND аннотации;
  * Асинх + директива компиляции (&НаКлиенте) — range начинается с Асинх,
    директива не входит в range (исторически).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@nixel2007 nixel2007 force-pushed the fix/async-method-description branch from a4b6c54 to afccaa5 Compare May 26, 2026 11:05
@nixel2007 nixel2007 closed this May 26, 2026
auto-merge was automatically disabled May 26, 2026 11:22

Pull request was closed

@nixel2007 nixel2007 reopened this May 26, 2026
@nixel2007 nixel2007 merged commit 6999d62 into develop May 26, 2026
1 check passed
@nixel2007 nixel2007 deleted the fix/async-method-description branch May 26, 2026 11:23
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