fleabitdev / glsp

The GameLisp scripting language
https://gamelisp.rs/
Apache License 2.0
395 stars 13 forks source link

Line:Column in error message when `parse_all` fails #30

Open Fahien opened 3 years ago

Fahien commented 3 years ago

I am experimenting with a language server extension and I am trying to highlight areas of the code that fail to parse. I am not sure if my approach is the best or even correct.

At the moment I am calling parse_all(&code, None), and I am inspecting the error value. Unfortunately I can only get a message, with no information about line and column (or span) where the error is.

fleabitdev commented 3 years ago

Thanks for your interest!

Line-and-column information is currently destroyed (converted to text) when constructing a GError. There's no easy way to access it programmatically. As a workaround, you could capture a short-form error string with glsp::try_call, and then parse line-and-column information from that string.

There's no reason we couldn't expose an API for this, but I have to admit that it's a low-priority feature. I might tackle it when I'm working on stack-frame inspection (issue #8).