Author: scabanovich
Date: 2010-01-15 10:43:16 -0500 (Fri, 15 Jan 2010)
New Revision: 19774
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/StaticLibraries.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5650
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/StaticLibraries.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/StaticLibraries.java 2010-01-15
15:30:22 UTC (rev 19773)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/StaticLibraries.java 2010-01-15
15:43:16 UTC (rev 19774)
@@ -10,12 +10,13 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal;
+
import java.io.File;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.Path;
-import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.web.kb.internal.scanner.LoadedDeclarations;
@@ -32,29 +33,38 @@
static StaticLibraries instance = new StaticLibraries();
LibraryStorage libraries = new LibraryStorage();
- HashMap<File, XModel> loaded = new HashMap<File, XModel>();
+ Map<File, XModelObject> loadedFolders = new HashMap<File, XModelObject>();
+ Map<File, XModelObject> loadedFiles = new HashMap<File, XModelObject>();
private StaticLibraries() {}
public ITagLibrary[] getLibraries(String uri) {
File file = TagLibraryManager.getStaticTLD(uri);
if(file == null) return new ITagLibrary[0];
+ if(loadedFiles.containsKey(file)) {
+ return libraries.getLibrariesArray(uri);
+ }
File folder = file.getParentFile();
- if(!loaded.containsKey(folder)) {
+ if(!loadedFolders.containsKey(folder)) {
XModelObject o = EclipseResourceUtil.createObjectForLocation(file.getAbsolutePath());
if(o != null) {
- loaded.put(folder, o.getModel());
- XModelObject[] fs = o.getParent().getChildren();
+ loadedFolders.put(folder, o.getParent());
+ }
+ }
+ XModelObject o = loadedFolders.get(folder);
+ if(o != null) {
+ XModelObject fo = o.getChildByPath(file.getName());
+ if (fo != null) {
+ loadedFiles.put(file, fo);
XMLScanner scanner = new XMLScanner();
- for (XModelObject fo: fs) {
- LoadedDeclarations ds = scanner.parse(fo, new Path(folder.getAbsolutePath()),
null);
- List<ITagLibrary> ls = ds.getLibraries();
- for (ITagLibrary l: ls) {
- libraries.addLibrary(l);
- }
+ LoadedDeclarations ds = scanner.parse(fo, new Path(file.getAbsolutePath()), null);
+ List<ITagLibrary> ls = ds.getLibraries();
+ for (ITagLibrary l : ls) {
+ libraries.addLibrary(l);
}
- }
+ }
}
+
return libraries.getLibrariesArray(uri);
}