Formatter - indent

After following this tutorial:
https://confluence.jetbrains.com/display/IntelliJIDEA/Formatter

and tweaking options, I can not figure out how to fine-tune indenting.

a specific question would be:

if next indent x1 is calculated in AbstractBlock.buildChildren,

how to make sure that the first next block after CRLF is indented with this value x1?

0
1 comment

ok here is a solution:

in FormattingModelBuilder:
FormattingModel createModel(PsiElement, CodeStyleSettings)
returns  FormattingModelImpl (your own minimum implementation)

FormattingModel implementation:
inits you implementation of Block,
returns your own minimum implementation of FormattingDocumentModel


in Block implementation:

public Spacing getSpacing(Block child1, Block child2) {
    make rules (if - then) depending on child1, child2 IElementTypes etc

     return Spacing.createSpacing(minSpace, maxSpace, minLineBreaks, true, 2);
}

you can space, indent, add / remove lines etc.

0

Please sign in to leave a comment.