OSDN Git Service

XML Comment Formatting Fixes. DO NOT MERGE.
authorTor Norbye <tnorbye@google.com>
Mon, 3 Oct 2011 16:15:23 +0000 (09:15 -0700)
committerTor Norbye <tnorbye@google.com>
Mon, 3 Oct 2011 23:28:08 +0000 (16:28 -0700)
commit2c07fc348d85836bff4d1f9ca656d96898a0833c
tree888ae963628bf0820195e459231ac585c35dd223
parent22b38a190fa658924a665989d99dc508d3e88739
XML Comment Formatting Fixes. DO NOT MERGE.

This changeset fixes issue 20452 related to XML comment
handling. There are several changes.

First it fixes a truncation bug where the last character in a comment
could get erased.

Second it makes sure we don't end up with double blank lines, since
there were cases where the comment formatter would insert a newline
(to preserve newlines after comments in the original document) and a
subsequent element or close tag would also insert a newline (which is
where the normal blank lines are added). Now the code will peek at the
write buffer to make sure we haven't already added a blank line.

Third, it attempts to handle multiline comments a bit better such that
the code which preserves indentation of the first comment line will
dedent down to the minimum indentation level of the block comment.
This means that we will format
   <!-- First
   Second -->
into
   <!--
   First
   Second
   -->
instead of
   <!--
        First
   Second
   -->
as the code did up until now. (The current handling was there to make
    <!-- This is
         a comment -->
format into
    <!--
         This is
         a comment
    -->
)

Unit tests.

Change-Id: I7201b55a2c824c3c0b43287e853bc9b75d74ed7f
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlAutoEditStrategy.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/XmlPrettyPrinter.java
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/formatting/XmlPrettyPrinterTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java