use of com.intellij.psi.formatter.PsiBasedFormattingModel in project kotlin by JetBrains.
the class KotlinFormattingModelBuilder method createModel.
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(KotlinLanguage.INSTANCE);
KotlinBlock block = new KotlinBlock(containingFile.getNode(), NodeAlignmentStrategy.getNullStrategy(), Indent.getNoneIndent(), null, settings, KotlinSpacingRulesKt.createSpacingBuilder(settings, KotlinSpacingBuilderUtilImpl.INSTANCE));
// it's needed until IDEA's issue with this document being created with wrong threading policy is fixed
if (!element.isPhysical()) {
FormattingDocumentModelImpl formattingDocumentModel = new FormattingDocumentModelImpl(new DocumentImpl(containingFile.getViewProvider().getContents(), true), containingFile);
return new PsiBasedFormattingModel(containingFile, block, formattingDocumentModel);
}
return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings);
}
Aggregations