MarkusAmshove / natls

Language Server implementation for the Natural 4GL programming language
MIT License
12 stars 3 forks source link

Offsets of diagnostics on copycode parameter within copycodes are wrong #387

Closed MarkusAmshove closed 10 months ago

MarkusAmshove commented 11 months ago

If a copycode specifies:

&1& := 'Hi'

and I pass a variable:

INCLUDE CC '#VARIABLE'

then the offset for the diagnostic (e.g. undefined variable) is wrong. It starts at the correct offset, but the length is calculated for #VARIABLE instead of &1& for the additional diagnostic info within the copycode.

We might be able to remember the positions where parameters were exchanged for passed stuff and on adding diagnostics look up the length of the parameter definition (e.g. &1&).

Also, if the issue was on 'Hi', then the offset would be broken because the token shifts by parameter length.

❗ Might be worth to create a tool to print a source with all copycodes "included"

MarkusAmshove commented 10 months ago

Will be part of #411