[291402] JSP include directives do not handle non-JSP content types
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
index 4783f6e..76a63b3 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,6 +47,7 @@
* @author pavery
*/
class XMLJSPRegionHelper implements StructuredDocumentRegionHandler {
+ private static final String DEFAULT_FRAGMENT_CONTENT_TYPE = "org.eclipse.jst.jsp.core.jspfragmentsource"; //$NON-NLS-1$
private final JSPTranslator fTranslator;
protected JSPSourceParser fLocalParser = null;
protected String fTextToParse = null;
@@ -135,7 +136,9 @@
* translator for dealing with TEI variables
*/
try {
- IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerFor(f);
+ IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerFor(f, false);
+ if (handler == null)
+ handler = ModelHandlerRegistry.getInstance().getHandlerForContentTypeId(DEFAULT_FRAGMENT_CONTENT_TYPE);
document = (IStructuredDocument) handler.getDocumentLoader().createNewStructuredDocument();
contents = FileContentCache.getInstance().getContents(f.getFullPath());
}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
index af83ded..1ffcb31 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -113,13 +113,14 @@
* type.
*
* @param file
+ * @param provideDefault should the default extension be used in the absence of other methods
* @return The IModelHandler registered for the content type of the given
* file. If an exact match is not found, the most-specific match
* according to IContentType.isKindOf() will be returned. If none
* are found, either a default or null will be returned.
* @throws CoreException
*/
- public IModelHandler getHandlerFor(IFile file) throws CoreException {
+ public IModelHandler getHandlerFor(IFile file, boolean provideDefault) throws CoreException {
IModelHandler modelHandler = null;
IContentDescription contentDescription = null;
IContentType contentType = null;
@@ -169,7 +170,7 @@
if (contentType != null) {
modelHandler = getHandlerForContentType(contentType);
}
- else {
+ else if (contentType == null && provideDefault) {
// hard coding for null content type
modelHandler = getHandlerExtension(INTERNAL_DEFAULT_EXTENSION); //$NON-NLS-1$
}
@@ -177,6 +178,21 @@
return modelHandler;
}
+ /**
+ * Finds the registered IModelHandler for a given named file's content
+ * type. Will check for a default.
+ *
+ * @param file
+ * @return The IModelHandler registered for the content type of the given
+ * file. If an exact match is not found, the most-specific match
+ * according to IContentType.isKindOf() will be returned. If none
+ * are found, either a default or null will be returned.
+ * @throws CoreException
+ */
+ public IModelHandler getHandlerFor(IFile file) throws CoreException {
+ return getHandlerFor(file, true);
+ }
+
/**
* Finds the registered IModelHandler for a given named InputStream.