Author: scabanovich
Date: 2009-12-17 05:39:16 -0500 (Thu, 17 Dec 2009)
New Revision: 19407
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3875
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java 2009-12-17
10:38:55 UTC (rev 19406)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java 2009-12-17
10:39:16 UTC (rev 19407)
@@ -11,13 +11,10 @@
package org.jboss.tools.jst.web.kb.internal.scanner;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -28,11 +25,9 @@
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.filesystems.impl.FileSystemsLoader;
+import org.jboss.tools.common.model.project.ext.AbstractClassPathMonitor;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.model.util.XModelObjectUtil;
import org.jboss.tools.jst.web.WebModelPlugin;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
@@ -44,15 +39,8 @@
*
* @author Viacheslav Kabanovich
*/
-public class ClassPathMonitor {
- KbProject project;
- XModel model = null;
-
- List<String> paths = null;
- Map<IPath, String> paths2 = new HashMap<IPath, String>();
-
- Set<String> processedPaths = new HashSet<String>();
-
+public class ClassPathMonitor extends AbstractClassPathMonitor<KbProject> {
+
/**
* Creates instance of class path for kb project
* @param project
@@ -62,102 +50,17 @@
}
/**
- * Returns kb project
- * @return
- */
- public KbProject getProject() {
- return project;
- }
-
- /**
* Initialization of inner model.
*/
public void init() {
model = InnerModelHelper.createXModel(project.getProject());
}
- static String[] SYSTEM_JARS = {"rt.jar", "jsse.jar",
"jce.jar", "charsets.jar"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
- static Set<String> SYSTEM_JAR_SET = new HashSet<String>();
-
- static {
- for (int i = 0; i < SYSTEM_JARS.length; i++) SYSTEM_JAR_SET.add(SYSTEM_JARS[i]);
+ public IProject getProjectResource() {
+ return project.getProject();
}
/**
- * Returns true if class path was up-to-date.
- * Otherwise, updates inner model and disables class loader.
- * @return
- */
- public boolean update() {
- List<String> newPaths = null;
- try {
- newPaths = EclipseResourceUtil.getClassPath(project.getProject());
- List<String> jre = EclipseResourceUtil.getJREClassPath(project.getProject());
- if(jre != null) newPaths.removeAll(jre);
- } catch (CoreException e) {
- //TODO
- WebModelPlugin.getDefault().logError(e);
- } catch(IOException e) {
- WebModelPlugin.getDefault().logError(e);
- }
- if(paths == null && newPaths == null) return false;
- if((newPaths == null || paths == null) || (paths.size() != newPaths.size())) {
- paths = newPaths;
- } else {
- boolean b = false;
- for (int i = 0; i < paths.size() && !b; i++) {
- if(!paths.get(i).equals(newPaths.get(i))) b = true;
- }
- if(!b) return false;
- paths = newPaths;
- }
- createMap();
- XModelObject object = model.getByPath("FileSystems"); //$NON-NLS-1$
- XModelObject[] fs = object.getChildren("FileSystemJar"); //$NON-NLS-1$
- Set<XModelObject> fss = new HashSet<XModelObject>();
- for (int i = 0; i < fs.length; i++) fss.add(fs[i]);
-
- for (int i = 0; i < paths.size(); i++) {
- String path = paths.get(i);
- if(!EclipseResourceUtil.isJar(path)) continue;
- String fileName = new File(path).getName();
- if(SYSTEM_JAR_SET.contains(fileName)) continue;
- String jsname = "lib-" + fileName; //$NON-NLS-1$
- XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname);
//$NON-NLS-1$
- if(o != null) {
- fss.remove(o);
- } else {
- o = object.getModel().createModelObject("FileSystemJar", null);
//$NON-NLS-1$
- o.setAttributeValue("name", jsname); //$NON-NLS-1$
- o.setAttributeValue("location", path); //$NON-NLS-1$
- o.set(FileSystemsLoader.IS_ADDED_TO_CLASSPATH, "true"); //$NON-NLS-1$
- object.addChild(o);
-// object.setModified(true);
- }
- }
-
- for (XModelObject o: fss) {
- String path = XModelObjectUtil.expand(o.getAttributeValue("location"),
o.getModel(), null); //$NON-NLS-1$
- if("true".equals(o.get(FileSystemsLoader.IS_ADDED_TO_CLASSPATH))) {
//$NON-NLS-1$
- o.removeFromParent();
- } else if(!new File(path).exists()) {
- o.removeFromParent();
- }
- }
-
- return true;
- }
-
- private void createMap() {
- paths2.clear();
- if(paths != null) {
- for (String p : paths) {
- paths2.put(new Path(p), p);
- }
- }
- }
-
- /**
* Loads kb components from items recently added to class path.
*/
public void process() {
@@ -176,7 +79,7 @@
LibraryScanner scanner = new LibraryScanner();
String fileName = new File(p).getName();
- if(SYSTEM_JAR_SET.contains(fileName)) continue;
+ if(EclipseResourceUtil.SYSTEM_JAR_SET.contains(fileName)) continue;
String jsname = "lib-" + fileName; //$NON-NLS-1$
XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname);
//$NON-NLS-1$
if(o == null) continue;
@@ -267,21 +170,4 @@
return list;
}
- public void pathLoaded(IPath path) {
- String p = paths2.get(path);
- if(p != null) {
- processedPaths.add(p);
- }
- }
-
- public boolean hasPath(IPath path) {
- return paths2.get(path) != null;
- }
-
- public void clean() {
- paths = null;
- if(paths2 != null) paths2.clear();
- processedPaths.clear();
- }
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java 2009-12-17
10:38:55 UTC (rev 19406)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/LibraryScanner.java 2009-12-17
10:39:16 UTC (rev 19407)
@@ -77,7 +77,7 @@
if(metaInf != null) {
XModelObject[] tlds = metaInf.getChildren();
for (XModelObject tld: tlds) {
- if(isFaceletTaglibFile(tld) || isTLDFile(tld)) {
+ if(isFaceletTaglibFile(tld) || isTLDFile(tld) || isFacesConfigFile(tld)) {
XMLScanner s = new XMLScanner();
LoadedDeclarations ds1 = s.parse(tld, path, sp);
if(ds1 != null) ds.add(ds1);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-12-17
10:38:55 UTC (rev 19406)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/scanner/XMLScanner.java 2009-12-17
10:39:16 UTC (rev 19407)
@@ -49,6 +49,7 @@
public static final String ATTR_ATTRIBUTE_NAME = "attribute-name";
//$NON-NLS-1$
public static final String ATTR_FUNC_SIGN = "function-signature";
//$NON-NLS-1$
public static final String ATTR_FUNC_NAME = "function-name"; //$NON-NLS-1$
+ public static final String ATTR_COMPONENT_TYPE = "component-type";
//$NON-NLS-1$
public XMLScanner() {}
@@ -190,6 +191,13 @@
FaceletTag tag = new FaceletTag();
tag.setId(t);
tag.setName(new XMLValueInfo(t, ATTR_TAG_NAME));
+ XModelObject d = t.getChildByPath("declaration"); //$NON-NLS-1$
+ if(d != null &&
d.getModelEntity().getName().startsWith("FaceletTaglibComponent")) {
//$NON-NLS-1$
+ String componentType = d.getAttributeValue(ATTR_COMPONENT_TYPE); //$NON-NLS-1$
+ if(componentType != null && componentType.length() > 0) {
+ tag.setComponentType(new XMLValueInfo(d, ATTR_COMPONENT_TYPE)); //$NON-NLS-1$
+ }
+ }
library.addComponent(tag);
} else if(entity.startsWith("FaceletTaglibFunction")) { //$NON-NLS-1$
ELFunction f = new ELFunction();