private Indent indentOfMultipleDeclarationChild(@NotNull IElementType childType, @NotNull IElementType specType) { if (childType == specType) { return Indent.getNormalIndent(); } return COMMENTS.contains(childType) && myNode.findChildByType(specType) != null ? Indent.getNormalIndent() : Indent.getNoneIndent(); }
@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(); }
return Indent.getNormalIndent(); } else if (parentElementType == BallerinaTypes.RECORD_LITERAL_BODY) { return Indent.getNormalIndent(); } else if (parentElementType == BallerinaTypes.WAIT_FOR_COLLECTION) { if (childElementType != BallerinaTypes.LEFT_BRACE && childElementType != BallerinaTypes.RIGHT_BRACE) { return Indent.getNormalIndent(); || parentElementType == BallerinaTypes.COMMITTED_CLAUSE || parentElementType == BallerinaTypes.RECORD_TYPE_NAME)) { return Indent.getNormalIndent(); } else if (parentElementType == BallerinaTypes.CALLABLE_UNIT_SIGNATURE) { return Indent.getIndent(Indent.Type.NORMAL, true, true); } else if (childElementType == BallerinaTypes.RETURN_PARAMETER) { return Indent.getNormalIndent(); } else if (childElementType == BallerinaTypes.RETURN_TYPE) { return Indent.getIndent(Indent.Type.NORMAL, true, true); } else if ((childElementType == BallerinaTypes.TUPLE_TYPE_NAME || childElementType == BallerinaTypes.UNION_TYPE_NAME) && (parentElementType == BallerinaTypes.RETURN_TYPE)) { return Indent.getIndent(Indent.Type.NORMAL, true, true); } else if (parentElementType == BallerinaTypes.MATCH_PATTERN_CLAUSE) { return Indent.getNormalIndent(); } else if (childElementType == BallerinaTypes.FIELD_DEFINITION || childElementType == BallerinaTypes.RECORD_REST_FIELD_DEFINITION) { return Indent.getNormalIndent(); } else if (childElementType == BallerinaTypes.SERVICE_BODY_MEMBER && parentElementType == BallerinaTypes.SERVICE_BODY) { return Indent.getNormalIndent(); } else if (childElementType == BallerinaTypes.TYPE_REFERENCE
@Override public Indent getIndent() { return Indent.getNoneIndent(); }
return Indent.getAbsoluteNoneIndent(); return Indent.getNormalIndent(); return Indent.getContinuationWithoutFirstIndent(); return isLast() ? Indent.getNormalIndent() : Indent.getContinuationWithoutFirstIndent(); return isLast() ? Indent.getNoneIndent() : Indent.getNormalIndent(); return Indent.getContinuationWithoutFirstIndent(); return Indent.getNormalIndent();
@NotNull private List<com.intellij.formatting.Block> buildAssociationsBaseChildren( @NotNull ASTNode associationsBase, @NotNull Wrap containerAssociationOperationWrap) { return buildChildren( associationsBase, (child, childElementType, blockList) -> { if (childElementType == CONTAINER_ASSOCIATION_OPERATION) { blockList.add(buildChild(child, containerAssociationOperationWrap, Indent.getNormalIndent())); } else { blockList.add(buildChild(child)); } return blockList; } ); }
&& (type == CypherTypes.READING_CLAUSE || type == CypherTypes.UPDATING_CLAUSE || type == CypherTypes.READING_WITH_RETURN)) { return Indent.getNoneIndent(); return Indent.getNoneIndent(); return Indent.getNormalIndent(); return Indent.getNormalIndent(); return Indent.getNormalIndent(); return Indent.getContinuationIndent(); return Indent.getContinuationIndent(); return Indent.getNormalIndent(); return Indent.getContinuationIndent(); return Indent.getContinuationIndent(); return Indent.getContinuationIndent(); return Indent.getNoneIndent();
endWrap, parentAlignment, Indent.getIndent(Indent.Type.NONE, indentRelativeToDirectParent, false) buildEndOfExpressionChildren(child, null, Indent.getNormalIndent()) ); } else if (childElementType == STAB) {
IElementType stabParentElementType = stabParent.getElementType(); childrenIndent = Indent.getNormalIndent( stabParentElementType == DO_BLOCK && codeStyleSettings(stabParent).ALIGN_UNMATCHED_CALL_DO_BLOCKS == childrenIndent = Indent.getSpaceIndent(normalIndentSize(stab), true); } else { ASTNode stabParent = stab.getTreeParent(); childrenIndent = Indent.getNormalIndent(); } else { childrenIndent = Indent.getSpaceIndent(spaces, true);
@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(); }
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())); }
@Override public Indent getIndent() { return Indent.getAbsoluteNoneIndent(); } }
@NotNull private List<com.intellij.formatting.Block> buildNoParenthesesKeywordsChildren(ASTNode noParenthesesKeywords) { return buildChildren( noParenthesesKeywords, (child, childElementType, blockList) -> { if (childElementType == NO_PARENTHESES_KEYWORD_PAIR) { blockList.add(buildChild(child, Indent.getIndent(Indent.Type.NONE, true, false))); } else { // commas and comments blockList.add(buildChild(child)); } return blockList; } ); }
@NotNull private List<com.intellij.formatting.Block> buildBlockListChildren(@NotNull ASTNode blockListNode, @Nullable Alignment parentAlignment) { return buildChildren( blockListNode, (child, childElementType, blockList) -> { blockList.add(buildChild(child, parentAlignment, Indent.getNoneIndent())); return blockList; } ); }
return Indent.getContinuationIndent(); return Indent.getContinuationIndent(); || isLast && BLOCK_CLOSERS.contains(nodeType) ) { return Indent.getNoneIndent(); return Indent.getNoneIndent(); assert psi instanceof PerlHeredocElementImpl; if (!((PerlHeredocElementImpl)psi).isIndentable()) { return Indent.getAbsoluteNoneIndent(); return Indent.getAbsoluteNoneIndent(); return Indent.getNoneIndent(); return Indent.getNoneIndent(); return Indent.getNoneIndent(); return Indent.getNoneIndent(); return Indent.getContinuationIndent(); nodeType == ATTRIBUTE && prevSiblingElementType != COLON ) { return Indent.getContinuationIndent();
@NotNull private List<com.intellij.formatting.Block> buildKeywordsChildren(@NotNull ASTNode keywords, @NotNull Wrap keywordPairWrap) { return buildChildren( keywords, (child, childElementType, blockList) -> { if (childElementType == KEYWORD_PAIR) { blockList.add(buildChild(child, keywordPairWrap, Indent.getNormalIndent())); } else { // commas and comments blockList.add(buildChild(child)); } return blockList; } ); }
@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 private List<com.intellij.formatting.Block> buildNoParenthesesKeywordPairChildren( @NotNull ASTNode noParenthesesKeywordPair ) { Wrap keywordKeyWrap = Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); Indent keywordKeyIndent = Indent.getIndent(Indent.Type.NONE, true, false); Wrap keywordPairColonWrap = Wrap.createChildWrap(keywordKeyWrap, WrapType.NONE, true); Wrap keywordValueWrap = Wrap.createChildWrap(keywordKeyWrap, WrapType.NONE, true); return buildChildren( noParenthesesKeywordPair, (child, childElementType, blockList) -> { if (childElementType == ACCESS_EXPRESSION) { blockList.addAll(buildContainerValueAccessExpressionChildren(child, keywordValueWrap)); } else if (childElementType == KEYWORD_KEY) { blockList.add(buildChild(child, keywordKeyWrap, keywordKeyIndent)); } else if (childElementType == KEYWORD_PAIR_COLON) { blockList.add(buildChild(child, keywordPairColonWrap)); } else { blockList.add(buildChild(child, keywordValueWrap)); } return blockList; } ); }
@NotNull private static Indent indentIfNotBrace(@NotNull ASTNode child) { return BRACES_TOKEN_SET.contains(child.getElementType()) ? Indent.getNoneIndent() : Indent.getNormalIndent(); }
@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); }