ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant XmlLogger.java
Date Thu, 16 Jan 2003 14:45:25 GMT
conor       2003/01/16 06:45:24

  Modified:    src/main/org/apache/tools/ant XmlLogger.java
  Log:
  Associate messages with the correct tasks in XML Logger.
  Where an UnknownElement is involved, need to look a little harder
  
  Commented out for now the code which associated a project level message
  with the currently active element - better to have it go to the project
  level
  
  PR:	7926
  
  Revision  Changes    Path
  1.32      +33 -5     jakarta-ant/src/main/org/apache/tools/ant/XmlLogger.java
  
  Index: XmlLogger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/XmlLogger.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -w -u -r1.31 -r1.32
  --- XmlLogger.java	25 Jul 2002 15:21:01 -0000	1.31
  +++ XmlLogger.java	16 Jan 2003 14:45:24 -0000	1.32
  @@ -62,6 +62,7 @@
   import java.io.Writer;
   import java.util.Hashtable;
   import java.util.Stack;
  +import java.util.Enumeration;
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
   import org.apache.tools.ant.util.DOMElementWriter;
  @@ -311,11 +312,11 @@
        *              Will not be <code>null</code>.
        */
       public void taskStarted(BuildEvent event) {
  -        Task task = event.getTask();
           TimedElement taskElement = new TimedElement();
           taskElement.startTime = System.currentTimeMillis();
           taskElement.element = doc.createElement(TASK_TAG);
   
  +        Task task = event.getTask();
           String name = event.getTask().getTaskName();
           taskElement.element.setAttribute(NAME_ATTR, name);
           taskElement.element.setAttribute(LOCATION_ATTR,
  @@ -360,6 +361,31 @@
           }
       }
   
  +
  +    /**
  +     * Get the TimedElement associated with a task.
  +     *
  +     * Where the task is not found directly, search for unknown elements which
  +     * may be hiding the real task
  +     */
  +    private TimedElement getTaskElement(Task task) {
  +        TimedElement element = (TimedElement) tasks.get(task);
  +        if (element != null) {
  +            return element;
  +        }
  +
  +        for (Enumeration e = tasks.keys(); e.hasMoreElements();) {
  +            Task key = (Task) e.nextElement();
  +            if (key instanceof UnknownElement) {
  +                if (((UnknownElement) key).getTask() == task) {
  +                    return (TimedElement) tasks.get(key);
  +                }
  +            }
  +        }
  +
  +        return null;
  +    }
  +
       /**
        * Fired when a message is logged, this adds a message element to the
        * most appropriate parent element (task, target or build) and records
  @@ -401,12 +427,13 @@
   
           Target target = event.getTarget();
           if (task != null) {
  -            parentElement = (TimedElement) tasks.get(task);
  +            parentElement = getTaskElement(task);
           }
           if (parentElement == null && target != null) {
               parentElement = (TimedElement) targets.get(target);
           }
   
  +        /*
           if (parentElement == null) {
               Stack threadStack
                       = (Stack) threadStacks.get(Thread.currentThread());
  @@ -416,6 +443,7 @@
                   }
               }
           }
  +        */
   
           if (parentElement != null) {
               parentElement.element.appendChild(messageElement);
  
  
  

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


Mime
View raw message