Skip to content

Fix comment parsing with unattached comments #104

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

Merged
merged 3 commits into from
Jan 16, 2021
Merged

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Jan 15, 2021

Fixes #80

  • Fixes an issue where trailing comments throw an exception
  • Fixes an issue where comments can be applied to an incorrect node
  • Unattached comments are returned in a list attached to the document

Note: these two documents parse the same, with the comment applied to obj2

{
  obj1 {
    field1
    # comment
  }
  obj2 {
    field2
  }
}

and

{
  obj1 {
    field1
  }
  # comment
  obj2 {
    field2
  }
}

@Shane32 Shane32 added the bugfix Pull request that fixes a bug label Jan 15, 2021
@Shane32 Shane32 requested a review from sungam3r January 15, 2021 15:31
@Shane32 Shane32 self-assigned this Jan 15, 2021
@github-actions github-actions bot added the test Pull request that adds new or changes existing tests label Jan 15, 2021
@Shane32
Copy link
Member Author

Shane32 commented Jan 15, 2021

I have no idea why VS automatically reformatted the document. Please use GitHub's "hide whitespace changes" feature to make the diff readable.
image

@@ -82,6 +82,7 @@ namespace GraphQLParser.AST
public GraphQLDocument() { }
public System.Collections.Generic.List<GraphQLParser.AST.ASTNode>? Definitions { get; set; }
public override GraphQLParser.AST.ASTNodeKind Kind { get; }
public System.Collections.Generic.List<GraphQLParser.AST.GraphQLComment>? UnattachedComments { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shane32 Thanks. I am now looking at this simple and obvious solution and do not understand why I decided to throw an exception before.

@sungam3r
Copy link
Member

I posted #106 to prevent unexpected changes.

@sungam3r
Copy link
Member

I don't understand what happened to the formatting. Apparently, now it is correct. Anyway, looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Pull request that fixes a bug test Pull request that adds new or changes existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants