Search in sources :

Example 6 with Alignment

use of com.intellij.formatting.Alignment in project intellij-community by JetBrains.

the class ChildrenBlocksBuilder method buildNodeChildBlocks.

public List<Block> buildNodeChildBlocks(ASTNode node, BlockFactory factory) {
    List<Block> blocks = ContainerUtil.newArrayList();
    for (ASTNode child : node.getChildren(null)) {
        if (FormatterUtil.isWhitespaceOrEmpty(child) || child.getTextLength() == 0) {
            continue;
        }
        Alignment alignment = myConfig.getAlignment(child);
        IElementType type = child.getElementType();
        Indent indent = myConfig.getIndent(type);
        Wrap wrap = myConfig.getWrap(type);
        blocks.add(factory.createBlock(child, indent, alignment, wrap));
    }
    return blocks;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) Alignment(com.intellij.formatting.Alignment) Indent(com.intellij.formatting.Indent) Wrap(com.intellij.formatting.Wrap) ASTNode(com.intellij.lang.ASTNode) Block(com.intellij.formatting.Block)

Example 7 with Alignment

use of com.intellij.formatting.Alignment in project intellij-community by JetBrains.

the class AlignmentProvider method getAlignment.

@Nullable
public Alignment getAlignment(@NotNull PsiElement e) {
    final Set<PsiElement> set = myTree.get(e);
    if (set == null) {
        return null;
    }
    Alignment alignment = myAlignments.get(set);
    if (alignment != null)
        return alignment;
    Alignment.Anchor anchor = myAnchor.get(set);
    if (anchor == null) {
        myAnchor.put(set, Alignment.Anchor.LEFT);
        anchor = Alignment.Anchor.LEFT;
    }
    alignment = Alignment.createAlignment(myAllowBackwardShift.get(set), anchor);
    myAlignments.put(set, alignment);
    return alignment;
}
Also used : Alignment(com.intellij.formatting.Alignment) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Alignment (com.intellij.formatting.Alignment)7 Wrap (com.intellij.formatting.Wrap)6 Block (com.intellij.formatting.Block)3 Indent (com.intellij.formatting.Indent)3 PsiElement (com.intellij.psi.PsiElement)3 ASTNode (com.intellij.lang.ASTNode)2 IElementType (com.intellij.psi.tree.IElementType)2 ArrayList (java.util.ArrayList)2 PsiNameValuePair (com.intellij.psi.PsiNameValuePair)1 Nullable (org.jetbrains.annotations.Nullable)1