Open bukowa opened 5 months ago
What kind of API are you envisioning?
Right now whitespace is not captured in the parser (as save files need maximum performance). An alternative that has been successful is to provide structural context for the error instead of the line number. To use your error as an example:
Warning: characters undefined mother 166330 not found at events[12].triggers[3].OR
You'd say that the error occurred at the OR
block inside the 3rd trigger of event id 12. (as an example). It might not be as helpful as the exact line number, but it should give most the context needed to find the issue.
To be honest, while writing, I didn't think about it, I was just curious if such a possibility exists. Now when you asked about API - LSP comes to my mind - but how to combine it so that it makes sense?
From docs The user executes “Go to Definition” on a symbol of an open document: The tool sends a ‘textDocument/definition’ request with two parameters: (1) the document URI and (2) the text position from where the ‘Go to Definition’ request was initiated to the server. The server responds with the document URI and the position of the symbol’s definition inside the document.
Position Position in a text document expressed as zero-based line and zero-based character offset. A position is between two characters like an ‘insert’ cursor in an editor. Special values like for example -1 to denote the end of a line are not supported.
Are you looking for something like the cwtools for vscode? https://marketplace.visualstudio.com/items?itemName=tboby.cwtools-vscode
I am parsing game files looking conflicts/errors in the repo https://github.com/bukowa/ck3oop I wonder if there is a way to receive line number where something is located, given; I would like to display line number with the path to the file so in the end it's clickable from IDE maybe?