ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r439869 - in /ant/core/trunk: WHATSNEW src/etc/testcases/taskdefs/macrodef.xml src/main/org/apache/tools/ant/taskdefs/MacroInstance.java src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java
Date Sun, 03 Sep 2006 22:56:35 GMT
Author: peterreilly
Date: Sun Sep  3 15:56:35 2006
New Revision: 439869

URL: http://svn.apache.org/viewvc?view=rev&rev=439869
Log:
add text for macro element. Bugzilla report 36803

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/etc/testcases/taskdefs/macrodef.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=439869&r1=439868&r2=439869
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Sep  3 15:56:35 2006
@@ -13,6 +13,7 @@
 * <zip filesonly="true"> included empty directories.  Bugzilla report 40258.
 * Invalid hash code of Target causes XmlLogger to fail.
   Bugzilla report 40207.
+* Macro element did not include top level Text. Bugzilla report 36803.
 
 Other changes:
 --------------

Modified: ant/core/trunk/src/etc/testcases/taskdefs/macrodef.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/macrodef.xml?view=diff&rev=439869&r1=439868&r2=439869
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/macrodef.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/macrodef.xml Sun Sep  3 15:56:35 2006
@@ -256,4 +256,18 @@
     </macrodef>
     <nobacktrace/>
   </target>
+
+  <target name="top-level-text">
+    <macrodef name="top">
+      <element name="em"/>
+      <sequential>
+        <echo><em/></echo>
+      </sequential>
+    </macrodef>
+    <top>
+      <em>
+        Hello World
+      </em>
+    </top>
+  </target>
 </project>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java?view=diff&rev=439869&r1=439868&r2=439869
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java Sun Sep  3 15:56:35
2006
@@ -133,7 +133,7 @@
             if (presentElements.get(name) != null) {
                 throw new BuildException("Element " + name + " already present");
             }
-            presentElements.put(name, ue.getChildren());
+            presentElements.put(name, ue);
         }
     }
 
@@ -297,8 +297,9 @@
                     ret.addChild(child);
                 }
             } else {
-                List list = (List) presentElements.get(tag);
-                if (list == null) {
+                UnknownElement presentElement =
+                    (UnknownElement) presentElements.get(tag);
+                if (presentElement == null) {
                     if (!templateElement.isOptional()) {
                         throw new BuildException(
                             "Required nested element "
@@ -306,11 +307,19 @@
                     }
                     continue;
                 }
-                for (Iterator i = list.iterator();
-                     i.hasNext();) {
-                    UnknownElement child = copy((UnknownElement) i.next());
-                    rc.addChild(child.getWrapper());
-                    ret.addChild(child);
+                String presentText =
+                    presentElement.getWrapper().getText().toString();
+                if (!"".equals(presentText)) {
+                    rc.addText(macroSubs(presentText, localAttributes));
+                }
+                List list = presentElement.getChildren();
+                if (list != null) {
+                    for (Iterator i = list.iterator();
+                         i.hasNext();) {
+                        UnknownElement child = copy((UnknownElement) i.next());
+                        rc.addChild(child.getWrapper());
+                        ret.addChild(child);
+                    }
                 }
             }
         }

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java?view=diff&rev=439869&r1=439868&r2=439869
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java Sun Sep 
3 15:56:35 2006
@@ -150,5 +150,9 @@
             "Checking if a back trace is created",
             "following error occurred");
     }
+
+    public void testTopLevelText() {
+        expectLogContaining("top-level-text", "Hello World");
+    }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message