|
Lines 32-48
Link Here
|
| 32 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; |
32 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; |
| 33 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; |
33 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; |
| 34 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; |
34 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; |
|
|
35 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; |
| 36 |
import org.eclipse.jface.viewers.TreePath; |
| 35 |
|
37 |
|
| 36 |
@SuppressWarnings("restriction") |
38 |
@SuppressWarnings("restriction") |
| 37 |
public abstract class VMCache |
39 |
public abstract class VMCache |
| 38 |
{ |
40 |
{ |
|
|
41 |
public static class CacheKey { |
| 42 |
public final Object fViewerInput; |
| 43 |
public final TreePath fPath; |
| 44 |
public CacheKey(IViewerUpdate update) { |
| 45 |
this(update.getViewerInput(), update.getElementPath()); |
| 46 |
} |
| 47 |
public CacheKey(Object viewerInput, TreePath path) { |
| 48 |
fViewerInput = viewerInput; |
| 49 |
fPath = path; |
| 50 |
} |
| 51 |
|
| 52 |
@Override |
| 53 |
public boolean equals(Object obj) { |
| 54 |
return obj instanceof CacheKey && |
| 55 |
((CacheKey)obj).fViewerInput.equals(fViewerInput) && |
| 56 |
((CacheKey)obj).fPath.equals(fPath); |
| 57 |
} |
| 58 |
|
| 59 |
@Override |
| 60 |
public int hashCode() { |
| 61 |
return fViewerInput.hashCode() + fPath.hashCode(); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 39 |
protected Executor fExecutor = new DefaultDsfExecutor(); |
65 |
protected Executor fExecutor = new DefaultDsfExecutor(); |
| 40 |
|
66 |
|
| 41 |
protected HashMap<Object, Integer> fChildrenCounts = new HashMap<Object, Integer>(); |
67 |
protected HashMap<CacheKey, Integer> fChildrenCounts = new HashMap<CacheKey, Integer>(); |
| 42 |
|
68 |
|
| 43 |
protected HashMap<Object, HashMap<Integer,Object>> fChildren = new HashMap<Object, HashMap<Integer,Object>>(); |
69 |
protected HashMap<CacheKey, HashMap<Integer,Object>> fChildren = new HashMap<CacheKey, HashMap<Integer,Object>>(); |
| 44 |
|
70 |
|
| 45 |
protected HashMap<Object, Boolean> fHasChildren = new HashMap<Object, Boolean>(); |
71 |
protected HashMap<CacheKey, Boolean> fHasChildren = new HashMap<CacheKey, Boolean>(); |
| 46 |
|
72 |
|
| 47 |
protected HashMap<IDMContext<?>, IDMData> fData = new HashMap<IDMContext<?>, IDMData>(); |
73 |
protected HashMap<IDMContext<?>, IDMData> fData = new HashMap<IDMContext<?>, IDMData>(); |
| 48 |
|
74 |
|
|
Lines 66-74
Link Here
|
| 66 |
{ |
92 |
{ |
| 67 |
HashMap<?,?> oldCacheData[] = oldCache.getCacheData(); |
93 |
HashMap<?,?> oldCacheData[] = oldCache.getCacheData(); |
| 68 |
|
94 |
|
| 69 |
fHasChildren = (HashMap<Object, Boolean>)oldCacheData[0]; |
95 |
fHasChildren = (HashMap<CacheKey, Boolean>)oldCacheData[0]; |
| 70 |
fChildrenCounts = (HashMap<Object, Integer>)oldCacheData[1]; |
96 |
fChildrenCounts = (HashMap<CacheKey, Integer>)oldCacheData[1]; |
| 71 |
fChildren = (HashMap<Object, HashMap<Integer,Object>>)oldCacheData[2]; |
97 |
fChildren = (HashMap<CacheKey, HashMap<Integer,Object>>)oldCacheData[2]; |
| 72 |
fData = (HashMap<IDMContext<?>, IDMData>)oldCacheData[3]; |
98 |
fData = (HashMap<IDMContext<?>, IDMData>)oldCacheData[3]; |
| 73 |
fDataArchive = (HashMap<IDMContext<?>, IDMData>)oldCacheData[4]; |
99 |
fDataArchive = (HashMap<IDMContext<?>, IDMData>)oldCacheData[4]; |
| 74 |
} |
100 |
} |
|
Lines 113-121
Link Here
|
| 113 |
Vector<IHasChildrenUpdate> missVector = new Vector<IHasChildrenUpdate>(); |
139 |
Vector<IHasChildrenUpdate> missVector = new Vector<IHasChildrenUpdate>(); |
| 114 |
for(IHasChildrenUpdate update : updates) |
140 |
for(IHasChildrenUpdate update : updates) |
| 115 |
{ |
141 |
{ |
| 116 |
if(fHasChildren.containsKey(update.getElement()) && isCacheReadEnabled()) |
142 |
CacheKey updateKey = new CacheKey(update); |
|
|
143 |
if(fHasChildren.containsKey(updateKey) && isCacheReadEnabled()) |
| 117 |
{ |
144 |
{ |
| 118 |
update.setHasChilren(fHasChildren.get(update.getElement()).booleanValue()); |
145 |
update.setHasChilren(fHasChildren.get(updateKey).booleanValue()); |
| 119 |
update.done(); |
146 |
update.done(); |
| 120 |
} |
147 |
} |
| 121 |
else |
148 |
else |
|
Lines 136-142
Link Here
|
| 136 |
if(getStatus().isOK()) |
163 |
if(getStatus().isOK()) |
| 137 |
{ |
164 |
{ |
| 138 |
if(isCacheWriteEnabled()) |
165 |
if(isCacheWriteEnabled()) |
| 139 |
fHasChildren.put(update.getElement(), this.getData()); |
166 |
fHasChildren.put(new CacheKey(update), this.getData()); |
| 140 |
update.setHasChilren(getData()); |
167 |
update.setHasChilren(getData()); |
| 141 |
} |
168 |
} |
| 142 |
update.done(); |
169 |
update.done(); |
|
Lines 156-164
Link Here
|
| 156 |
Vector<IChildrenCountUpdate> missVector = new Vector<IChildrenCountUpdate>(); |
183 |
Vector<IChildrenCountUpdate> missVector = new Vector<IChildrenCountUpdate>(); |
| 157 |
for(IChildrenCountUpdate update : updates) |
184 |
for(IChildrenCountUpdate update : updates) |
| 158 |
{ |
185 |
{ |
| 159 |
if(fChildrenCounts.containsKey(update.getElement()) && isCacheReadEnabled()) |
186 |
CacheKey updateKey = new CacheKey(update); |
|
|
187 |
if(fChildrenCounts.containsKey(updateKey) && isCacheReadEnabled()) |
| 160 |
{ |
188 |
{ |
| 161 |
update.setChildCount(fChildrenCounts.get(update.getElement())); |
189 |
update.setChildCount(fChildrenCounts.get(updateKey)); |
| 162 |
update.done(); |
190 |
update.done(); |
| 163 |
} |
191 |
} |
| 164 |
else |
192 |
else |
|
Lines 178-184
Link Here
|
| 178 |
if(getStatus().isOK()) |
206 |
if(getStatus().isOK()) |
| 179 |
{ |
207 |
{ |
| 180 |
if(isCacheWriteEnabled()) |
208 |
if(isCacheWriteEnabled()) |
| 181 |
fChildrenCounts.put(update.getElement(), this.getData()); |
209 |
fChildrenCounts.put(new CacheKey(update), this.getData()); |
| 182 |
update.setChildCount(this.getData()); |
210 |
update.setChildCount(this.getData()); |
| 183 |
} |
211 |
} |
| 184 |
update.done(); |
212 |
update.done(); |
|
Lines 197-208
Link Here
|
| 197 |
Vector<IChildrenUpdate> updatesEntirelyMissingFromCache = new Vector<IChildrenUpdate>(); |
225 |
Vector<IChildrenUpdate> updatesEntirelyMissingFromCache = new Vector<IChildrenUpdate>(); |
| 198 |
for(final IChildrenUpdate update : updates) |
226 |
for(final IChildrenUpdate update : updates) |
| 199 |
{ |
227 |
{ |
| 200 |
if(fChildren.containsKey(update.getElement()) && isCacheReadEnabled()) |
228 |
CacheKey updateKey = new CacheKey(update); |
|
|
229 |
if(fChildren.containsKey(updateKey) && isCacheReadEnabled()) |
| 201 |
{ |
230 |
{ |
| 202 |
Vector<Integer> childrenMissingFromCache = new Vector<Integer>(); |
231 |
Vector<Integer> childrenMissingFromCache = new Vector<Integer>(); |
| 203 |
for(int i = update.getOffset(); i < update.getOffset() + update.getLength(); i++) |
232 |
for(int i = update.getOffset(); i < update.getOffset() + update.getLength(); i++) |
| 204 |
childrenMissingFromCache.addElement(i); |
233 |
childrenMissingFromCache.addElement(i); |
| 205 |
childrenMissingFromCache.removeAll(fChildren.get(update.getElement()).keySet()); |
234 |
childrenMissingFromCache.removeAll(fChildren.get(updateKey).keySet()); |
| 206 |
|
235 |
|
| 207 |
if(childrenMissingFromCache.size() > 0) |
236 |
if(childrenMissingFromCache.size() > 0) |
| 208 |
{ |
237 |
{ |
|
Lines 265-271
Link Here
|
| 265 |
{ |
294 |
{ |
| 266 |
// we have all of the children in cache; return from cache |
295 |
// we have all of the children in cache; return from cache |
| 267 |
for(int position = update.getOffset(); position < update.getOffset() + update.getLength(); position++) |
296 |
for(int position = update.getOffset(); position < update.getOffset() + update.getLength(); position++) |
| 268 |
update.setChild(fChildren.get(update.getElement()).get(position), position); |
297 |
update.setChild(fChildren.get(updateKey).get(position), position); |
| 269 |
update.done(); |
298 |
update.done(); |
| 270 |
} |
299 |
} |
| 271 |
} |
300 |
} |
|
Lines 293-302
Link Here
|
| 293 |
{ |
322 |
{ |
| 294 |
if(isCacheWriteEnabled()) |
323 |
if(isCacheWriteEnabled()) |
| 295 |
{ |
324 |
{ |
|
|
325 |
CacheKey updateKey = new CacheKey(update); |
| 296 |
if(!fChildren.containsKey(update.getElement())) |
326 |
if(!fChildren.containsKey(update.getElement())) |
| 297 |
fChildren.put(update.getElement(), new HashMap<Integer,Object>()); |
327 |
fChildren.put(updateKey, new HashMap<Integer,Object>()); |
| 298 |
|
328 |
|
| 299 |
fChildren.get(update.getElement()).put(update.getOffset() + j, getData().get(j)); |
329 |
fChildren.get(updateKey).put(update.getOffset() + j, getData().get(j)); |
| 300 |
} |
330 |
} |
| 301 |
|
331 |
|
| 302 |
update.setChild(getData().get(j), update.getOffset() + j); |
332 |
update.setChild(getData().get(j), update.getOffset() + j); |