Skip to content

Fix CommentInserter crash on compact classes#4963

Merged
johannescoetzee merged 1 commit into
javaparser:masterfrom
johannescoetzee:johannes/fix-comment-inserter
Jan 28, 2026
Merged

Fix CommentInserter crash on compact classes#4963
johannescoetzee merged 1 commit into
javaparser:masterfrom
johannescoetzee:johannes/fix-comment-inserter

Conversation

@johannescoetzee

Copy link
Copy Markdown
Collaborator

Fixes #4961.

The crash was caused by the CommentInserter attempting to attribute a comment to a node without a range which is now possible for compact classes (the SimpleName child of the compact class was the specific one causing the crash reported).

@johannescoetzee johannescoetzee added the PR: Fixed A PR that offers a fix or correction label Jan 28, 2026
@johannescoetzee johannescoetzee added this to the next release milestone Jan 28, 2026
@codecov

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.661%. Comparing base (2146cfc) to head (024961e).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #4963       +/-   ##
===============================================
+ Coverage     58.657%   58.661%   +0.003%     
  Complexity      2564      2564               
===============================================
  Files            699       699               
  Lines          40121     40122        +1     
  Branches        7314      7315        +1     
===============================================
+ Hits           23534     23536        +2     
  Misses         13620     13620               
+ Partials        2967      2966        -1     
Flag Coverage Δ
AlsoSlowTests 58.661% <100.000%> (+0.003%) ⬆️
javaparser-core 58.661% <100.000%> (+0.003%) ⬆️
javaparser-symbol-solver 58.661% <100.000%> (+0.003%) ⬆️
jdk-10 58.232% <100.000%> (+0.006%) ⬆️
jdk-11 58.229% <100.000%> (+0.001%) ⬆️
jdk-12 58.231% <100.000%> (+0.003%) ⬆️
jdk-13 58.231% <100.000%> (+0.003%) ⬆️
jdk-14 58.463% <100.000%> (+0.003%) ⬆️
jdk-15 58.461% <100.000%> (+0.001%) ⬆️
jdk-16 58.438% <100.000%> (+0.003%) ⬆️
jdk-17 58.588% <100.000%> (+0.003%) ⬆️
jdk-18 58.588% <100.000%> (+0.003%) ⬆️
jdk-8 58.068% <100.000%> (+0.006%) ⬆️
jdk-9 58.230% <100.000%> (+0.006%) ⬆️
macos-latest 58.636% <100.000%> (+0.003%) ⬆️
ubuntu-latest 58.631% <100.000%> (+0.003%) ⬆️
windows-latest 58.643% <100.000%> (+0.003%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...n/java/com/github/javaparser/CommentsInserter.java 89.108% <100.000%> (+0.220%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e42de1a...024961e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johannescoetzee

Copy link
Copy Markdown
Collaborator Author

@jlerbsc Do you agree with this fix? I can't think of any situations where just skipping nodes without a range is a problem (especially since they just result in a crash later), but there could be cases where this could hide some sort of bug

@jlerbsc

jlerbsc commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

@jlerbsc Do you agree with this fix? I can't think of any situations where just skipping nodes without a range is a problem (especially since they just result in a crash later), but there could be cases where this could hide some sort of bug

All tests are running, including the new ones, so I think the fix is appropriate.

@johannescoetzee

Copy link
Copy Markdown
Collaborator Author

OK great, I'll merge it then

@johannescoetzee johannescoetzee merged commit 3dc8e77 into javaparser:master Jan 28, 2026
35 checks passed
@johannescoetzee johannescoetzee deleted the johannes/fix-comment-inserter branch January 28, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java 25 file parse error

2 participants