diff -r ad3b9bde4308 xml.wsdl.model/src/org/netbeans/modules/xml/wsdl/model/impl/WSDLModelImpl.java --- a/xml.wsdl.model/src/org/netbeans/modules/xml/wsdl/model/impl/WSDLModelImpl.java Fri May 14 16:52:14 2010 +0400 +++ b/xml.wsdl.model/src/org/netbeans/modules/xml/wsdl/model/impl/WSDLModelImpl.java Mon May 17 22:45:41 2010 +0400 @@ -245,16 +255,20 @@ return getElementRegistry().getKnownElementNames(); } - public ChangeInfo prepareChangeInfo(List pathToRoot) { - ChangeInfo change = super.prepareChangeInfo(pathToRoot); + @Override + public ChangeInfo prepareChangeInfo(List pathToRoot, + List nsContextPathToRoot) { + ChangeInfo change = super.prepareChangeInfo(pathToRoot, nsContextPathToRoot); DocumentComponent parentComponent = findComponent(change.getRootToParentPath()); if (parentComponent == null) { return change; diff -r ad3b9bde4308 xml.xam/apichanges.xml --- a/xml.xam/apichanges.xml Fri May 14 16:52:14 2010 +0400 +++ b/xml.xam/apichanges.xml Mon May 17 22:45:41 2010 +0400 @@ -104,6 +104,25 @@ + + + Method AbstractDocumentModel.prepareChangeInfo() is replaced with a new one. + + + + + + The modufication is necessary for fixing issue #166177. + The old method {@link org.netbeans.modules.xml.xam.dom.AbstractDocumentModel#prepareChangeInfo(java.util.List)} + is marked as deprecated and a new one {@link org.netbeans.modules.xml.xam.dom.AbstractDocumentModel#prepareChangeInfo(java.util.List, java.util.List)} is created. + The new one contains additional parameter nsContextPathToRoot, which + is necessary for correct calculation of namespace context after + deletion of namespace prefix. See the issue for details. + + + + + Two new methods to enhance model's performance diff -r ad3b9bde4308 xml.xam/src/org/netbeans/modules/xml/xam/dom/AbstractDocumentModel.java --- a/xml.xam/src/org/netbeans/modules/xml/xam/dom/AbstractDocumentModel.java Fri May 14 16:52:14 2010 +0400 +++ b/xml.xam/src/org/netbeans/modules/xml/xam/dom/AbstractDocumentModel.java Mon May 17 22:45:41 2010 +0400 @@ -225,13 +225,36 @@ } /** - * Performs preparation stage of synchronization XDM --> XAM. * - * Be aware that the method isn't only called from XDM (XDMListener), - * but it also can be redifined. An example can be found in WSDL Model. + * @param pathToRoot + * @return + * @deprecated Use {@link org.netbeans.modules.xml.xam.dom.AbstractDocumentModel#prepareChangeInfo(java.util.List, java.util.List)} instead. It is necessary for fixing bug #166177. * */ public ChangeInfo prepareChangeInfo(List pathToRoot) { + return prepareChangeInfo(pathToRoot, pathToRoot); + } + + + /** + * Performs intermediate stage of synchronization XDM --> XAM. + * A new {@link org.netbeans.modules.xml.xam.dom.ChangeInfo} object + * is generated here. + * + * @param pathToRoot a path of DOM objects from root to changed one. + * @param nsContextPathToRoot Usually the same path as previous param, + * but in case of deletion it contains the same path from old model's tree. + * It is required in case of prefix declaration deletion, because the deleted + * declaration is present only in old model's tree. + * + * Be aware that the method is designed to be called only from XDM + * {@link org.netbeans.modules.xml.xdm.xam.XDMListener}, + * but it also can be redifined. An example can be found in + * {@link org.netbeans.modules.xml.wsdl.model.WSDLModel}. + * + */ + public ChangeInfo prepareChangeInfo(List pathToRoot, + List nsContextPathToRoot) { // we already handle change on root before enter here if (pathToRoot.size() < 1) { throw new IllegalArgumentException("pathToRoot here should be at least 1"); @@ -261,7 +284,7 @@ } QName currentQName = new QName(getAccess().lookupNamespaceURI( - current, pathToRoot), current.getLocalName()); + current, nsContextPathToRoot), current.getLocalName()); if (!(qnames.contains(currentQName))) { changedIsDomainElement = false; break; diff -r ad3b9bde4308 xml.xdm/src/org/netbeans/modules/xml/xdm/xam/XDMListener.java --- a/xml.xdm/src/org/netbeans/modules/xml/xdm/xam/XDMListener.java Fri May 14 16:52:14 2010 +0400 +++ b/xml.xdm/src/org/netbeans/modules/xml/xdm/xam/XDMListener.java Mon May 17 22:45:41 2010 +0400 @@ -182,9 +180,7 @@ assert namespacePathToRoot.size() == pathToRoot.size(); } // - ChangeInfo change = model.prepareChangeInfo(pathToRoot); + ChangeInfo change = model.prepareChangeInfo(pathToRoot, namespacePathToRoot); change.setAdded(isAdded); processChange(change); }