Fixing Json character offsets via wrapping the underlying character buffer"#2643
Fixing Json character offsets via wrapping the underlying character buffer"#2643jurgenvinju merged 26 commits intomainfrom
Conversation
…he JsonReader. idea via @DavyLandman
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2643 +/- ##
=======================================
Coverage 46% 46%
+ Complexity 6682 6680 -2
=======================================
Files 795 795
Lines 65892 65899 +7
Branches 9877 9878 +1
=======================================
+ Hits 30710 30716 +6
+ Misses 32810 32802 -8
- Partials 2372 2381 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java
Outdated
Show resolved
Hide resolved
…oid NPEs and other crashes
8614a3d to
d8dec4d
Compare
…n positions on objects
…sts to include line/column accuracy testing. Fixed some off-by-one errors
There was a problem hiding this comment.
This remains finicky code, because the internal pos field of GsonReader is not a proper cursor into the file. The new fix with a wrapped Reader helps a lot in getting this under control.
Nevertheless there are seemingly magic "-1"'s and "+1"'s spread throughout JsonValueReader to make up for a lack of control over de pos field in GsonReader. I'd rather have those -1's spread throughout the code, where you can see how much they depend semantically on the calls to GsonReader.{beginObject, endObject, fillBuffer} etc and their effect on the pos variable. A kneejerk reaction could be to factor this in a method; but would be a false abstraction. This is the real complexity of it.
src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java
Outdated
Show resolved
Hide resolved
src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java
Outdated
Show resolved
Hide resolved
src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java
Outdated
Show resolved
Hide resolved
src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java
Outdated
Show resolved
Hide resolved
|



This continues where #2638 left off.
ParseError(locationTop or |unknown:///|, line, column, cause, path)instead ofParseError(locWithOffsetLineColumn, cause, path)trackOrigins=falsefor the public Rascal API.trackOriginshas no effect. It is alwaysoff.This fix does not change the previous behavior of the Json IO library other than fixing two complex issues:
trackOrigins=falsedid not workThis API still streams pretty quickly. Could not measure a degredation in speed on smaller files like we have in the tests. On very larger files sometimes it's 1% slower and sometimes 1% faster, so that seems to be noise.
This is for another PR