Custom language formatter question pack #1

Hello.

First of all i wonder if the formatting is different if i return null from getFormattingModelBuilder or if i return this
FormattingModelProvider.createFormattingModelForPsiFile(
element.getContainingFile(),
null,
settings);
from my FormattingModelBuilder?

Secondly, what exactly is a formatting model and what is the difference with blocks?

And what Block do i need to pass to this FormattingModelProvider.createFormattingModelForPsiFile ?

0
2 comments
Avatar
Permanently deleted user

Hello Jay,

First of all i wonder if the formatting is different if i return null
from getFormattingModelBuilder or if i return this
FormattingModelProvider.createFormattingModelForPsiFile(
element.getContainingFile(),
null,
settings);
from my FormattingModelBuilder?


Why do you care? Neither of these is a valid implementation.

Secondly, what exactly is a formatting model and what is the
difference with blocks?


A formatting model contains a tree of blocks.

And what Block do i need to pass to this
FormattingModelProvider.createFormattingModelForPsiFile ?


The block describing your entire file (with sub-blocks for AST nodes contained
in the file).

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

I care because right now i don't have time to validly implement the formatter, however i noticed that the second version ”doesn't work“ better than the first one.
Like when i don't have a FormattingModelBuilder at all and press enter, the new line's indent is different from the previous. Surprisingly this does not happen when i have a null Block.

0

Please sign in to leave a comment.