Browse Source

striplinecomments comment nested text value

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@537021 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
79901525e8
3 changed files with 72 additions and 0 deletions
  1. +4
    -0
      WHATSNEW
  2. +10
    -0
      src/main/org/apache/tools/ant/filters/StripLineComments.java
  3. +58
    -0
      src/tests/antunit/filters/striplinecomments-test.xml

+ 4
- 0
WHATSNEW View File

@@ -128,6 +128,10 @@ Other changes:

* <concat> is now usable as a single-element ResourceCollection.

* It is now possible to provide the value of a <striplinecomments> filter's
<comment> nested element as nested text instead of using the 'value'
attribute.


Changes from Ant 1.6.5 to Ant 1.7.0
===================================


+ 10
- 0
src/main/org/apache/tools/ant/filters/StripLineComments.java View File

@@ -219,5 +219,15 @@ public final class StripLineComments
public final String getValue() {
return value;
}

/**
* Alt. syntax to set the prefix for this type of line comment.
*
* @param comment The prefix for a line comment of this type.
* Must not be <code>null</code>.
*/
public void addText(String comment) {
setValue(comment);
}
}
}

+ 58
- 0
src/tests/antunit/filters/striplinecomments-test.xml View File

@@ -0,0 +1,58 @@
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />

<property name="br" value="${line.separator}" />

<string id="input">foo
#pound
bar
//java sl
baz
REMark
</string>

<macrodef name="test">
<attribute name="lines" />
<element name="comments" implicit="true" />
<sequential>
<au:assertTrue>
<resourcecount count="@{lines}">
<tokens>
<concat>
<resource refid="input" />
<filterchain>
<striplinecomments>
<comments />
</striplinecomments>
<ignoreblank />
</filterchain>
</concat>
</tokens>
</resourcecount>
</au:assertTrue>
</sequential>
</macrodef>

<target name="testBasic">
<test lines="5">
<comment value="#" />
</test>
</target>

<target name="testMultiple">
<test lines="3">
<comment value="#" />
<comment value="//" />
<comment value="REM" />
</test>
</target>

<target name="testNestedText">
<test lines="3">
<comment>#</comment>
<comment>//</comment>
<comment>REM</comment>
</test>
</target>

</project>

Loading…
Cancel
Save