rewrite

private fun rewrite(text: String)

Swaps the file's whole tree for one parsed from text. The file object survives, so its module — and with it the analysis cache key — stays the one this editor already had. The modification stamp moves, which is what tells the session on that key to be rebuilt instead of reused stale.

The parsed file is a throwaway. It is never analyzed, so it never becomes a module of its own.