Skip to content
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

Merged
merged 4 commits into from
Sep 26, 2022
Merged

Fix group comments #133

merged 4 commits into from
Sep 26, 2022

Conversation

SebastienGllmt
Copy link
Contributor

@SebastienGllmt SebastienGllmt commented Aug 30, 2022

This PR:

  • Makes a fix to comments_before_grpchoice parsing
  • Makes a behavior change to comments_before_group

@@ -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
Copy link
Contributor Author

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

Copy link
Owner

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()?;
Copy link
Contributor Author

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

@anweiss
Copy link
Owner

anweiss commented Sep 12, 2022

#121 has been merged. Feel free to rebase.

@anweiss
Copy link
Owner

anweiss commented Sep 22, 2022

#132 has been merged.

@anweiss
Copy link
Owner

anweiss commented Sep 26, 2022

Thanks a ton for these contributions @SebastienGllmt. Looks solid!

@anweiss anweiss merged commit 9258948 into anweiss:main Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants