FormattingModelBuilder
Why here http://confluence.jetbrains.com/display/IntelliJIDEA/Formatter FormattingModel created around given element but not a PsiFile a whole?
E.g. why we have
public class SimpleFormattingModelBuilder implements FormattingModelBuilder {@NotNull@Overridepublic FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),new SimpleBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false),Alignment.createAlignment(), createSpaceBuilder(settings)), settings);}
...
instead of
public class SimpleFormattingModelBuilder implements FormattingModelBuilder {@NotNull@Overridepublic FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
PsiFile containingFile =element.getContainingFile().getViewProvider().getPsi(SimpleLanguage.INSTANCE);return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),new SimpleBlock(containingFile, Wrap.createWrap(WrapType.NONE, false),Alignment.createAlignment(), createSpaceBuilder(settings)), settings);}
my exception is based on http://devnet.jetbrains.com/message/5216859#5216859
Q: And what Block do i need to pass to thisFormattingModelProvider.createFormattingModelForPsiFile
A(Dmitry Jemerov): The block describing your entire file (with sub-blocks for AST nodes contained
in the file).
If it is bug, please also provide answer to http://devnet.jetbrains.com/thread/444830?tstart=0
Please sign in to leave a comment.
Hi Sergey,
I consider that to be a custom language tutorial bug. Even FormattingModelProvider.createFormattingModelForPsiFile() javadoc says that root block should be provided
Denis
Thanks for answer. Do I need to create a bug report somewhere?
I've created corresponding ticket - IDEA-107927.
Denis
Ok. I'm also created https://github.com/cheptsov/SimplePlugin/pull/1
Cool, thanks!