Package com.dci.intellij.dbn.code.common.style.presets.iteration

Source Code of com.dci.intellij.dbn.code.common.style.presets.iteration.IterationIgnoreWrappingPreset

package com.dci.intellij.dbn.code.common.style.presets.iteration;

import com.dci.intellij.dbn.language.common.element.ElementType;
import com.dci.intellij.dbn.language.common.element.IterationElementType;
import com.dci.intellij.dbn.language.common.element.TokenElementType;
import com.dci.intellij.dbn.language.common.psi.BasePsiElement;
import com.intellij.formatting.Spacing;
import com.intellij.formatting.Wrap;
import com.intellij.psi.codeStyle.CodeStyleSettings;

public class IterationIgnoreWrappingPreset extends IterationAbstractPreset {
    public IterationIgnoreWrappingPreset() {
        super("ignore_wrapping", "Ignore");
    }

    public Wrap getWrap(BasePsiElement psiElement, CodeStyleSettings settings) {
        return null;
    }

    public Spacing getSpacing(BasePsiElement psiElement, CodeStyleSettings settings) {
        BasePsiElement parentPsiElement = getParentPsiElement(psiElement);
        IterationElementType iterationElementType = (IterationElementType) parentPsiElement.getElementType();
        ElementType elementType = psiElement.getElementType();

        if (elementType instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) elementType;
            if (iterationElementType.isSeparator(tokenElementType)) {
                return tokenElementType.isCharacter() ?
                        SPACING_NO_SPACE :
                        SPACING_ONE_SPACE;
            }
        }
        return null;
    }
}
TOP

Related Classes of com.dci.intellij.dbn.code.common.style.presets.iteration.IterationIgnoreWrappingPreset

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.