Author: scabanovich
Date: 2008-02-22 07:42:26 -0500 (Fri, 22 Feb 2008)
New Revision: 6532
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
JBIDE-1785 Test support added
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2008-02-22
12:32:39 UTC (rev 6531)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2008-02-22
12:42:26 UTC (rev 6532)
@@ -187,9 +187,6 @@
} else {
source = (IPath)context.get(SeamXMLConstants.ATTR_PATH);
}
- if(source == null) {
- System.out.println("Cannot load source");
- }
Element e_id = XMLUtilities.getUniqueChild(element, SeamXMLConstants.TAG_ID);
if(e_id != null) {
String cls = e_id.getAttribute(SeamXMLConstants.ATTR_CLASS);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-02-22
12:32:39 UTC (rev 6531)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-02-22
12:42:26 UTC (rev 6532)
@@ -90,11 +90,7 @@
Map<String,List<String>> imports = new HashMap<String,
List<String>>();
{
- ScopeType[] types = ScopeType.values();
- for (int i = 0; i < scopes.length; i++) {
- scopes[i] = new SeamScope(this, types[i]);
- scopesMap.put(types[i], scopes[i]);
- }
+ createScopes();
}
Map<String, SeamComponent> allComponents = new HashMap<String,
SeamComponent>();
@@ -333,8 +329,7 @@
if(!dependsOn.contains(p)) return;
p.usedBy.remove(this);
dependsOn.remove(p);
- IPath[] ps = sourcePaths.toArray(new IPath[0]);
- //TODO use sourcePaths2
+ IPath[] ps = sourcePaths2.keySet().toArray(new IPath[0]);
for (int i = 0; i < ps.length; i++) {
IPath pth = ps[i];
if(p.getSourcePath().isPrefixOf(pth)) {
@@ -379,8 +374,6 @@
if(isStorageResolved) return;
isStorageResolved = true;
- long begin = System.currentTimeMillis();
-
postponeFiring();
try {
@@ -395,8 +388,12 @@
root = XMLUtilities.getElement(file, null);
if(root != null) {
loadProjectDependencies(root);
- loadSourcePaths2(root);
-// loadSourcePaths(root);
+ if(XMLUtilities.getUniqueChild(root, "paths") != null) {
+ loadSourcePaths2(root);
+ } else {
+ //old code
+ loadSourcePaths(root);
+ }
}
}
@@ -412,12 +409,51 @@
fireChanges();
}
- long e = System.currentTimeMillis();
+ }
+
+ /**
+ * Method testing how long it takes to load Seam model
+ * serialized previously.
+ * This approach makes sure, that all other services
+ * (JDT, XModel, etc) are already loaded at first start of
+ * Seam model, so that now it is more or less pure time
+ * to be computed.
+ *
+ * @return
+ */
+ public long reload() {
+ classPath = new ClassPath(this);
+ sourcePaths.clear();
+ sourcePaths2.clear();
+ isStorageResolved = false;
+ dependsOn.clear();
+ usedBy.clear();
+ allComponents.clear();
+ allFactories.clear();
+ allVariables.clear();
+ allVariablesCopy = null;
+ allVariablesPlusShort = null;
+ imports.clear();
+ javaDeclarations.clear();
+ packages.clear();
+ createScopes();
- //TODO replace with proper testing
- System.out.println("Seam project " + project.getName() + " started in
" + (e - begin));
+ long begin = System.currentTimeMillis();
+
+ classPath.init();
+ resolve();
+
+ long end = System.currentTimeMillis();
+ return end - begin;
}
+ private void createScopes() {
+ ScopeType[] types = ScopeType.values();
+ for (int i = 0; i < scopes.length; i++) {
+ scopes[i] = new SeamScope(this, types[i]);
+ scopesMap.put(types[i], scopes[i]);
+ }
+ }
/**
* Stores results of last build, so that on exit/enter Eclipse
* load them without rebuilding project
@@ -429,7 +465,7 @@
Element root = XMLUtilities.createDocumentElement("seam-project");
//$NON-NLS-1$
storeProjectDependencies(root);
- storeSourcePaths(root);
+// storeSourcePaths(root);
storeSourcePaths2(root);
if(validationContext != null) validationContext.store(root);
@@ -461,13 +497,13 @@
/*
*
*/
- private void storeSourcePaths(Element root) {
- Element sourcePathsElement = XMLUtilities.createElement(root,
"source-paths"); //$NON-NLS-1$
- for (IPath path : sourcePaths) {
- Element pathElement = XMLUtilities.createElement(sourcePathsElement,
"path"); //$NON-NLS-1$
- pathElement.setAttribute("value", path.toString()); //$NON-NLS-1$
- }
- }
+// private void storeSourcePaths(Element root) {
+// Element sourcePathsElement = XMLUtilities.createElement(root,
"source-paths"); //$NON-NLS-1$
+// for (IPath path : sourcePaths) {
+// Element pathElement = XMLUtilities.createElement(sourcePathsElement,
"path"); //$NON-NLS-1$
+// pathElement.setAttribute("value", path.toString()); //$NON-NLS-1$
+// }
+// }
private void storeSourcePaths2(Element root) {
Properties context = new Properties();
@@ -528,7 +564,7 @@
}
/*
- *
+ * obsolete, will work only for old projects
*/
private void loadSourcePaths(Element root) {
Element sourcePathsElement = XMLUtilities.getUniqueChild(root,
"source-paths"); //$NON-NLS-1$
@@ -703,8 +739,7 @@
return;
}
if(!sourcePaths.contains(source)) sourcePaths.add(source);
-
- sourcePaths2.put(source, ds); //TODO
+ sourcePaths2.put(source, ds);
if(ds.getImports().size() > 0) {
setImports(source.toString(), ds.getImports());
@@ -911,7 +946,7 @@
* @param source
*/
public void pathRemoved(IPath source) {
- if(!sourcePaths.contains(source)) return;
+ if(!sourcePaths.contains(source) && !sourcePaths2.containsKey(source)) return;
sourcePaths.remove(source);
sourcePaths2.remove(source);
removeImports(source.toString());
@@ -1395,7 +1430,6 @@
if(postponedChanges == null) return;
List<Change> changes = postponedChanges;
postponedChanges = null;
- System.out.println("fireng " + changes.size() + " changes");
fireChanges(changes);
}