Author: vrubezhny
Date: 2009-11-26 09:52:28 -0500 (Thu, 26 Nov 2009)
New Revision: 18857
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
Log:
JBIDE-5119: Refactor PageContextFactory to improve perfomance of context creation
cleanUp() methods are made due to allow the KbBuilder to clean up the cached contexts
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-11-26
14:45:04 UTC (rev 18856)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-26
14:52:28 UTC (rev 18857)
@@ -208,6 +208,18 @@
}
}
}
+
+ /**
+ * Cleans up the contexts for the resource change delta
+ *
+ * @param file
+ */
+ public void cleanUp(IResourceDelta delta) {
+ if(cache == null || cache.size() == 0) return;
+ if(!checkDelta(delta)) return;
+ processDelta(delta);
+ }
+
// long ctm = 0;
// String getContextType1(IFile file) {
@@ -897,10 +909,13 @@
}
}
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
public void resourceChanged(IResourceChangeEvent event) {
- if(cache == null || cache.size() == 0 || event == null || event.getDelta() == null)
return;
- if(!checkDelta(event.getDelta())) return;
- processDelta(event.getDelta());
+ if(event == null || event.getDelta() == null) return;
+ cleanUp(event.getDelta());
}
private boolean checkDelta(IResourceDelta delta) {
@@ -918,13 +933,15 @@
int kind = delta.getKind();
IResource resource = delta.getResource();
- if( resource instanceof IProject && (
-// kind == IResourceDelta.CHANGED ||
-// kind == IResourceDelta.ADDED ||
- kind == IResourceDelta.REMOVED // ||
-// kind == IResourceDelta.CONTENT)
- )) {
+ if(resource instanceof IProject &&
+ kind == IResourceDelta.REMOVED) {
cleanUp((IProject)resource);
+ } else if (resource instanceof IFile && (
+ kind == IResourceDelta.CHANGED ||
+ kind == IResourceDelta.ADDED ||
+ kind == IResourceDelta.REMOVED ||
+ kind == IResourceDelta.CONTENT)) {
+ cleanUp((IFile)resource);
}
IResourceDelta[] cs = delta.getAffectedChildren();
Show replies by date