-
Notifications
You must be signed in to change notification settings - Fork 121
Fix NullPointerException in DeletingCollectionItemDiagnostic for incomplete forEach statements #3738
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
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
…mplete forEach statements Co-authored-by: nixel2007 <[email protected]>
...m/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java
Outdated
Show resolved
Hide resolved
...m/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java
Outdated
Show resolved
Hide resolved
…tCode pattern Co-authored-by: nixel2007 <[email protected]>
|
/buildJar |
|
✅ Собраны JAR-файлы для этого PR по команде Артефакт: 5034073540 Файлы внутри:
|
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 that occurs in DeletingCollectionItemDiagnostic when developers type incomplete forEach statements like "Для Каждого" (For each) without an expression. The issue happened because the code attempted to call getText() on a null expression context.
Key Changes:
- Added null check for
ctx.expression()before accessing it - Added regression test to verify incomplete forEach statements don't throw exceptions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnostic.java | Added null check and early return when forEach expression is null to prevent NullPointerException |
| src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java | Added regression test using assertThatCode pattern to verify incomplete forEach statements are handled gracefully |
Test Results 2 808 files ±0 2 808 suites ±0 51m 24s ⏱️ +31s Results for commit 68c53c9. ± Comparison against base commit 6acf373. This pull request removes 8 and adds 5 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Plan to Fix NullPointerException in DeletingCollectionItemDiagnostic
Issue
NullPointerException occurs when typing incomplete forEach statements like "Для каждого " (For each) because
ctx.expression()returns null when the expression part is missing.Checklist
ctx.expression()invisitForEachStatementmethodSummary
Successfully fixed the NullPointerException by adding a null check before accessing
ctx.expression(). The diagnostic now gracefully handles incomplete forEach statements during code editing. All tests pass and no security vulnerabilities were introduced.Review Feedback Addressed
\s) from test stringassertThatCode(() -> getDiagnostics(documentContext)).doesNotThrowAnyException()pattern to explicitly verify no exception is thrownOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.