Author: scabanovich
Date: 2007-10-18 07:54:57 -0400 (Thu, 18 Oct 2007)
New Revision: 4330
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/scanner/LoadedDeclarations.java
Log:
JBIDE-982
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 2007-10-18
11:54:48 UTC (rev 4329)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-10-18
11:54:57 UTC (rev 4330)
@@ -71,7 +71,7 @@
ClassPath classPath = new ClassPath(this);
- boolean useDefaultRuntime = false;
+// boolean useDefaultRuntime = false;
String runtimeName = null;
@@ -87,6 +87,8 @@
Set<SeamProject> usedBy = new HashSet<SeamProject>();
+ Map<String,List<String>> imports = new HashMap<String,
List<String>>();
+
{
ScopeType[] types = ScopeType.values();
for (int i = 0; i < scopes.length; i++) {
@@ -146,7 +148,7 @@
ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
return sp == null ? null : sp.getRuntimeName();
}
- if(useDefaultRuntime) {
+ if(runtimeName == null) {
SeamRuntime runtime = SeamRuntimeManager.getInstance().getDefaultRuntime();
return runtime != null ? runtime.getName() : null;
}
@@ -163,7 +165,7 @@
ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
return sp == null ? null : sp.getRuntime();
}
- if(useDefaultRuntime) {
+ if(runtimeName == null) {
return SeamRuntimeManager.getInstance().getDefaultRuntime();
}
return runtimeName == null ? null :
SeamRuntimeManager.getInstance().findRuntimeByName(runtimeName);
@@ -179,7 +181,7 @@
if(this.runtimeName != null && this.runtimeName.equals(runtimeName)) return;
SeamRuntime d = SeamRuntimeManager.getInstance().getDefaultRuntime();
- useDefaultRuntime = d != null && d.getName().equals(runtimeName);
+ boolean useDefaultRuntime = d != null && d.getName().equals(runtimeName);
if(useDefaultRuntime) {
this.runtimeName = null;
}
@@ -255,7 +257,6 @@
runtimeName = prefs.get(RUNTIME_NAME, null);
if(runtimeName != null) {
} else {
- useDefaultRuntime = true;
storeRuntime();
}
SeamCorePlugin.getDefault().getPluginPreferences().addPropertyChangeListener(new
Preferences.IPropertyChangeListener() {
@@ -263,9 +264,8 @@
if(SeamFacetPreference.RUNTIME_LIST.equals(event.getProperty())) {
SeamRuntime d = SeamRuntimeManager.getInstance().getDefaultRuntime();
if(d != null && d.getName().equals(runtimeName)) {
- runtimeName = null;
- useDefaultRuntime = true;
- storeRuntime();
+// runtimeName = null;
+// storeRuntime();
}
}
}
@@ -561,13 +561,19 @@
ISeamComponentDeclaration[] components = ds.getComponents().toArray(new
ISeamComponentDeclaration[0]);
ISeamFactory[] factories = ds.getFactories().toArray(new ISeamFactory[0]);
- if(components.length == 0 && factories.length == 0) {
+ if(components.length == 0 && factories.length == 0 &&
ds.getImports().size() == 0) {
pathRemoved(source);
return;
}
if(!sourcePaths.contains(source)) sourcePaths.add(source);
revalidateLock++;
+
+ if(ds.getImports().size() > 0) {
+ imports.put(source.toString(), ds.getImports());
+ } else if(imports.containsKey(source.toString())) {
+ imports.remove(source.toString());
+ }
Map<Object,ISeamComponentDeclaration> currentComponents =
findComponentDeclarations(source);
@@ -696,6 +702,7 @@
for (ISeamFactory f : ds.getFactories()) {
ds1.getFactories().add(f.clone());
}
+ ds1.getImports().addAll(ds.getImports());
p.registerComponents(ds1, source);
}
}
@@ -753,6 +760,7 @@
public void pathRemoved(IPath source) {
if(!sourcePaths.contains(source)) return;
sourcePaths.remove(source);
+ imports.remove(source.toString());
revalidateLock++;
Iterator<SeamComponent> iterator = allComponents.values().iterator();
while(iterator.hasNext()) {
@@ -992,7 +1000,10 @@
}
public boolean isImportedPackage(String packageName) {
- //TODO implement processing imported packages
+ for (String s: imports.keySet()) {
+ List<String> list = imports.get(s);
+ if(list.contains(packageName)) return true;
+ }
return false;
}
@@ -1321,6 +1332,16 @@
}
ds.getFactories().add(f.clone());
}
+ for (String s: imports.keySet()) {
+ IPath p = new Path(s);
+ if(p == null || p.toString().endsWith(".jar")) continue; //$NON-NLS-1$
+ LoadedDeclarations ds = map.get(p);
+ if(ds == null) {
+ ds = new LoadedDeclarations();
+ map.put(p, ds);
+ }
+ ds.getImports().addAll(imports.get(s));
+ }
return map;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2007-10-18
11:54:48 UTC (rev 4329)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2007-10-18
11:54:57 UTC (rev 4330)
@@ -24,6 +24,7 @@
public class LoadedDeclarations {
List<ISeamComponentDeclaration> components = new
ArrayList<ISeamComponentDeclaration>();
List<ISeamFactory> factories = new ArrayList<ISeamFactory>();
+ List<String> imports = new ArrayList<String>();
public List<ISeamComponentDeclaration> getComponents() {
return components;
@@ -33,6 +34,10 @@
return factories;
}
+ public List<String> getImports() {
+ return imports;
+ }
+
public void add(LoadedDeclarations ds) {
if(ds == null) return;
components.addAll(ds.components);