Package ro.redeul.google.go.formatter.blocks

Source Code of ro.redeul.google.go.formatter.blocks.GoFunctionDeclarationBlock

package ro.redeul.google.go.formatter.blocks;

import com.intellij.formatting.Alignment;
import com.intellij.formatting.Indent;
import com.intellij.formatting.Spacing;
import com.intellij.lang.ASTNode;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.tree.IElementType;
import ro.redeul.google.go.lang.parser.GoElementTypes;

class GoFunctionDeclarationBlock extends GoBlock {
    public GoFunctionDeclarationBlock(ASTNode node, Alignment alignment, Indent indent,
                                      CommonCodeStyleSettings settings) {
        super(node, alignment, indent, null, settings);
    }

    @Override
    protected Spacing getGoBlockSpacing(GoBlock child1, GoBlock child2) {
        IElementType child1ElementType = child1.getNode().getElementType();

        if (child1ElementType == GoElementTypes.pRPAREN) {
            return BASIC_SPACING;
        }

        if (child1ElementType == GoElementTypes.FUNCTION_RESULT) {
            return BASIC_SPACING;
        }

        Spacing spacing = super.getGoBlockSpacing(child1, child2);
        if (spacing != null) {
            return spacing;
        }

        return EMPTY_SPACING;
    }
}
TOP

Related Classes of ro.redeul.google.go.formatter.blocks.GoFunctionDeclarationBlock

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.