com.intellij.psi.formatter.common.AbstractBlock Java Examples
The following examples show how to use
com.intellij.psi.formatter.common.AbstractBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FluidBlockWithInjection.java From idea-php-typo3-plugin with MIT License | 6 votes |
@NotNull private List<Block> buildBlocks() { List<Block> list = this.getOriginal().getSubBlocks(); if (list.isEmpty()) { return AbstractBlock.EMPTY; } else { ArrayList<Block> result = new ArrayList<>(list.size()); Iterator var3 = list.iterator(); while(var3.hasNext()) { Block block = (Block)var3.next(); if (block.getTextRange().intersects(this.myRange)) { result.add(new InjectedLanguageBlockWrapper(block, this.myOffset, this.myRange, null, this.getLanguage())); } } return result; } }
Example #2
Source File: FormatterBasedLineIndentInfoBuilder.java From consulo with Apache License 2.0 | 6 votes |
private static List<Indent.Type> getIndentOnStartOffset(Block block, TextRange range, int startOffset) { List<Indent.Type> indentsOnStartOffset = new ArrayList<Indent.Type>(); while (block != null && range.getStartOffset() == startOffset) { Indent.Type type = block.getIndent() != null ? block.getIndent().getType() : Indent.Type.CONTINUATION_WITHOUT_FIRST; indentsOnStartOffset.add(type); if (block instanceof AbstractBlock) { ((AbstractBlock)block).setBuildIndentsOnly(true); } List<Block> subBlocks = block.getSubBlocks(); block = subBlocks.isEmpty() ? null : subBlocks.get(0); } return indentsOnStartOffset; }
Example #3
Source File: TemplateLanguageFormattingModelBuilder.java From consulo with Apache License 2.0 | 6 votes |
protected AbstractBlock createDummyBlock(final ASTNode node) { return new AbstractBlock(node, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment()) { @Override protected List<Block> buildChildren() { return Collections.emptyList(); } @Override public Spacing getSpacing(final Block child1, @Nonnull final Block child2) { return Spacing.getReadOnlySpacing(); } @Override public boolean isLeaf() { return true; } }; }
Example #4
Source File: CsvFormatHelper.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
public static boolean isQuotedField(@Nullable CsvBlock block) { if (block != null && block.getNode().getElementType() == CsvTypes.FIELD) { List<Block> subBlocks = block.buildChildren(); if (subBlocks.size() > 0) { AbstractBlock abstractBlock = (AbstractBlock) subBlocks.get(0); return abstractBlock.getNode().getElementType() == CsvTypes.QUOTE; } } return false; }
Example #5
Source File: SimpleTemplateLanguageFormattingModelBuilder.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { if (element instanceof PsiFile) { final FileViewProvider viewProvider = ((PsiFile)element).getViewProvider(); if (viewProvider instanceof TemplateLanguageFileViewProvider) { final Language language = ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage(); FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forLanguage(language); if (builder != null) { return builder.createModel(viewProvider.getPsi(language), settings); } } } final PsiFile file = element.getContainingFile(); return new DocumentBasedFormattingModel(new AbstractBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment()) { @Override protected List<Block> buildChildren() { return Collections.emptyList(); } @Override public Spacing getSpacing(final Block child1, @Nonnull final Block child2) { return Spacing.getReadOnlySpacing(); } @Override public boolean isLeaf() { return true; } }, element.getProject(), settings, file.getFileType(), file); }
Example #6
Source File: DataLanguageBlockFragmentWrapper.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public List<Block> getSubBlocks() { return AbstractBlock.EMPTY; }