(Changes by lesya) Replacing inner Type class with int enum in Wrap interface in order to fix build

This commit is contained in:
Eugene Zhuravlev
2005-03-25 15:02:23 +03:00
parent baf674b2c5
commit e7933e2a10
5 changed files with 28 additions and 42 deletions
@@ -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;
}
@@ -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();
@@ -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);
}
@@ -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);
@@ -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) {