[118371] XMLCatalogIdResolver#resolve throws AssertionFailedException
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java
index c4e60eb..125df78 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/ModelQueryAdapterFactoryForHTML.java
@@ -107,17 +107,17 @@
/**
- * ModelQueryAdapterFactoryForHTML constructor comment.
- * Note: this is a case there the key is not exactly same
- * as the class we are after.
+ * ModelQueryAdapterFactoryForHTML constructor comment. Note: this is a
+ * case there the key is not exactly same as the class we are after.
*/
public ModelQueryAdapterFactoryForHTML() {
super(ModelQueryAdapter.class, true);
}
/**
- * We need this protected version to allow subclasses to
- * pass up standard behaviour.
+ * We need this protected version to allow subclasses to pass up standard
+ * behaviour.
+ *
* @param adapterKey
* @param registerAdapters
*/
@@ -138,9 +138,9 @@
if (modelStateNotifier != null) {
modelStateNotifier.removeModelStateListener(internalModelStateListener);
}
-
+
modelStateNotifier = null;
-
+
if (modelQueryAdapter != null) {
modelQueryAdapter.release();
}
@@ -149,8 +149,8 @@
/**
* createAdapter method comment.
*
- * XXX: we must make this method more independent of 'location'
- * (at least provide some fall-back method).
+ * XXX: we must make this method more independent of 'location' (at least
+ * provide some fall-back method).
*/
protected INodeAdapter createAdapter(INodeNotifier target) {
@@ -187,7 +187,12 @@
System.out.println("----------------ModelQueryAdapterFactoryForHTML... baseLocation : " + baseLocation); //$NON-NLS-1$
CMDocumentCache cmDocumentCache = new CMDocumentCache();
- URIResolver idResolver = new XMLCatalogIdResolver(baseLocation, model.getResolver());
+ URIResolver idResolver = null;
+
+ org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
+ if (baseLocation != null || resolver != null) {
+ idResolver = new XMLCatalogIdResolver(baseLocation, resolver);
+ }
ModelQuery modelQuery = new HTMLModelQueryImpl(cmDocumentCache, idResolver);
modelQuery.setEditMode(ModelQuery.EDIT_MODE_UNCONSTRAINED);
modelQueryAdapter = new ModelQueryAdapterImpl(cmDocumentCache, modelQuery, idResolver);
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/XHTMLAssociationProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/XHTMLAssociationProvider.java
index f9d1e2f..5a1eecf 100644
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/XHTMLAssociationProvider.java
+++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/XHTMLAssociationProvider.java
@@ -44,8 +44,10 @@
* @return
*/
public CMDocument getXHTMLCMDocument(String publicId, String systemId) {
+ if (idResolver == null)
+ return null;
String grammerURI = null;
- if (USE_QUICK_CACHE) {
+ if (USE_QUICK_CACHE) {
// In parsing a document, we get many identiical requests to this
// method, so instead of looking up (resolving) grammerURI each
// time,
@@ -68,15 +70,19 @@
if (grammerURI == null)
return null;
-
+
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88896
- // previously called the deprecated 2 argument form of getCMDocument, which eventually
- // resulted in empty string for type, which I don't think the infrastructure was prepared
- // for. So, I deleted deprecated methods, and switched to null.
+ // previously called the deprecated 2 argument form of getCMDocument,
+ // which eventually
+ // resulted in empty string for type, which I don't think the
+ // infrastructure was prepared
+ // for. So, I deleted deprecated methods, and switched to null.
// 'null' means to "create based on uri"
// and 'dtd' would work to mean load only those registered as dtd's
- // CMDocument cmDocument = documentManager.getCMDocument(publicId, grammerURI);
- //CMDocument cmDocument = documentManager.getCMDocument(publicId, grammerURI, "dtd");
+ // CMDocument cmDocument = documentManager.getCMDocument(publicId,
+ // grammerURI);
+ // CMDocument cmDocument = documentManager.getCMDocument(publicId,
+ // grammerURI, "dtd");
CMDocument cmDocument = documentManager.getCMDocument(publicId, grammerURI, null);
return cmDocument;
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
index 4145e26..25b5c08 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/ModelQueryAdapterFactoryForXML.java
@@ -169,7 +169,10 @@
if (org.eclipse.wst.sse.core.internal.util.Debug.displayInfo)
System.out.println("********XMLModelQueryImpl"); //$NON-NLS-1$
- idResolver = new XMLCatalogIdResolver(baseLocation, model.getResolver());
+ org.eclipse.wst.sse.core.internal.util.URIResolver resolver = model.getResolver();
+ if (baseLocation != null || resolver != null) {
+ idResolver = new XMLCatalogIdResolver(baseLocation, resolver);
+ }
modelQuery = new XMLModelQueryImpl(cmDocumentCache, idResolver);
// cs todo...
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java
index 0a24f26..367d43b 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLCatalogIdResolver.java
@@ -21,8 +21,9 @@
// TODO cs : remove this class and utilize the common URIResolver directly
-// We need to update some of the ModelQuery related code to pass the 'baseLocation' thru
-// and then there'll be node need for this class.
+// We need to update some of the ModelQuery related code to pass the
+// 'baseLocation' thru
+// and then there'll be node need for this class.
//
public class XMLCatalogIdResolver implements org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver {
protected String resourceLocation;
@@ -32,12 +33,21 @@
private XMLCatalogIdResolver() {
super();
}
+
private XMLCatalogIdResolver(String resourceLocation) {
this.resourceLocation = resourceLocation;
}
public XMLCatalogIdResolver(String resourceLocation, URIResolver uriresolver) {
this(resourceLocation);
+// this constructor should not be called with two null arguments.
+// If so, an assert will occur later when resolve is called.
+// See 118371 XMLCatalogIdResolver#resolve throws AssertionFailedException
+//
+// but, I'm not enabling this check now due to lateness in cycle.
+// if (resourceLocation == null && uriresolver == null) {
+// throw new IllegalArgumentException("both location and resolver can not be null");
+// }
this.uriresolver = uriresolver;
}
@@ -61,20 +71,22 @@
String result = systemId;
if (base == null) {
- base = getResourceLocation();
- // bug 117320, ensure base URI is 'protocal' qualified before passing it thru to URIResolver
- // bug 117424, we should be able to assume that the base location is non-null
- Assert.isNotNull(base, "Base location is expected to be non null.");
- base = URIHelper.addImpliedFileProtocol(base);
+ base = getResourceLocation();
+ // bug 117320, ensure base URI is 'protocal' qualified before
+ // passing it thru to URIResolver
+ // bug 117424, we should be able to assume that the base location
+ // is non-null
+ Assert.isNotNull(base, "Base location is expected to be non null.");
+ base = URIHelper.addImpliedFileProtocol(base);
}
- result = URIResolverPlugin.createResolver().resolve(base, publicId, systemId);
+ result = URIResolverPlugin.createResolver().resolve(base, publicId, systemId);
return result;
}
-
- public String resolvePhysicalLocation(String baseLocation, String publicId, String logicalLocation) {
- // This class should never be called to perform physical resolution!
- // If it does we should log it as an error
- Logger.log(Logger.ERROR_DEBUG, "XMLCatalogIDResolver.resolvePhysicalLocation() called unexpectedly");
- return logicalLocation;
- }
+
+ public String resolvePhysicalLocation(String baseLocation, String publicId, String logicalLocation) {
+ // This class should never be called to perform physical resolution!
+ // If it does we should log it as an error
+ Logger.log(Logger.ERROR_DEBUG, "XMLCatalogIDResolver.resolvePhysicalLocation() called unexpectedly");
+ return logicalLocation;
+ }
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java
index 90c9d54..fd3087f 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/modelquery/XMLModelQueryAssociationProvider.java
@@ -32,17 +32,24 @@
}
protected String resolveGrammarURI(Document document, String publicId, String systemId) {
-
+
// CS : spooky code alert!
- // this look really strange because we're passing null in as the first argument
- // however we're assuming the use of a 'fudged' URIResolver that knows the
- // correct baseLocation and will call to the URIResolver framework properly
-
+ // this look really strange because we're passing null in as the first
+ // argument
+ // however we're assuming the use of a 'fudged' URIResolver that knows
+ // the
+ // correct baseLocation and will call to the URIResolver framework
+ // properly
+
// CS : note that we should never call resolvePhysical at this point.
- // Physical resolution should only occur when we're interesting to opening the actual stream.
- // The CMDocumentFactory implementation would be responsible for calling resolvePhysical.
+ // Physical resolution should only occur when we're interesting to
+ // opening the actual stream.
+ // The CMDocumentFactory implementation would be responsible for
+ // calling resolvePhysical.
// All we need to do here is return a 'logical' URI
-
+
+ if (idResolver == null)
+ return null;
return idResolver.resolve(null, publicId, systemId);
}
}