Author: akazakov
Date: 2011-06-09 17:58:28 -0400 (Thu, 09 Jun 2011)
New Revision: 31988
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
Log:
https://issues.jboss.org/browse/JBIDE-9088
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IKbProject.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.kb;
import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.jboss.tools.jst.web.kb.validation.IProjectValidationContext;
@@ -36,6 +37,13 @@
*/
ITagLibrary[] getTagLibraries(String uri);
+ /**
+ * Returns tag libraries by resource
+ * @param uri
+ * @return
+ */
+ ITagLibrary[] getTagLibraries(IPath path);
+
void resolve();
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -12,10 +12,8 @@
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.eclipse.jface.text.IDocument;
-import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
@@ -23,7 +21,7 @@
* Page context
* @author Alexey Kazakov
*/
-public interface IPageContext extends ELContext {
+public interface IPageContext extends IXmlContext {
/**
* Returns libraries which should be used in this context
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -134,6 +134,7 @@
public static boolean isPage(IFile file) {
IContentType type = IDE.getContentType(file);
String typeId = (type == null ? null : type.getId());
+ typeId = IncludeContextBuilder.getContextType(typeId);
return JSP_PAGE_CONTEXT_TYPE.equals(typeId) ||
FACELETS_PAGE_CONTEXT_TYPE.equals(typeId);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -28,7 +28,6 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -114,6 +113,14 @@
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.IKbProject#getTagLibraries(org.eclipse.core.runtime.IPath)
+ */
+ public ITagLibrary[] getTagLibraries(IPath path) {
+ return libraries.getLibrariesArray(path);
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
@@ -1055,8 +1062,8 @@
public void printModifications() {
System.out.println(project.getName());
- System.out.println("" + modifications);
+ System.out.println("" + modifications); //$NON-NLS-1$
if(validationContext != null)
- System.out.println("validationContext " +
validationContext.getModificationsSinceLastStore());
+ System.out.println("validationContext " +
validationContext.getModificationsSinceLastStore()); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/LibraryStorage.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -51,6 +53,8 @@
return allLibrariesArray;
}
+ private static final ITagLibrary[] EMPTY_LIB_ARRAY = new ITagLibrary[0];
+
public ITagLibrary[] getLibrariesArray(String uri) {
ITagLibrary[] result = librariesByUriArray.get(uri);
if(result == null) {
@@ -59,7 +63,7 @@
if(libs!=null) {
result = libs.toArray(new ITagLibrary[0]);
} else {
- result = new ITagLibrary[0];
+ result = EMPTY_LIB_ARRAY;
}
librariesByUriArray.put(uri, result);
}
@@ -71,6 +75,17 @@
return librariesBySource.get(path);
}
+ public ITagLibrary[] getLibrariesArray(IPath path) {
+ ITagLibrary[] result = EMPTY_LIB_ARRAY;
+ synchronized(librariesBySource) {
+ Set<ITagLibrary> libs = librariesBySource.get(path);
+ if(libs!=null) {
+ result = libs.toArray(new ITagLibrary[0]);
+ }
+ }
+ return result;
+ }
+
public void addLibrary(ITagLibrary f) {
synchronized(allLibraries) {
allLibraries.add(f);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/IComponent.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.taglib;
+import org.eclipse.core.resources.IResource;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IProposalProcessor;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -110,4 +111,10 @@
* @return parent tag lib.
*/
ITagLibrary getTagLib();
+
+ /**
+ * Returns the resource where this component is defined. May be a jar file.
+ * @return
+ */
+ IResource getResource();
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java 2011-06-09
21:27:12 UTC (rev 31987)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java 2011-06-09
21:58:28 UTC (rev 31988)
@@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URL;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
import org.jboss.tools.jst.web.kb.IKbProject;
@@ -40,6 +41,19 @@
}
/**
+ * Returns all the tag libraries which defined in the file (TLD, facelet tag lib,
composite component, etc.)
+ * @param file
+ * @return
+ */
+ public static ITagLibrary[] getLibraries(IFile file) {
+ IKbProject kbProject = KbProjectFactory.getKbProject(file.getProject(), true);
+ if(kbProject == null) {
+ return new ITagLibrary[0];
+ }
+ return kbProject.getTagLibraries(file.getFullPath());
+ }
+
+ /**
* Returns all tag libraries which are available in the project.
* @param project
* @return
@@ -74,7 +88,6 @@
}
} catch (IOException e) {
WebKbPlugin.getDefault().logError(e);
- return null;
}
return null;