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 missing comma classification in json classification #68535

Merged
merged 2 commits into from
Jun 12, 2023

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #68534

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner June 10, 2023 23:13
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 10, 2023
@@ -187,7 +197,7 @@ public void Visit(JsonTextNode node)

public void Visit(JsonCommaValueNode node)
{
AddClassification(node.CommaToken, ClassificationTypeNames.JsonPunctuation);
// already handled when we recurse in AddTokenClassifications
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I understand how the logic in here works. Why are commas special versus other types of tokens handled by the other visit methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

Commas are handled slightly specially in json (for error recovery purposes). They can both be a node (with a token in them), or just a token in separated list. We were only handling the first case.

Now we handle both cases by just checking the token case only.

Copy link
Member

Choose a reason for hiding this comment

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

Probably worth documenting that :)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I thought that comment was :'(

Copy link
Member

Choose a reason for hiding this comment

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

This comment explains a bit of the why, but not the "commas are special for error recovery" part. That's what I needed to know to understand the code 🙂.

@CyrusNajmabadi CyrusNajmabadi merged commit 4cbfec9 into dotnet:main Jun 12, 2023
24 checks passed
@ghost ghost added this to the Next milestone Jun 12, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the jsonPunctuation branch June 12, 2023 04:34
@RikkiGibson RikkiGibson modified the milestones: Next, 17.7 P3 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LSP] [Bug]: Commas after non-array elements in JSON-like strings are colored incorrectly
3 participants