Return-Path: Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Delivered-To: mailing list dev@ant.apache.org Received: (qmail 55036 invoked by uid 500); 1 Apr 2003 14:59:59 -0000 Received: (qmail 55033 invoked from network); 1 Apr 2003 14:59:58 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 1 Apr 2003 14:59:58 -0000 Received: (qmail 91313 invoked by uid 1142); 1 Apr 2003 14:59:58 -0000 Date: 1 Apr 2003 14:59:58 -0000 Message-ID: <20030401145958.91312.qmail@icarus.apache.org> From: conor@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant/helper ProjectHelper2.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N conor 2003/04/01 06:59:58 Modified: src/main/org/apache/tools/ant IntrospectionHelper.java UnknownElement.java src/main/org/apache/tools/ant/helper ProjectHelper2.java Log: Change reporting of problems creating elements within Task containers to say that the container does not support the given nested element. Revision Changes Path 1.50 +8 -3 ant/src/main/org/apache/tools/ant/IntrospectionHelper.java Index: IntrospectionHelper.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -w -u -r1.49 -r1.50 --- IntrospectionHelper.java 7 Mar 2003 11:22:59 -0000 1.49 +++ IntrospectionHelper.java 1 Apr 2003 14:59:58 -0000 1.50 @@ -503,6 +503,13 @@ } } + public void throwNotSupported(Project project, Object parent, + String elementName) { + String msg = project.getElementName(parent) + + " doesn't support the nested \"" + elementName + "\" element."; + throw new BuildException(msg); + } + /** * Creates a named nested element. Depending on the results of the * initial introspection, either a method in the given parent instance @@ -538,9 +545,7 @@ } } if (nc == null) { - String msg = project.getElementName(parent) + - " doesn't support the nested \"" + elementName + "\" element."; - throw new BuildException(msg); + throwNotSupported(project, parent, elementName); } try { Object nestedElement = nc.create(parent); 1.42 +7 -15 ant/src/main/org/apache/tools/ant/UnknownElement.java Index: UnknownElement.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/UnknownElement.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -w -u -r1.41 -r1.42 --- UnknownElement.java 7 Mar 2003 11:22:59 -0000 1.41 +++ UnknownElement.java 1 Apr 2003 14:59:58 -0000 1.42 @@ -271,10 +271,10 @@ if (!ih.supportsNestedElement(child.getTag()) && parent instanceof TaskContainer) { - realChild = makeTask(child, childWrapper, false); + realChild = makeTask(child, childWrapper); if (realChild == null) { - throw getNotFoundException("task", child.getTag()); + ih.throwNotSupported(getProject(), parent, child.getTag()); } // XXX DataTypes will be wrapped or treated like normal components @@ -286,7 +286,8 @@ task.setOwningTarget(this.getOwningTarget()); task.init(); } else { - // What ? Add data type ? createElement ? + // should not happen + ih.throwNotSupported(getProject(), parent, child.getTag()); } } else { realChild @@ -318,7 +319,7 @@ * @return the task or data type represented by the given unknown element. */ protected Object makeObject(UnknownElement ue, RuntimeConfigurable w) { - Object o = makeTask(ue, w, true); + Object o = makeTask(ue, w); if (o == null) { o = getProject().createDataType(ue.getTag()); } @@ -334,21 +335,12 @@ * @param ue The UnknownElement to create the real task for. * Must not be null. * @param w Ignored. - * @param onTopLevel Whether or not this is definitely trying to create - * a task. If this is true and the - * task name is not recognised, a BuildException - * is thrown. * * @return the task specified by the given unknown element, or - * null if the task name is not recognised and - * onTopLevel is false. + * null if the task name is not recognised. */ - protected Task makeTask(UnknownElement ue, RuntimeConfigurable w, - boolean onTopLevel) { + protected Task makeTask(UnknownElement ue, RuntimeConfigurable w) { Task task = getProject().createTask(ue.getTag()); - if (task == null && !onTopLevel) { - throw getNotFoundException("task", ue.getTag()); - } if (task != null) { task.setLocation(getLocation()); 1.16 +0 -5 ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Index: ProjectHelper2.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -u -r1.15 -r1.16 --- ProjectHelper2.java 10 Feb 2003 14:13:33 -0000 1.15 +++ ProjectHelper2.java 1 Apr 2003 14:59:58 -0000 1.16 @@ -846,11 +846,6 @@ Attributes attrs, AntXMLContext context) throws SAXParseException { - // this element - RuntimeConfigurable wrapper = context.currentWrapper(); - - Object element = wrapper.getProxy(); -// return ProjectHelper2.nestedElementHandler; return ProjectHelper2.elementHandler; }