-
Notifications
You must be signed in to change notification settings - Fork 111
fix: handle null code blocks in loops #3465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a NullPointerException in the loop subgraph builder by adding a null check for the CodeBlockContext. Key changes include:
- Adding a test case that simulates a loop with a null code block.
- Modifying the visitCodeBlock method to return immediately if the context is null.
- Annotating the buildLoopSubgraph method’s ctx parameter with @nullable to explicitly indicate its nullability.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/test/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphBuilderTest.java | Added test case ensuring loops can be processed even with a null CodeBlockContext. |
src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgBuildingParseTreeVisitor.java | Added null-check logic in visitCodeBlock and annotated buildLoopSubgraph’s ctx parameter with @nullable. |
|
var children = forStatement.children; | ||
|
||
// Find and remove the CodeBlockContext child | ||
for (int i = 0; i < children.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А как без шаманства с нодами, чисто с помощью bsl получить нулл вместо код-блока?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно какую-то фигню пустить на вход, которая обычно случается при наборе кода. Я могу попробовать подобрать кусок кода, который бы сломал парсер, но это зависимость теста на поведение конкретной версии парсера. А так тест проверяет уже конечный сломанный результат
👋 Hi there! This PR was automatically generated by Autofix 🤖
This fix was triggered by Nikita Fedkin.
Fixes BSL-LANGUAGE-SERVER-CE. The issue was that:
buildLoopSubgraph
method lacks a null check for theCodeBlockContext
, causing a NullPointerException when processing malformedfor
statements.buildLoopSubgraph
method to handle nullCodeBlockContext
.@Nullable
annotation to thectx
parameter inbuildLoopSubgraph
method.If you have any questions or feedback for the Sentry team about this fix, please email [email protected] with the Run ID: 31331.