EditorFileModule
A dangling file module that holds its file outright.
The stock KaDanglingFileModuleImpl takes a smart pointer on the file instead, which the pointer manager registers and keeps; the module offers no way to hand it back, and its own reference is private. So the file's PSI tree outlives anything that releases the module, which is what AnalysisSession.Editor.close would otherwise be unable to reclaim. Here the file is an ordinary field, and goes when the module does.
Writing one is the documented alternative — the stock implementation says as much. The optimization given up is one shortcut in session building: for its own class the factory merges the context session's symbol providers straight in, and for anything else it aggregates and compares both dependency sets first. Same result, a little more work per session. Everything below mirrors the stock behavior, which is to say it defers to the context module throughout.
Constructors
Properties
Through the view provider, not PsiFile.virtualFile: the latter is null for an in-memory file, and the scope still has to accept one.