Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2009-08-19 18:25:11 +0000
committercbateman2009-08-19 18:25:11 +0000
commitc908b8c5c70c1939337844a90d1e776b42ef0923 (patch)
tree948aba0b40ae2d01161267bb753dbf2cc67baee1
parentc35c107790051a140c6d3b79d88ef654bf697476 (diff)
downloadwebtools.jsf-c908b8c5c70c1939337844a90d1e776b42ef0923.tar.gz
webtools.jsf-c908b8c5c70c1939337844a90d1e776b42ef0923.tar.xz
webtools.jsf-c908b8c5c70c1939337844a90d1e776b42ef0923.zip
Add null checks to getTagDirUri.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java
index 30506c0d8..47e20649b 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/tld/CMUtil.java
@@ -30,6 +30,8 @@ import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocumen
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration;
import org.eclipse.jst.jsp.core.taglib.ITaglibRecord;
import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration;
import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
@@ -75,8 +77,9 @@ public final class CMUtil {
* Must <ul>not</ul> be called with HTML or JSP documents.
* As there is no API on the doc for standalone or tagDir doc, it is possible that this could return an invalid string.
* However, if the code is consistent in it's usage, all should be well.
+ * or null if not found.
*/
- public static String getURIFromDoc(final TLDDocument doc, final IProject project) {
+ public static String getURIFromDoc(final TLDDocument doc, final IProject project) {
String uri = doc.getUri();
IProject proj = project;
if (uri == null) {//
@@ -101,6 +104,7 @@ public final class CMUtil {
* @param tldRec
* @param project
* @return valid string to use for the uri when given a ITaglibRecord
+ * or null.
*/
public static String getURIFromTaglibRecord(ITaglibRecord tldRec, IProject project) {
//similar code in PaletteHelper and above
@@ -125,13 +129,25 @@ public final class CMUtil {
IPath webContentPath = ComponentCore.createComponent(project).getRootFolder().getUnderlyingFolder().getLocation();
return getURIFromPath(p.makeAbsolute().makeRelativeTo(webContentPath.makeAbsolute()));
}
-
+
private static String getTagDirURI(TLDDocument doc, IProject project) {
Path p = new Path(doc.getBaseLocation());
- IPath webContentPath = ComponentCore.createComponent(project).getRootFolder().getUnderlyingFolder().getFullPath();
- return getURIFromPath(p.makeRelativeTo(webContentPath));
+ IVirtualComponent projectComp = ComponentCore.createComponent(project);
+
+ if (projectComp != null)
+ {
+ IVirtualFolder rootFolder = projectComp.getRootFolder();
+
+ if (rootFolder != null)
+ {
+ IPath webContentPath =
+ rootFolder.getUnderlyingFolder().getFullPath();
+ return getURIFromPath(p.makeRelativeTo(webContentPath));
+ }
+ }
+ return null;
}
-
+
private static String getURIFromPath(IPath uriPath)
{
if (uriPath != null)

Back to the top