Search in sources :

Example 1 with FormatOptions

use of com.intellij.formatting.FormatProcessor.FormatOptions in project intellij-community by JetBrains.

the class FormatterImpl method buildProcessorAndWrapBlocks.

private static FormatProcessor buildProcessorAndWrapBlocks(final FormattingDocumentModel docModel, Block rootBlock, CodeStyleSettings settings, CommonCodeStyleSettings.IndentOptions indentOptions, @Nullable FormatTextRanges affectedRanges, int interestingOffset) {
    FormatOptions options = new FormatOptions(settings, indentOptions, affectedRanges, false, interestingOffset);
    FormatProcessor processor = new FormatProcessor(docModel, rootBlock, options, FormattingProgressCallback.EMPTY);
    while (!processor.iteration()) ;
    return processor;
}
Also used : FormatOptions(com.intellij.formatting.FormatProcessor.FormatOptions)

Example 2 with FormatOptions

use of com.intellij.formatting.FormatProcessor.FormatOptions in project intellij-community by JetBrains.

the class FormatterImpl method format.

public void format(final FormattingModel model, final CodeStyleSettings settings, final CommonCodeStyleSettings.IndentOptions indentOptions, final FormatTextRanges affectedRanges, final boolean formatContextAroundRanges) throws IncorrectOperationException {
    try {
        validateModel(model);
        SequentialTask task = new MyFormattingTask() {

            @NotNull
            @Override
            protected FormatProcessor buildProcessor() {
                FormatOptions options = new FormatOptions(settings, indentOptions, affectedRanges, formatContextAroundRanges);
                FormatProcessor processor = new FormatProcessor(model.getDocumentModel(), model.getRootBlock(), options, getProgressCallback());
                processor.format(model, true);
                return processor;
            }
        };
        execute(task);
    } catch (FormattingModelInconsistencyException e) {
        LOG.error(e);
    }
}
Also used : SequentialTask(com.intellij.util.SequentialTask) FormatOptions(com.intellij.formatting.FormatProcessor.FormatOptions)

Aggregations

FormatOptions (com.intellij.formatting.FormatProcessor.FormatOptions)2 SequentialTask (com.intellij.util.SequentialTask)1