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

Please provide end index (position) of tokens #112

Open
nthykier opened this issue Apr 8, 2024 · 0 comments
Open

Please provide end index (position) of tokens #112

nthykier opened this issue Apr 8, 2024 · 0 comments

Comments

@nthykier
Copy link

nthykier commented Apr 8, 2024

Using the lc attribute of CommentedMap and CommentedSeq enables you to get the line index and starting column of a given key/value/item. So far so good. However, it is hard to figure out where the object in question ends.

Consider the following input:

foo: string
bar: "string"

Both of these start a column 5 on their respective line and their parsed form is string (6 characters). But the first line is 2 characters shorter than the second due to the quotes.

This makes it hard to compute ranges of values for tokens. As I am writing a language server (LSP) for a YAML based format, I need to report diagnostics (linting) via ranges - that is, start and end position, such that the editor knows exactly where to put its error markers.

The underlying tokens already have a start and and end marker (at least, during the token/parse phrase), so for trivial cases the data is already available just not exposed. I am less sure how to handle values like objects and lists. But for starters, just having exact start + end position on basic types like strings, bool, int/float, etc. would be a great help. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant