summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-07-19 16:57:57 (EDT)
committer pelder2006-07-19 16:57:57 (EDT)
commit1ecfe7bfbf220454cd79889f1c0b6acfc77d88c0 (patch)
tree1fff0930dd791e2b09ee518cf2058e58e7d2c5ff
parentf0411e43599a6e127834d22997d220cd5a67efc8 (diff)
downloadorg.eclipse.jet-1ecfe7bfbf220454cd79889f1c0b6acfc77d88c0.zip
org.eclipse.jet-1ecfe7bfbf220454cd79889f1c0b6acfc77d88c0.tar.gz
org.eclipse.jet-1ecfe7bfbf220454cd79889f1c0b6acfc77d88c0.tar.bz2
[148443] Fix removeAttribute on EMF-based models.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/JETBundleDescriptor.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java3
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java43
3 files changed, 47 insertions, 3 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/JETBundleDescriptor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/JETBundleDescriptor.java
index f2cc147..fc243c0 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/JETBundleDescriptor.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/JETBundleDescriptor.java
@@ -95,7 +95,7 @@ public class JETBundleDescriptor implements IJETBundleDescriptor
*/
public String getName()
{
- return name;
+ return name == null ? id : name;
}
/* (non-Javadoc)
@@ -103,7 +103,7 @@ public class JETBundleDescriptor implements IJETBundleDescriptor
*/
public String getDescription()
{
- return description;
+ return description == null ? "" : description; //$NON-NLS-1$
}
/* (non-Javadoc)
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java
index 9ed50e1..9c7eb39 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EObjectInspector.java
@@ -1067,7 +1067,8 @@ public class EObjectInspector implements IElementInspector, INodeInspectorExtens
{
EObject eObject = (EObject)element;
final Setting setting = getNamedAttributeInternal(eObject, new ExpandedName(name));
- if(setting != null && setting.isSet() && setting.getEStructuralFeature().isUnsettable()) {
+// if(setting != null && setting.isSet() && setting.getEStructuralFeature().isUnsettable()) {
+ if(setting != null) {
setting.unset();
}
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
index 227bc57..de95b7e 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
@@ -699,6 +699,49 @@ public class EObjectInspectorTests extends TestCase {
assertTrue("cust not in afterList", !afterList.contains(emp));
}
+ public void testRemoveAttribute_emf() {
+ EStructuralFeature nameFeature = emfRoot.eClass().getEStructuralFeature("name");
+ assertTrue("setup: name is not set", emfRoot.eIsSet(nameFeature));
+
+ inspector.removeAttribute(emfRoot, "name");
+
+ assertFalse("name is still set", emfRoot.eIsSet(nameFeature));
+ assertNull(inspector.getNamedAttribute(emfRoot, new ExpandedName("name")));
+ }
+
+ public void testRemoveAttribute_emf_nonexisting() {
+ final String attrName = "notAnAttribute";
+ EStructuralFeature nameFeature = emfRoot.eClass().getEStructuralFeature(attrName);
+ assertNull("setup: " + attrName + " is not set", nameFeature);
+
+ inspector.removeAttribute(emfRoot, attrName);
+
+ // success if we get here without someone throwing an exception
+ }
+
+ public void testRemoveAttribute_xml() {
+ ExpandedName enRootAttr = new ExpandedName("rootAttr");
+ Object originalRootAttr = inspector.getNamedAttribute(xmlRootElement, enRootAttr);
+ assertNotNull("setup: originalRootAttr is null", originalRootAttr);
+
+ inspector.removeAttribute(xmlRootElement, "rootAttr");
+
+ Object rootAttr = inspector.getNamedAttribute(xmlRootElement, enRootAttr);
+ assertNull("rootAttr should be null", rootAttr);
+ }
+
+ public void testRemoveAttribute_xsd() {
+ Object projectElement = xsdRootElement.eContents().get(0);
+
+ Object originalAttribute = inspector.getNamedAttribute(projectElement, new ExpandedName("name"));
+ assertNotNull("setup: originalAttribute is null", originalAttribute);
+
+ inspector.removeAttribute(projectElement, "name");
+
+ Object attribute = inspector.getNamedAttribute(projectElement, new ExpandedName("name"));
+ assertNull("attribute should be null", attribute);
+ }
+
public void testRemoveElement_xml() {
// EStructuralFeature feature = xmlRootElement.getAny().getEStructuralFeature(0);
EStructuralFeature feature = Bug130552Workaround.getEStructuralFeature(xmlRootElement.getAny(), 0);