Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcrogers2010-04-28 18:52:55 -0400
committercrogers2010-04-28 18:52:55 -0400
commit3dc82d31eb10cd5a25f1b72c5b9d3a905c546b98 (patch)
tree31ab2c64031f33d7c258d0f8cc26743f3c42b99c
parent152fe41e2a1bd583199a49fb23150f4853086e29 (diff)
downloadwebtools.jsf-3dc82d31eb10cd5a25f1b72c5b9d3a905c546b98.tar.gz
webtools.jsf-3dc82d31eb10cd5a25f1b72c5b9d3a905c546b98.tar.xz
webtools.jsf-3dc82d31eb10cd5a25f1b72c5b9d3a905c546b98.zip
[Bug 305546] Exception initializing FaceletTagRegistry for HTML.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/CompositeTagRegistryFactory.java18
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/TagRegistryFactory.java8
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/jsp/registry/TLDRegistryManager.java33
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/FaceletDocumentFactory.java13
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/FaceletRegistryManager.java17
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java5
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java25
7 files changed, 102 insertions, 17 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/CompositeTagRegistryFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/CompositeTagRegistryFactory.java
index 10503bc8b..9a56b804d 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/CompositeTagRegistryFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/CompositeTagRegistryFactory.java
@@ -65,8 +65,8 @@ public final class CompositeTagRegistryFactory
return INSTANCE;
}
- private final Map<IContentType, Set<ITagRegistryFactoryInfo>> _cachedExtensionsByType =
- new HashMap<IContentType, Set<ITagRegistryFactoryInfo>>(4);
+ private final Map<TagRegistryIdentifier, Set<ITagRegistryFactoryInfo>> _cachedExtensionsByType =
+ new HashMap<TagRegistryIdentifier, Set<ITagRegistryFactoryInfo>>(4);
private CompositeTagRegistryFactory()
{
@@ -191,8 +191,7 @@ public final class CompositeTagRegistryFactory
private Set<ITagRegistryFactoryInfo> findMatchingExtensions(
TagRegistryIdentifier id, Set<ITagRegistryFactoryInfo> handlers)
{
- Set<ITagRegistryFactoryInfo> matching = _cachedExtensionsByType.get(id
- .getContentType());
+ Set<ITagRegistryFactoryInfo> matching = _cachedExtensionsByType.get(id);
if (matching == null)
{
@@ -200,23 +199,22 @@ public final class CompositeTagRegistryFactory
for (final ITagRegistryFactoryInfo handler : handlers)
{
- if (handler.getContentTypes().contains(id.getContentType()))
+ if (handler.getContentTypes().contains(id.getContentType())
+ && handler.getTagRegistryFactory().projectIsValid(id.getProject()))
{
matching.add(handler);
}
}
// if there is nothing matching, just store the empty set and
- // discard
- // the extra memory
+ // discard the extra memory
if (matching.size() > 0)
{
- _cachedExtensionsByType.put(id.getContentType(), matching);
+ _cachedExtensionsByType.put(id, matching);
}
else
{
- _cachedExtensionsByType.put(id.getContentType(),
- Collections.EMPTY_SET);
+ _cachedExtensionsByType.put(id, Collections.EMPTY_SET);
}
}
return matching;
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/TagRegistryFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/TagRegistryFactory.java
index d0c5ecb59..ba0f74da1 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/TagRegistryFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/TagRegistryFactory.java
@@ -39,6 +39,14 @@ public abstract class TagRegistryFactory implements IIdentifiableStrategy<IProje
public abstract ITagRegistry createTagRegistry(final IProject project) throws TagRegistryFactoryException;
/**
+ * @param project
+ * @return determines whether a particular tag registry is appropriate for
+ * the project. If there is no valid tag registry for a project (i.e. due
+ * to lack of facet or bad facet version), return false.
+ */
+ public abstract boolean projectIsValid(final IProject project);
+
+ /**
* Allow
*
* @param project
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/jsp/registry/TLDRegistryManager.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/jsp/registry/TLDRegistryManager.java
index d5f29ca60..8bec0653c 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/jsp/registry/TLDRegistryManager.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/view/model/jsp/registry/TLDRegistryManager.java
@@ -25,6 +25,9 @@ import org.eclipse.jst.jsf.core.internal.JSFCoreTraceOptions;
import org.eclipse.jst.jsf.designtime.internal.Messages;
import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry;
import org.eclipse.jst.jsf.designtime.internal.view.model.TagRegistryFactory;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
/**
* A per-resource singleton manager for TLDTagRegistry's.
@@ -36,6 +39,7 @@ public final class TLDRegistryManager extends
ResourceSingletonObjectManager<TLDTagRegistry, IProject>
{
// STATIC
+ private final static String JST_WEB_MODULE = "jst.web"; //$NON-NLS-1$
private static TLDRegistryManager INSTANCE;
/**
@@ -141,6 +145,35 @@ public final class TLDRegistryManager extends
{
return Messages.TLDRegistryManager_DisplayName;
}
+
+ @Override
+ public boolean projectIsValid(IProject project) {
+ if (project == null)
+ {
+ return false;
+ }
+
+ // Check that this is a dynamic web project
+ // (I.E. the JST Web facet is installed)
+ try
+ {
+ if (ProjectFacetsManager.isProjectFacetDefined(JST_WEB_MODULE))
+ {
+ IFacetedProject faceted = ProjectFacetsManager.create(project);
+ IProjectFacet webModuleFacet = ProjectFacetsManager.getProjectFacet(JST_WEB_MODULE);
+ if (faceted != null && faceted.hasProjectFacet(webModuleFacet))
+ {
+ return true;
+ }
+ }
+ }
+ catch (CoreException ce)
+ {
+ JSFCorePlugin.log(ce, "TLDRegistryManager failed checking web project"); //$NON-NLS-1$
+ }
+
+ return false;
+ }
}
private class MyWorkspaceSaveParticipant implements ISaveParticipant
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/FaceletDocumentFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/FaceletDocumentFactory.java
index 8c1a837ee..0c806f8a4 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/FaceletDocumentFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/FaceletDocumentFactory.java
@@ -155,12 +155,15 @@ public class FaceletDocumentFactory
try
{
registry = factory.createTagRegistry(project);
- final Namespace ns = registry.getTagLibrary(uri);
-
- if (ns != null)
+ if (registry != null)
{
- adapter = new NamespaceCMAdapter(ns, project);
- _cmDocuments.put(uri, adapter);
+ final Namespace ns = registry.getTagLibrary(uri);
+
+ if (ns != null)
+ {
+ adapter = new NamespaceCMAdapter(ns, project);
+ _cmDocuments.put(uri, adapter);
+ }
}
}
catch (final TagRegistryFactoryException e)
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/FaceletRegistryManager.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/FaceletRegistryManager.java
index aff143bf0..357458b0d 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/FaceletRegistryManager.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/registry/FaceletRegistryManager.java
@@ -3,6 +3,7 @@ package org.eclipse.jst.jsf.facelet.core.internal.registry;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.jst.jsf.common.internal.resource.ResourceSingletonObjectManager;
+import org.eclipse.jst.jsf.core.JSFVersion;
import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry;
import org.eclipse.jst.jsf.designtime.internal.view.model.TagRegistryFactory;
import org.eclipse.jst.jsf.facelet.core.internal.FaceletCoreTraceOptions;
@@ -109,5 +110,21 @@ public final class FaceletRegistryManager extends
{
return Messages.FaceletRegistryManager_REGISTRY_FACTORY_DISPLAYNAME;
}
+
+ @Override
+ public boolean projectIsValid(IProject project) {
+ if (project == null)
+ {
+ return false;
+ }
+
+ final JSFVersion jsfVersion = JSFVersion.valueOfProject(project);
+ if (jsfVersion != null && jsfVersion.compareTo(JSFVersion.V2_0) >= 0)
+ {
+ return true;
+ }
+
+ return false;
+ }
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java
index f35703a4f..47ac5910e 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java
@@ -111,6 +111,11 @@ public class XHTMLContentAssistProcessor2 implements IContentAssistProcessor
try
{
registry = factory.createTagRegistry(project);
+ if (registry == null)
+ {
+ return proposals;
+ }
+
final Collection<? extends Namespace> tagLibs = registry
.getAllTagLibraries();
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java
index a8457d5e1..17785c1d1 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java
@@ -2,6 +2,7 @@ package org.eclipse.jst.jsf.facelet.ui.internal.validation;
import java.io.IOException;
import java.util.Collection;
+import java.util.Collections;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -57,12 +58,22 @@ import org.w3c.dom.Element;
*/
public class HTMLValidator extends AbstractValidator implements IValidator
{
+ /**
+ * @param helper
+ * @return no rule, null
+ */
public ISchedulingRule getSchedulingRule(final IValidationContext helper)
{
// no rule...
return null;
}
+ /**
+ * @param helper
+ * @param reporter
+ * @return status of this validation
+ * @throws ValidationException
+ */
public IStatus validateInJob(final IValidationContext helper,
final IReporter reporter) throws ValidationException
{
@@ -195,8 +206,18 @@ public class HTMLValidator extends AbstractValidator implements IValidator
.getDeclaredNamespaces(rootElement.getAttributes());
final ITagRegistry tagRegistry = ViewUtil
.getHtmlTagRegistry(project);
- final Collection<? extends Namespace> namespaces = tagRegistry
- .getAllTagLibraries();
+ final Collection<? extends Namespace> namespaces;
+ if (tagRegistry != null)
+ {
+ namespaces = tagRegistry.getAllTagLibraries();
+ }
+ else
+ {
+ // unexpected
+ namespaces = Collections.EMPTY_SET;
+ JSFCorePlugin.log(IStatus.ERROR, "Program Error: HTML tag registry not found"); //$NON-NLS-1$
+ }
+
for (final Attr attr : declaredNamespaces)
{
// only validate prefix declarations

Back to the top