Author: akazakov
Date: 2009-05-22 12:28:12 -0400 (Fri, 22 May 2009)
New Revision: 15448
Removed:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/FaceletContextImpl.java
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/internal/JspContextImpl.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/taglib/TagLibriryManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
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 2009-05-22
16:25:10 UTC (rev 15447)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-05-22
16:28:12 UTC (rev 15448)
@@ -11,6 +11,9 @@
package org.jboss.tools.jst.web.kb;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IDocument;
+import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
/**
* @author Alexey Kazakov
@@ -19,7 +22,7 @@
/**
* Creates a page context for given resource and offset.
- * @param file
+ * @param file JSP or Facelet
* @param offset
* @return
*/
@@ -29,8 +32,37 @@
}
/**
+ * Creates a jsp context for given resource and offset.
+ * @param file JSP
+ * @param offset
+ * @return
+ */
+ public static IPageContext createJSPContext(IFile file, int offset) {
+ JspContextImpl context = new JspContextImpl();
+// context.s
+ // TODO
+ return null;
+ }
+
+ /**
+ * Creates a jsp context for given resource, document and offset.
+ * @param file JSP
+ * @param offset
+ * @param document
+ * @return
+ */
+ public static IPageContext createJSPContext(IFile file, IDocument document, int offset)
{
+ JspContextImpl context = new JspContextImpl();
+ context.setDocument(document);
+ context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
+// context.s
+ // TODO
+ return null;
+ }
+
+ /**
* Creates a facelet context for given resource and offset.
- * @param file
+ * @param file Facelet
* @param offset
* @return
*/
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/FaceletContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/FaceletContextImpl.java 2009-05-22
16:25:10 UTC (rev 15447)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/FaceletContextImpl.java 2009-05-22
16:28:12 UTC (rev 15448)
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.internal;
-
-import java.util.Map;
-
-import org.jboss.tools.jst.web.kb.IFaceletPageContext;
-
-/**
- * Facelet page context
- * @author Alexey Kazakov
- */
-public class FaceletContextImpl extends JspContextImpl implements IFaceletPageContext {
-
- private IFaceletPageContext parentContext;
- private Map<String, String> params;
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.common.kb.text.FaceletPageContext#getParentContext()
- */
- public IFaceletPageContext getParentContext() {
- return parentContext;
- }
-
- public void setParentContext(IFaceletPageContext parentContext) {
- this.parentContext = parentContext;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.common.kb.text.FaceletPageContext#getParams()
- */
- public Map<String, String> getParams() {
- return params;
- }
-
- public void setParams(Map<String, String> params) {
- this.params = params;
- }
-}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-05-22
16:25:10 UTC (rev 15447)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-05-22
16:28:12 UTC (rev 15448)
@@ -61,20 +61,6 @@
}
/**
- * @return the libs
- */
- public ITagLibrary[] getLibs() {
- return libs;
- }
-
- /**
- * @param libs the libs to set
- */
- public void setLibs(ITagLibrary[] libs) {
- this.libs = libs;
- }
-
- /**
* @param document the document to set
*/
public void setDocument(IDocument document) {
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 2009-05-22
16:25:10 UTC (rev 15447)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/KbProject.java 2009-05-22
16:28:12 UTC (rev 15448)
@@ -68,26 +68,59 @@
LibraryStorage libraries = new LibraryStorage();
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IKbProject#getTagLibraries()
+ */
public ITagLibrary[] getTagLibraries() {
return libraries.getAllLibrariesArray();
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IKbProject#getTagLibraries(java.lang.String)
+ */
+ public ITagLibrary[] getTagLibraries(String uri) {
+ return libraries.getLibrariesArray(uri);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#configure()
+ */
public void configure() throws CoreException {
addToBuildSpec(KbBuilder.BUILDER_ID);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#deconfigure()
+ */
public void deconfigure() throws CoreException {
removeFromBuildSpec(KbBuilder.BUILDER_ID);
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.resources.IProjectNature#getProject()
+ */
public IProject getProject() {
return project;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.KbObject#getKbProject()
+ */
+ @Override
public IKbProject getKbProject() {
return this;
}
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
+ */
public void setProject(IProject project) {
this.project = project;
setSourcePath(project.getFullPath());
@@ -669,34 +702,51 @@
private Set<ITagLibrary> allLibraries = new HashSet<ITagLibrary>();
private ITagLibrary[] allLibrariesArray = null;
Map<IPath, Set<ITagLibrary>> librariesBySource = new HashMap<IPath,
Set<ITagLibrary>>();
+ Map<String, Set<ITagLibrary>> librariesByUri = new HashMap<String,
Set<ITagLibrary>>();
+ private ITagLibrary[] librariesByUriArray = null;
public void clear() {
synchronized(allLibraries) {
allLibraries.clear();
allLibrariesArray = null;
+ librariesByUriArray = null;
}
librariesBySource.clear();
+ librariesByUri.clear();
}
public ITagLibrary[] getAllLibrariesArray() {
- ITagLibrary[] result = allLibrariesArray;
- if(result == null) {
+ if(allLibrariesArray == null) {
synchronized(allLibraries) {
allLibrariesArray = allLibraries.toArray(new ITagLibrary[0]);
- result = allLibrariesArray;
}
}
- return result;
+ return allLibrariesArray;
}
+ public ITagLibrary[] getLibrariesArray(String uri) {
+ if(librariesByUriArray == null) {
+ synchronized(librariesByUri) {
+ Set<ITagLibrary> libs = librariesByUri.get(uri);
+ if(libs!=null) {
+ librariesByUriArray = libs.toArray(new ITagLibrary[0]);
+ } else {
+ librariesByUriArray = new ITagLibrary[0];
+ }
+ }
+ }
+ return librariesByUriArray;
+ }
+
public Set<ITagLibrary> getLibrariesBySource(IPath path) {
return librariesBySource.get(path);
}
-
+
public void addLibrary(ITagLibrary f) {
synchronized(allLibraries) {
allLibraries.add(f);
allLibrariesArray = null;
+ librariesByUriArray = null;
}
IPath path = f.getSourcePath();
if(path != null) {
@@ -707,12 +757,20 @@
}
fs.add(f);
}
+ String uri = f.getURI();
+ Set<ITagLibrary> ul = librariesByUri.get(uri);
+ if(ul==null) {
+ ul = new HashSet<ITagLibrary>();
+ librariesByUri.put(uri, ul);
+ }
+ ul.add(f);
}
-
+
public void removeLibrary(ITagLibrary f) {
synchronized(allLibraries) {
allLibraries.remove(f);
allLibrariesArray = null;
+ librariesByUriArray = null;
}
IPath path = f.getSourcePath();
if(path != null) {
@@ -724,6 +782,14 @@
librariesBySource.remove(fs);
}
}
+ String uri = f.getURI();
+ Set<ITagLibrary> ul = librariesByUri.get(uri);
+ if(ul!=null) {
+ ul.remove(f);
+ }
+ if(ul.isEmpty()) {
+ librariesByUri.remove(uri);
+ }
}
public Set<ITagLibrary> removePath(IPath path) {
@@ -732,21 +798,16 @@
for (ITagLibrary f: fs) {
synchronized(allLibraries) {
allLibraries.remove(f);
- allLibrariesArray = null;
}
+ synchronized (librariesByUri) {
+ librariesByUri.remove(f.getURI());
+ }
+ allLibrariesArray = null;
+ librariesByUriArray = null;
}
librariesBySource.remove(path);
return fs;
}
-
}
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.IKbProject#getTagLibraries(java.lang.String)
- */
- public ITagLibrary[] getTagLibraries(String uri) {
- // TODO
- return null;
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java 2009-05-22
16:25:10 UTC (rev 15447)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java 2009-05-22
16:28:12 UTC (rev 15448)
@@ -11,6 +11,8 @@
package org.jboss.tools.jst.web.kb.taglib;
import org.eclipse.core.resources.IProject;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
/**
* @author Alexey Kazakov
@@ -24,7 +26,7 @@
* @return
*/
public static ITagLibrary[] getLibraries(IProject project, String uri) {
- //TODO
- return null;
+ IKbProject kbProject = KbProjectFactory.getKbProject(project, true);
+ return kbProject.getTagLibraries(uri);
}
}
\ No newline at end of file