-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
fix: OOB in JDTCommentBuilder #2840
Conversation
LGTM. @pvojtechovsky do you merge? |
SourcePosition elsePosition = elseStatement.getPosition().isValidPosition() ? elseStatement.getPosition() : elseExpression.getPosition(); | ||
SourcePosition thenPosition = thenStatement.getPosition(); | ||
if (!thenPosition.isValidPosition()) { | ||
CtStatement thenExpression = ((CtBlock) thenStatement).getStatement(0); |
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.
thenStatement isn't always CtBlock in this context.
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.
Ok, I see, but it's exactly the way the original code was written (I did not really want to change it):
SourcePosition thenPosition = e.getThenStatement().getPosition().isValidPosition() == false ? ((CtBlock) e.getThenStatement()).getStatement(0).getPosition() : e.getThenStatement().getPosition();
SourcePosition elsePosition = e.getElseStatement().getPosition().isValidPosition() == false ? ((CtBlock) e.getElseStatement()).getStatement(0).getPosition() : e.getElseStatement().getPosition();
Would you like me to add an additional check like thenStatement instanceof CtBlock
?
I see that it is same code like before. I suggest to write it correctly, when we are already touching it.
yes please |
Thank you @Egor18 |
I think that refactoring of JDTCommentBuilder in #2822 did not go so well :|
This PR is to fix IndexOutOfBoundsException during model build for the following code: