Add error position and json_path to the JRuby extension - #1067
Open
ojuschugh1 wants to merge 2 commits into
Open
Add error position and json_path to the JRuby extension#1067ojuschugh1 wants to merge 2 commits into
ojuschugh1 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1062, as suggested there: this brings
ParserError#line,#columnand#json_pathto the JRuby extension.The Java parser already shares the C parser's architecture (frame stack + value stack), so the implementation mirrors it closely: positions are computed by scanning backwards from the error offset like
cursor_positiondoes in C, and@json_pathis collected as raw segments from the frame stack, then formatted by the shared Ruby code from #1062. Everything happens at raise time, so nothing is added to the happy path.NestingErrorstays bare, matching the C extension.Positions and paths come out identical to the C parser:
The duplicate key case reuses the existing cursor rewind to the object's opening brace, so line/column match C exactly there too. Error message wording still differs between the two extensions ("unexpected token at" vs "unexpected character:"); I left that alone to keep the diff focused.
The four
json_pathtest methods now run on JRuby (omit guards removed), plus a newtest_parse_error_positionasserting line/column values on both extensions. JRuby suite goes from 53 omissions to 49 with 0 failures; CRuby stays at 0 failures, 0 omissions.