[112967] poor performance on large documents. Fix to annotation children, and Text nodes
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
index 55a67c4..1f8a5bd 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
@@ -31,6 +31,21 @@
protected void handleNodeChanged(Node node)
{
+ // Make sure that the node is in the XSD Schema namespace. We don't need to
+ // reconcile the model for other nodes like text or nodes in other namespaces
+ // like the ones normally occurring in annotations.
+
+ try
+ {
+ if (!shouldReconcileModelFor(node))
+ {
+ return;
+ }
+ }
+ catch (Exception e)
+ {
+ }
+
if (node instanceof Element)
{
XSDConcreteComponent concreteComponent = schema.getCorrespondingComponent(node);
@@ -78,7 +93,45 @@
}
}
}
-
+
+ /**
+ * Checks if a change to the given node should trigger a model update.
+ *
+ * @param changedNode
+ * the DOM node to test.
+ * @return true if the change to the given node should trigger a model update.
+ */
+ protected boolean shouldReconcileModelFor(Node changedNode)
+ {
+ // No need to reconcile if the node is in a different namespace as it is the
+ // case for nodes deeply nested in appinfo or documentation elements.
+
+ String nodeNamespace = changedNode.getNamespaceURI();
+ String schemaNamespace = schema.getSchemaForSchemaNamespace();
+
+ if (!schemaNamespace.equals(nodeNamespace))
+ {
+ return false;
+ }
+
+ // When a child node is added to an appinfo or documentation element
+ // No need to reconcile if the node is the first child of appinfo or documentation
+ // elements.
+
+ Node parentNode = changedNode.getParentNode();
+
+ if (parentNode != null)
+ {
+ String nodeName = changedNode.getLocalName();
+
+ if (XSDConstants.APPINFO_ELEMENT_TAG.equals(nodeName) || XSDConstants.DOCUMENTATION_ELEMENT_TAG.equals(nodeName))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty)
{
if (!isDirty)
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/util/ModelReconcileAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/util/ModelReconcileAdapter.java
index a6fc072..a0bba52 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/util/ModelReconcileAdapter.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/util/ModelReconcileAdapter.java
@@ -20,6 +20,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.Text;
public abstract class ModelReconcileAdapter extends DocumentAdapter implements IModelStateListener
{
@@ -78,8 +79,7 @@
public void handleNotifyChange(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index)
{
- //Node n = (Node)notifier;
- //System.out.println("nodeChanged(" + eventType + ")" + n.getNodeName());
+ Node node = (Node)notifier;
switch (eventType)
{
case INodeNotifier.ADD:
@@ -97,9 +97,20 @@
}
case INodeNotifier.CHANGE:
case INodeNotifier.STRUCTURE_CHANGED:
+ {
+ handleNodeChanged(node);
+ break;
+ }
case INodeNotifier.CONTENT_CHANGED:
{
- Node node = (Node)notifier;
+ // If the only thing changed was the content of a text node
+ // then we don't want to reconcile.
+
+ if (feature instanceof Text)
+ {
+ break;
+ }
+
handleNodeChanged(node);
break;
}