diff --git a/source/com/intellij/newCodeFormatting/Wrap.java b/source/com/intellij/newCodeFormatting/Wrap.java index bc8e7ccb4c9f..dcf951b149d9 100644 --- a/source/com/intellij/newCodeFormatting/Wrap.java +++ b/source/com/intellij/newCodeFormatting/Wrap.java @@ -1,21 +1,8 @@ package com.intellij.newCodeFormatting; public interface Wrap { - class Type{ - private final String myName; - - private Type(final String name) { - myName = name; - } - - public static final Type DO_NOT_WRAP = new Type("NONE"); - public static final Type WRAP_AS_NEEDED = new Type("NORMAL"); - public static final Type CHOP_IF_NEEDED = new Type("CHOP"); - public static final Type WRAP_ALWAYS = new Type("ALWAYS"); - - public String toString() { - return myName; - } - } - + public int ALWAYS = 0; + public int NORMAL = 1; + public int NONE = 2; + public int CHOP_DOWN_IF_LONG = 3; } diff --git a/source/com/intellij/newCodeFormatting/impl/FormatProcessor.java b/source/com/intellij/newCodeFormatting/impl/FormatProcessor.java index 37b96bab652c..dd6fea281553 100644 --- a/source/com/intellij/newCodeFormatting/impl/FormatProcessor.java +++ b/source/com/intellij/newCodeFormatting/impl/FormatProcessor.java @@ -1,10 +1,9 @@ package com.intellij.newCodeFormatting.impl; +import com.intellij.newCodeFormatting.Block; +import com.intellij.newCodeFormatting.FormattingModel; import com.intellij.openapi.util.TextRange; import com.intellij.psi.codeStyle.CodeStyleSettings; -import com.intellij.newCodeFormatting.FormattingModel; -import com.intellij.newCodeFormatting.Block; -import com.intellij.newCodeFormatting.Wrap; import java.util.*; @@ -210,7 +209,7 @@ class FormatProcessor { if (wrap == null) return false; if (!isSuitableInTheCurrentPosition(wrap)) return false; if (wrap.isIsActive()) return true; - final Wrap.Type type = wrap.getType(); + final WrapImpl.Type type = wrap.getType(); if (type == WrapImpl.Type.WRAP_ALWAYS) return true; if (type == WrapImpl.Type.WRAP_AS_NEEDED || type == WrapImpl.Type.CHOP_IF_NEEDED) { return lineOver(); diff --git a/source/com/intellij/newCodeFormatting/impl/FormatterImpl.java b/source/com/intellij/newCodeFormatting/impl/FormatterImpl.java index bc498b7e2d09..4f1e7e73f8e1 100644 --- a/source/com/intellij/newCodeFormatting/impl/FormatterImpl.java +++ b/source/com/intellij/newCodeFormatting/impl/FormatterImpl.java @@ -22,7 +22,7 @@ public class FormatterImpl extends Formatter implements ApplicationComponent{ return new IndentImpl(IndentImpl.Type.NONE, 0,0); } - public Wrap createWrap(Wrap.Type type, boolean wrapFirstElement) { + public Wrap createWrap(int type, boolean wrapFirstElement) { return new WrapImpl(type, wrapFirstElement); } diff --git a/testSource/com/intellij/psi/formatter/AbstractXmlBlock.java b/testSource/com/intellij/psi/formatter/AbstractXmlBlock.java index 2c1bfe058874..7d11195d391b 100644 --- a/testSource/com/intellij/psi/formatter/AbstractXmlBlock.java +++ b/testSource/com/intellij/psi/formatter/AbstractXmlBlock.java @@ -1,20 +1,20 @@ package com.intellij.psi.formatter; +import com.intellij.lang.ASTNode; import com.intellij.newCodeFormatting.*; import com.intellij.openapi.util.TextRange; -import com.intellij.psi.impl.source.tree.ElementType; -import com.intellij.psi.impl.source.tree.CompositeElement; -import com.intellij.psi.impl.source.tree.LeafElement; -import com.intellij.psi.impl.source.parsing.ChameleonTransforming; -import com.intellij.psi.impl.source.SourceTreeToPsiMap; -import com.intellij.psi.codeStyle.CodeStyleSettings; -import com.intellij.psi.tree.IElementType; import com.intellij.psi.PsiElement; +import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.impl.source.SourceTreeToPsiMap; +import com.intellij.psi.impl.source.parsing.ChameleonTransforming; +import com.intellij.psi.impl.source.tree.CompositeElement; +import com.intellij.psi.impl.source.tree.ElementType; +import com.intellij.psi.impl.source.tree.LeafElement; +import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlTag; -import com.intellij.lang.ASTNode; -import java.util.List; import java.util.ArrayList; +import java.util.List; public abstract class AbstractXmlBlock implements Block { @@ -111,11 +111,11 @@ public abstract class AbstractXmlBlock implements Block { return true; } - private Wrap.Type getWrapType(final int type) { - if (type == CodeStyleSettings.DO_NOT_WRAP) return Wrap.Type.DO_NOT_WRAP; - if (type == CodeStyleSettings.WRAP_ALWAYS) return Wrap.Type.WRAP_ALWAYS; - if (type == CodeStyleSettings.WRAP_AS_NEEDED) return Wrap.Type.WRAP_AS_NEEDED; - return Wrap.Type.CHOP_IF_NEEDED; + private int getWrapType(final int type) { + if (type == CodeStyleSettings.DO_NOT_WRAP) return Wrap.NONE; + if (type == CodeStyleSettings.WRAP_ALWAYS) return Wrap.ALWAYS; + if (type == CodeStyleSettings.WRAP_AS_NEEDED) return Wrap.NORMAL; + return Wrap.CHOP_DOWN_IF_LONG; } private Alignment chooseAlignment(final ASTNode child, final Alignment attrAlignment, final Alignment textAlignment) { @@ -273,9 +273,9 @@ public abstract class AbstractXmlBlock implements Block { return (XmlTag)SourceTreeToPsiMap.treeElementToPsi(node); } - protected abstract Wrap.Type getWrappingTypeForTagEnd(final XmlTag xmlTag); + protected abstract int getWrappingTypeForTagEnd(final XmlTag xmlTag); - protected abstract Wrap.Type getWrappingTypeForTagBegin(); + protected abstract int getWrappingTypeForTagBegin(); protected abstract boolean insertLineBreakBeforeTag(final XmlTag xmlTag); diff --git a/testSource/com/intellij/psi/formatter/XmlBlock.java b/testSource/com/intellij/psi/formatter/XmlBlock.java index f73fb5519bf4..21f4a4c7e369 100644 --- a/testSource/com/intellij/psi/formatter/XmlBlock.java +++ b/testSource/com/intellij/psi/formatter/XmlBlock.java @@ -32,12 +32,12 @@ public class XmlBlock extends AbstractXmlBlock { return false; } - protected Wrap.Type getWrappingTypeForTagEnd(final XmlTag xmlTag) { - return xmlTag.getSubTags().length > 0 ? Wrap.Type.WRAP_ALWAYS : Wrap.Type.WRAP_AS_NEEDED; + protected int getWrappingTypeForTagEnd(final XmlTag xmlTag) { + return xmlTag.getSubTags().length > 0 ? Wrap.ALWAYS : Wrap.NORMAL; } - protected Wrap.Type getWrappingTypeForTagBegin() { - return Wrap.Type.WRAP_ALWAYS; + protected int getWrappingTypeForTagBegin() { + return Wrap.ALWAYS; } protected boolean isTextElement(XmlTag tag) {