@NotNull @Override public FormattingModel createModel(@NotNull PsiElement element, @NotNull CodeStyleSettings settings) { Block block = new GoFormattingBlock(element.getNode(), null, Indent.getNoneIndent(), null, settings, createSpacingBuilder(settings)); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { if (!isGrammarViolated(element.getNode())) { BallerinaBlock rootBlock = new BallerinaBlock(element.getNode(), null, Indent.getNoneIndent(), null, settings, createSpaceBuilder(settings), new HashMap<>()); return FormattingModelProvider .createFormattingModelForPsiFile(element.getContainingFile(), rootBlock, settings); // If the plugin grammar tree is not generated correctly for the file, code reformat should not work. } else { AbstractBlock rootBlock = new AbstractBlock(element.getNode(), null, null) { @Nullable @Override public Spacing getSpacing(@Nullable Block child1, @NotNull Block child2) { return null; } @Override public boolean isLeaf() { return false; } @Override protected List<Block> buildChildren() { return new LinkedList<>(); } }; return FormattingModelProvider .createFormattingModelForPsiFile(element.getContainingFile(), rootBlock, settings); } }
/** * Requests building the formatting model for a section of the file containing * the specified PSI element and its children. * * @param element the top element for which formatting is requested. * @param settings the code style settings used for formatting. * @return the formatting model for the file. */ @NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PsiFile containingFile = element.getContainingFile(); if (DUMP_FORMATTING_AST) { System.out.println("AST tree for " + containingFile.getName() + ":"); printAST(containingFile.getNode(), 0); } Block block = new Block( element.getNode(), createSpaceBuilder(settings) ); if (DUMP_FORMATTING_AST) { FormattingModelDumper.dumpFormattingModel(block, 2, System.out); } return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, block, settings); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { CommonCodeStyleSettings commonSettings = settings.getCommonSettings(MathematicaLanguage.INSTANCE); MathematicaCodeStyleSettings mathematicaSettings = settings.getCustomSettings(MathematicaCodeStyleSettings.class); return FormattingModelProvider.createFormattingModelForPsiFile( element.getContainingFile(), AbstractMathematicaBlock.createMathematicaBlock(element, commonSettings, mathematicaSettings), settings); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PerlFormattingBlock block = new EmbeddedPerlFormattingBlock(element.getNode(), new EmbeddedPerlFormattingContext(element, settings)); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); } }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PerlFormattingBlock block = new MasonFormattingBlock(element.getNode(), new MasonFormattingContext(element, settings)); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); } }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PerlFormattingBlock block = new MojoliciousFormattingBlock(element.getNode(), new MojoliciousFormattingContext(element, settings)); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); } }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PerlFormattingBlock block = new HTMLMasonFormattingBlock(element.getNode(), new HTMLMasonFormattingContext(element, settings)); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); } }
@NotNull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { ASTNode node = element.getNode(); assert node != null; PsiFile containingFile = element.getContainingFile(); ASTNode astNode = containingFile.getNode(); assert astNode != null; BashProjectSettings projectSettings = BashProjectSettings.storedSettings(containingFile.getProject()); if (!projectSettings.isFormatterEnabled()) { return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, new NoOpBlock(astNode), settings); } return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, new BashBlock(astNode, null, Indent.getAbsoluteNoneIndent(), null, settings), settings); }
@NotNull @Override public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { final Block impexBlock = new ImpexBlock( element.getNode(), null, Alignment.createAlignment(), createSpaceBuilder(settings), settings ); return FormattingModelProvider.createFormattingModelForPsiFile( element.getContainingFile(), impexBlock, settings ); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(ProtoLanguage.INSTANCE); ASTNode fileNode = containingFile.getNode(); Wrap wrap = Wrap.createWrap(WrapType.NONE, false); Alignment alignment = Alignment.createAlignment(); ProtoFileBlock block = new ProtoFileBlock(fileNode, wrap, alignment, settings); return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, block, settings); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { CypherBlock block = new CypherBlock(element.getNode(), Alignment.createAlignment(), Indent.getNoneIndent(), Wrap.createWrap(WrapType.NONE, false), settings, CypherFormattingModelBuilder.createSpacingBuilder(settings) ); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { ASTNode root = CsvFormatHelper.getRoot(element.getNode()); CsvFormattingInfo formattingInfo = new CsvFormattingInfo( settings, CsvFormatHelper.createSpaceBuilder(settings), CsvFormatHelper.createColumnInfoMap(root, settings) ); return FormattingModelProvider.createFormattingModelForPsiFile( element.getContainingFile(), new CsvBlock(root, formattingInfo), settings ); }