} else {
if (doc instanceof IDocumentExtension4) {
IDocumentExtension4 ext = (IDocumentExtension4) doc;
session = ext.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
}
participant.formatSelection(doc, regionsToFormat, pyEdit, ps);
}
} finally {
if (session != null) {
((IDocumentExtension4) doc).stopRewriteSession(session);