Browse Source

Change reporting of problems creating elements within Task containers to

say that the container does not support the given nested element.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274365 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
662f68f096
3 changed files with 15 additions and 23 deletions
  1. +8
    -3
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  2. +7
    -15
      src/main/org/apache/tools/ant/UnknownElement.java
  3. +0
    -5
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java

+ 8
- 3
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -503,6 +503,13 @@ public class IntrospectionHelper implements BuildListener {
}
}

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 @@ public class IntrospectionHelper implements BuildListener {
}
}
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);


+ 7
- 15
src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -271,10 +271,10 @@ public class UnknownElement extends Task {

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 @@ public class UnknownElement extends Task {
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 @@ public class UnknownElement extends Task {
* @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 @@ public class UnknownElement extends Task {
* @param ue The UnknownElement to create the real task for.
* Must not be <code>null</code>.
* @param w Ignored.
* @param onTopLevel Whether or not this is definitely trying to create
* a task. If this is <code>true</code> and the
* task name is not recognised, a BuildException
* is thrown.
*
* @return the task specified by the given unknown element, or
* <code>null</code> if the task name is not recognised and
* onTopLevel is <code>false</code>.
* <code>null</code> 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());


+ 0
- 5
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -846,11 +846,6 @@ public class ProjectHelper2 extends ProjectHelper {
Attributes attrs,
AntXMLContext context)
throws SAXParseException {
// this element
RuntimeConfigurable wrapper = context.currentWrapper();

Object element = wrapper.getProxy();
// return ProjectHelper2.nestedElementHandler;
return ProjectHelper2.elementHandler;
}



Loading…
Cancel
Save