Given an existing set of program sources, I would like to leverage an LSP server to instrument that source code so that, when run with a test, profiler, benchmark or some other sample program, the instrumented code will generate a database of information about the given source code.
My first application of this idea will be for a code coverage tool that will work on many languages and operate at the source code level rather than at the intermediate level.
LSP appears to support the operations necessary to make this work. It can supply source code location information (file start and end positions) for many definitions like class, method, variable, operator, file, array, etc. (See LSP symbol-kind and the workspace/symbol request method.) I have successfully used the (fwcd) Kotlin Language Server to obtain such information.
Once I have the declaration information for a method or class, for example, how would I leverage LSP to traverse the statements in each method (or at the top level) to instrument each statement so that pre-canned library calls can be added, as appropriate for the kind of statement?
A related question: are there any LSP based debuggers that use this instrumenting concept? The VSCode debuggers apparently do not but use some other protocol. References to those other protocols would be good.