* be formatted.
* @throws SyntaxErrorException
*/
public void applyFormatAction(PyEdit pyEdit, PySelection ps, int[] regionsToFormat, boolean throwSyntaxError)
throws BadLocationException, SyntaxErrorException {
final IFormatter participant = getFormatter();
final IDocument doc = ps.getDoc();
final SelectionKeeper selectionKeeper = new SelectionKeeper(ps);
DocumentRewriteSession session = null;
try {
if (regionsToFormat == null || regionsToFormat.length == 0) {
if (doc instanceof IDocumentExtension4) {
IDocumentExtension4 ext = (IDocumentExtension4) doc;
session = ext.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
}
participant.formatAll(doc, pyEdit, true, throwSyntaxError);
} 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);