@NotNull private Indent calcIndent(@NotNull ASTNode child) { IElementType parentType = myNode.getElementType(); IElementType type = child.getElementType(); if (type == SWITCH_START) return Indent.getNoneIndent(); if (parentType == BLOCK && type == SELECT_STATEMENT) return Indent.getNoneIndent(); if (parentType == SELECT_STATEMENT && type == RBRACE) return Indent.getNormalIndent(); if (parentType == ARGUMENT_LIST && type != LPAREN && type != RPAREN) return Indent.getNormalIndent(); if ((parentType == EXPR_CASE_CLAUSE || parentType == TYPE_CASE_CLAUSE) && (type == CASE || type == DEFAULT)) return Indent.getNoneIndent(); if (BLOCKS_TOKEN_SET.contains(parentType)) return indentIfNotBrace(child); if (parentType == IMPORT_DECLARATION) return indentOfMultipleDeclarationChild(type, IMPORT_SPEC); if (parentType == CONST_DECLARATION) return indentOfMultipleDeclarationChild(type, CONST_SPEC); if (parentType == VAR_DECLARATION) return indentOfMultipleDeclarationChild(type, VAR_SPEC); if (parentType == TYPE_DECLARATION) return indentOfMultipleDeclarationChild(type, TYPE_SPEC); if (parentType == COMM_CLAUSE && child.getPsi() instanceof GoStatement) return Indent.getNormalIndent(); if (child.getPsi() instanceof GoExpression) return Indent.getContinuationWithoutFirstIndent(); return Indent.getNoneIndent(); }
public PerlSyntheticBlock(@NotNull PerlAstBlock realBlock, @NotNull List<Block> subBlocks, @Nullable Wrap wrap, @Nullable Alignment alignment, @NotNull PerlFormattingContext context) { if (subBlocks.isEmpty()) { throw new IllegalArgumentException("Subblocks should not be empty"); } mySubBlocks = ContainerUtil.immutableList(new ArrayList<>(subBlocks)); myRealBlock = realBlock; myWrap = wrap; myAlignment = alignment; myContext = context; myIndent = getFirstRealBlock().getIndent(); mySubBlocks.stream() .filter(block -> block instanceof PerlAstBlock && block.getIndent() != Indent.getAbsoluteNoneIndent()) .forEach(block -> ((PerlAstBlock)block) .setIndent(Indent.getContinuationWithoutFirstIndent())); }
@Nullable @Override protected Indent getChildIndent() { IElementType elementType = myNode.getElementType(); if (NORMAL_CHILD_INDENTED_CONTAINERS.contains(elementType)) { return Indent.getNormalIndent(); } else if (CONTINUOS_CHILD_INDENTED_CONTAINERS.contains(elementType)) { return Indent.getContinuationWithoutFirstIndent(); } return super.getChildIndent(); }
return Indent.getContinuationWithoutFirstIndent(); return isLast() ? Indent.getNormalIndent() : Indent.getContinuationWithoutFirstIndent(); return Indent.getContinuationWithoutFirstIndent();
return grandParentNodeType == STATEMENT ? Indent.getContinuationWithoutFirstIndent() : Indent.getContinuationIndent(); return forceFirstIndent ? Indent.getContinuationIndent() : Indent.getContinuationWithoutFirstIndent();