Change-Id: Id41a5543b4e4639eb8c9943463587168c90f9ff4
}
private boolean newlineBeforeElementOpen(Element element, int depth) {
+ if (hasBlankLineAbove()) {
+ return false;
+ }
+
if (mPrefs.removeEmptyLines || depth <= 0) {
return false;
}
}
private boolean newlineAfterElementClose(Element element, int depth) {
+ if (hasBlankLineAbove()) {
+ return false;
+ }
+
return element.getParentNode().getNodeType() == Node.ELEMENT_NODE
&& !keepElementAsSingleLine(depth - 1, (Element) element.getParentNode());
}
import junit.framework.TestCase;
+@SuppressWarnings("javadoc")
public class XmlPrettyPrinterTest extends TestCase {
@Override
protected void setUp() throws Exception {
"\n" +
"</foo>");
}
+
+ public void testCommentHandling2() throws Exception {
+ checkFormat(
+ XmlFormatPreferences.create(), XmlFormatStyle.LAYOUT,
+ "<foo >\n" +
+ " <!-- multi -->\n" +
+ "\n" +
+ " <bar />\n" +
+ "</foo>",
+
+ "<foo >\n" +
+ "\n" +
+ " <!-- multi -->\n" +
+ "\n" +
+ " <bar />\n" +
+ "\n" +
+ "</foo>");
+ }
}