-
Notifications
You must be signed in to change notification settings - Fork 53
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
add line and column information to scanner and visitor #17
Conversation
Cool, thanks a lot! |
Not having new-lines reported in comment is a problem. Especially as the scanner always scans and consumes comments. Its only the parser that ignores it and reports and error, if not allowed. So your original idea of reporting the line number with the I'm also not opposed to returning linenumber/character in every call back ( |
Thanks a lot for your feedback! I decided to implement an extra At the moment, the value The only bit I'm worried about is the confusion the We could also remove I hope I took into account all line breaks that may occur in the scanning process. |
That would be my favourite as its the most consistent. |
Should we pass a zero-based column alongside the current line as well? |
Yes, line and character (following the naming in the LSP) |
Sounds good to me. |
Looks good! |
published as 2.1 |
The PR implements an extra and optional
onLineBreak
function.At the moment, jsonc-parser make use of offset and length for positional info, which is totally fine.
Unfortunately, quite a few tools/editors operate on lines and columns, therefore integrating jsonc-parser is a bit more troublesome, since you need to fall back to scanner/tokenizer and perform the entire parsing process (At least, I couldn't find any reasonable way to implement positional info based on columns and lines without the use of scanner).
Hope the above reasoning makes sense.
I am not sure about the presence of
lineNumber
and whether it should be zero-based or not. I believe we could get rid of it and let the consumer implement it if needed.Moreover, I'm afraid we cannot really handle line breaks in multi-line comments due to the way these comments are parsed.