-
-
Notifications
You must be signed in to change notification settings - Fork 352
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 for a bug concerning multiples comments before a catch block #1074
Conversation
OK for me. @tdurieux (expert of the comment mode), OK for you? |
Don't do the merge right now apparently there is more for issue #1073. I'll
check on it tomorrow.
Le dim. 25 déc. 2016 à 11:05, Martin Monperrus <[email protected]> a
écrit :
… OK for me. @tdurieux <https://github.com/tdurieux> (expert of the comment
mode), OK for you?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1074 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABaOWIz2div8hEobbVl4pwp5MT0Iy0erks5rLj_igaJpZM4LVRCs>
.
|
there are already two fixes here, right?.
we can still do another PR for the rest of #1073 (one PR = one fix).
|
Ok to do another PR for the rest of #1073 then.
Le dim. 25 déc. 2016 à 12:38, Martin Monperrus <[email protected]> a
écrit :
… this is already two fixes here, right?.
we can still do another PR for the rest of #1073 (one PR = one fix).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1074 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABaOWM7JpSPKYwXn0MZFE3VhocalcI1Uks5rLlXIgaJpZM4LVRCs>
.
|
|
||
@Override | ||
public void visitCtCatch(CtCatch e) { | ||
if (comment.getPosition().getLine() <= e.getPosition().getLine()) { |
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.
use sourceStart() instead of getLine
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.
Actually I used the same getLine
which is used in visitCtClass
which manage properly multiple inline comments. If I use here sourceStart()
one comment is missing when writing something like:
try {}
// one comment
// two comment
catch {}
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.
It is strange because getLine uses sourceStart() to perform the line number
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.
What I understand is that sourceStart
starts at the same position than the first comment, which means the equality is respected and the comment is included (it was the previous implementation). But then the sourceStart of the second comment is greater than this sourcePosition and so it's not considered.
Now with getLine either it considers all are on the same line, either it computes well the different lines using the line separator position, which is the case I think.
if (comment.getPosition().getLine() <= e.getPosition().getLine()) { | ||
e.addComment(comment); | ||
return; | ||
} |
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.
call super.visitCtCatch()
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.
This super call is directly implemented in the scan
override, do we really need it here? It is missing in all the other overriding visitCtXX
methods...
Multiple comments placed before a catch block were ignored, see #1073. This PR contains test to spot the bug and a fix.