Bug 396219 - Intentionally referencing a non-existent id in Augment task
shows error editor
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java
index 5c8423f..1c2bc7e 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/AntEditorTests.java
@@ -263,6 +263,18 @@
assertTrue("The hover text must contain the augmented element 'foo'", text.indexOf("foo") > -1);
}
+ /**
+ * Tests that the Ant editor is resilient to using an Augment task that references an unknown id
+ *
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=396219
+ * @throws Exception
+ */
+ public void testAugmentMissingId() throws Exception {
+ IFile file = getIFile("bug396219.ent");
+ IEditorPart part = EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
+ assertTrue("The opened editor must be the AntEditor", part instanceof AntEditor);
+ }
+
public void testHoverRegionWithSpaces() throws PartInitException, BadLocationException {
IFile file= getIFile("refid.xml");
AntEditor editor= (AntEditor)EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
diff --git a/ant/org.eclipse.ant.tests.ui/testbuildfiles/bug396219.ent b/ant/org.eclipse.ant.tests.ui/testbuildfiles/bug396219.ent
new file mode 100644
index 0000000..0dcb688
--- /dev/null
+++ b/ant/org.eclipse.ant.tests.ui/testbuildfiles/bug396219.ent
@@ -0,0 +1,10 @@
+<project>
+ <path id="path1"/>
+ <resource id="resource1"/>
+ <propertyset id="property1"/>
+ <target name="augment">
+ <augment id="path">
+ <pathelement location="/foo"/>
+ </augment>
+ </target>
+</project>
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntAugmentTaskNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntAugmentTaskNode.java
index f35e2aa..9c418ed 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntAugmentTaskNode.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntAugmentTaskNode.java
@@ -55,6 +55,11 @@
//either a system exit or setting of system property was attempted
handleBuildException(new BuildException(AntModelMessages.AntTaskNode_0), AntEditorPreferenceConstants.PROBLEM_SECURITY);
}
+ catch(IllegalStateException ise) {
+ //this is thrown when the id to augment does not exist
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=396219
+ handleBuildException(new BuildException(ise), AntEditorPreferenceConstants.PROBLEM_TASKS);
+ }
return false;
}