I'd like to take this opportunity that as far as indexing is concerned there is an additional third functionality, separate from index-while-building and background-index-changed-files, which is "get the index data for the in-memory source changes".
Essentially what we'd like to have is index data to be generated/updated as you edit the file, with the in-memory source changes. The functionality to generate the index data would be reside in sourcekitd (the compiler side) and controlled by SourceKit-LSP.