ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephane Chauvin <SChau...@cardiff.com>
Subject [SUBMIT] FilterReader for compilation directives
Date Wed, 14 Aug 2002 18:43:06 GMT
Hi all,

I propose a FilterReader named 'CommentOut' that puts in comment a line or a
block for Java, HTML/XML/XSLT and JSP files. A tag in the code with a
condition will enable or disable the line conversion.

Here's an example how the CommentOut FilterReader works:
    <filterreader classname="org.apache.tools.ant.filters.CommentOut">
      <param name="condition" value="debug"/>
    </filterreader>

If the source code is:
    log("-->method()"); // @IF_LINE@ debug
<!-- @IF_BLOCK@ debug --> <myXMLtag attribute="test"/>

The result is:
//    log("-->method()"); // @IF_LINE@ debug
<!-- @IF_BLOCK@ debug <myXMLtag attribute="test"/>

My motivation was to remove the debugging methods for the release code
compilation because they may slow down the runtime, and to not provide a
part of a code, depending if it is a customer release or a demo release.
A solution was to do a compilation directive. I extended the idea to the
other file types. Also, the FilterReader checks first if the line/block was
already enabled, and is able to disable it. It means that the conversion is
reversible.

Please see the documentation for more examples and for a table with the
different conversions. The code is compiling with the JDK1.1.8. A TestCase
parses a file that contains about 115 conditions.

Your feedback is very much appreciated,
Stephane.


Mime
View raw message