void (final @NotNull Document document, final ReadonlyFragmentModificationHandler handler) { final Document doc = document instanceof DocumentWindow ? ((DocumentWindow)document).getDelegate() : document; if (doc instanceof DocumentImpl) { ((DocumentImpl)document).setReadonlyFragmentModificationHandler(handler); } }