LSP & Warnings
Last week, I turned up warnings and fixed potential bugs related to large files. This week, I went through most of the extended warnings in my codebase. Ironically, when I wrote more LSP code, I immediately ran into a bug. The bug wasn't something that could have been warned about; it was inside a utility function that I recently changed, which had no test. Testing utility functions was on my todo list, so I bumped it up.
In the LSP generator, I generated code to parse json for messages going to the client. The code to generate the body of a switch was extremely simple. The output is
case 0xB26BF0F09C58A6F1: if (method == "method/name") { todo(); /* Need Response DocumentationName */ } break;
Next week, I'll be writing tests to trigger these todos and implement all the commonly used functionality. I wrote about 1200 lines to generate 2600 lines, not a great ratio, but the generated code is tedious and has a lot of strings, which compilers can't catch typos in, so I think it's still pretty good, even if not great. There were so many corner cases; what I can generate might be finished. There shouldn't be much left to do, so the rest of the protocol code will likely be written by hand. However, the non-protocol part (actually doing stuff with the events) hasn't been started. The first few methods and events I want to implement are jump to definition, function signatures, autocomplete, and diagnostics (errors/warnings as you type). I remember LSPs being slow on syntax highlighting. I'll likely implement it, but not right away. I shouldn't need an LSP to make source files look decent.