IDEA-103320 Android/XML code style: add "Insert line break after last attribute" option

This commit is contained in:
Eugene Kudelevsky
2013-10-25 16:31:47 +04:00
parent 019a43e152
commit 49ea461652
4 changed files with 22 additions and 0 deletions
@@ -93,6 +93,11 @@ public class HtmlPolicy extends XmlFormattingPolicy {
return false;
}
@Override
public boolean insertLineBreakAfterLastAttribute(XmlAttribute attribute) {
return false;
}
@Override
public boolean insertLineBreakAfterTagBegin(XmlTag tag) {
return false;
@@ -96,6 +96,16 @@ public class SyntheticBlock extends AbstractSyntheticBlock implements Block, Rea
return Spacing.createSafeSpacing(myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines());
}
if (type1 == XmlElementType.XML_ATTRIBUTE && (type2 == XmlTokenType.XML_TAG_END || type2 == XmlTokenType.XML_EMPTY_ELEMENT_END)) {
final PsiElement psi1 = node1.getPsi();
if (psi1 instanceof XmlAttribute && myXmlFormattingPolicy.insertLineBreakAfterLastAttribute((XmlAttribute)psi1)) {
return Spacing.createSpacing(0, 0, 1,
myXmlFormattingPolicy.getShouldKeepLineBreaks(),
myXmlFormattingPolicy.getKeepBlankLines());
}
}
if (type2 == XmlElementType.XML_EMPTY_ELEMENT_END && myXmlFormattingPolicy.addSpaceIntoEmptyTag()) {
return Spacing.createSpacing(1, 1, 0,
myXmlFormattingPolicy.getShouldKeepLineBreaks(),
@@ -90,6 +90,8 @@ public abstract class XmlFormattingPolicy {
public abstract boolean insertLineBreakBeforeFirstAttribute(XmlAttribute attribute);
public abstract boolean insertLineBreakAfterLastAttribute(XmlAttribute attribute);
public abstract boolean insertLineBreakAfterTagBegin(XmlTag tag);
public abstract boolean removeLineBreakBeforeTag(XmlTag xmlTag);
@@ -48,6 +48,11 @@ public class XmlPolicy extends XmlFormattingPolicy{
return false;
}
@Override
public boolean insertLineBreakAfterLastAttribute(XmlAttribute attribute) {
return false;
}
@Override
public boolean insertLineBreakAfterTagBegin(XmlTag tag) {
return false;