-
Notifications
You must be signed in to change notification settings - Fork 15
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 group comments #133
Fix group comments #133
Conversation
26aa86c
to
f85a35e
Compare
@@ -1411,17 +1411,17 @@ impl<'a> Parser<'a> { | |||
#[cfg(not(feature = "ast-comments"))] | |||
let group = self.parse_group()?; | |||
|
|||
// we take the first comment inside the 1st group to be comments_before_group |
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.
Previously, ALL comments in the 1st group were used as comments_before_group
However, this is problematic because it means there is no way to add a comment to the 1st group. So instead, I made that only the 1st line belongs to comments_before_group
This is not really an ideal solution, but CDDL's syntax doesn't allow for anything better as far as I know
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.
Indeed ... not sure if there's a way around this.
self.advance_newline()?; | ||
#[cfg(feature = "ast-comments")] | ||
{ | ||
grpchoice.comments_before_grpchoice = self.collect_comments()?; |
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.
For any group after the 1st group, this line used to override the contents of comments_before_grpchoice
. This change makes this block only apply to the 1st group to avoid overriding
On a side note, I'm not sure why `comments_before_group is not set here instead of the previous logic to strip stuff after the fact
#121 has been merged. Feel free to rebase. |
#132 has been merged. |
51bac9d
to
8ca5917
Compare
Thanks a ton for these contributions @SebastienGllmt. Looks solid! |
This PR:
comments_before_grpchoice
parsingcomments_before_group