-
Notifications
You must be signed in to change notification settings - Fork 611
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
json: Reflect escaping characters in Traversal
.SourceRange()
#598
Comments
Hi @radeksimko, This is the way it is right now honestly because I didn't know how to make it behave better: the source ranges inside the JSON string are being generated by I think the trickiest part here is that the source location information originates in the tokenisation step in I expected something like that would add significant overhead to all parsing tasks, and so elected to just let this edge case be a little wrong so that we would not hurt the other more common situations (like not using JSON at all) where tokenizing directly to slices of a byte array is sufficient and fast. If you have ideas on how we could solve this without either lots of logic duplication or adding overhead to the non-JSON tokenizing process then I'd love to discuss them! But I personally exhausted all of my ideas and so just accepted this compromise out of pragmatism. |
I am guessing that looping over the parsed traversal after the linked LOC (inside My working theory is that we can safely assume that any successfully parsed It still may not make the implementation easy, but I thought it's worth making that distinction. I suppose a more elegant solution would involve some decoupling of |
Context
As indicated by the inline comment and discovered as part of adding support for reference related code intelligence via language server in hashicorp/hcl-lang#185 a traversal inside a JSON config which includes string key, e.g.
has a reported range which is off by 2 for each/any string key. i.e. with every map/object key this becomes more inaccurate.
The expected range would be
See https://go.dev/play/p/pnDgnpEeLXA
Proposal
Report accurate range for traversals with string keys inside JSON.
The text was updated successfully, but these errors were encountered: