Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/projection/ProjectionSummary.d @ 134:51e6e63f930e
Regex fix for casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:46:20 +0200 |
parents | 7d818bd32d63 |
children | b6bad70d540a |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
173 try { | 173 try { |
174 | 174 |
175 | 175 |
176 IDocument document= fProjectionViewer.getDocument(); | 176 IDocument document= fProjectionViewer.getDocument(); |
177 if (document instanceof ISynchronizable && fAnnotationModel instanceof ISynchronizable) { | 177 if (document instanceof ISynchronizable && fAnnotationModel instanceof ISynchronizable) { |
178 ISynchronizable sync= (ISynchronizable) fAnnotationModel; | 178 ISynchronizable sync= cast(ISynchronizable) fAnnotationModel; |
179 previousLockObject= sync.getLockObject(); | 179 previousLockObject= sync.getLockObject(); |
180 sync.setLockObject(((ISynchronizable) document).getLockObject()); | 180 sync.setLockObject((cast(ISynchronizable) document).getLockObject()); |
181 } | 181 } |
182 | 182 |
183 | 183 |
184 removeSummaries(monitor); | 184 removeSummaries(monitor); |
185 | 185 |
189 createSummaries(monitor); | 189 createSummaries(monitor); |
190 | 190 |
191 } finally { | 191 } finally { |
192 | 192 |
193 if (fAnnotationModel instanceof ISynchronizable) { | 193 if (fAnnotationModel instanceof ISynchronizable) { |
194 ISynchronizable sync= (ISynchronizable) fAnnotationModel; | 194 ISynchronizable sync= cast(ISynchronizable) fAnnotationModel; |
195 sync.setLockObject(previousLockObject); | 195 sync.setLockObject(previousLockObject); |
196 } | 196 } |
197 fAnnotationModel= null; | 197 fAnnotationModel= null; |
198 | 198 |
199 } | 199 } |
206 private void removeSummaries(IProgressMonitor monitor) { | 206 private void removeSummaries(IProgressMonitor monitor) { |
207 IAnnotationModelExtension extension= null; | 207 IAnnotationModelExtension extension= null; |
208 List bags= null; | 208 List bags= null; |
209 | 209 |
210 if (fAnnotationModel instanceof IAnnotationModelExtension) { | 210 if (fAnnotationModel instanceof IAnnotationModelExtension) { |
211 extension= (IAnnotationModelExtension) fAnnotationModel; | 211 extension= cast(IAnnotationModelExtension) fAnnotationModel; |
212 bags= new ArrayList(); | 212 bags= new ArrayList(); |
213 } | 213 } |
214 | 214 |
215 Iterator e= fAnnotationModel.getAnnotationIterator(); | 215 Iterator e= fAnnotationModel.getAnnotationIterator(); |
216 while (e.hasNext()) { | 216 while (e.hasNext()) { |
217 Annotation annotation= (Annotation) e.next(); | 217 Annotation annotation= cast(Annotation) e.next(); |
218 if (annotation instanceof AnnotationBag) { | 218 if (annotation instanceof AnnotationBag) { |
219 if (bags is null) | 219 if (bags is null) |
220 fAnnotationModel.removeAnnotation(annotation); | 220 fAnnotationModel.removeAnnotation(annotation); |
221 else | 221 else |
222 bags.add(annotation); | 222 bags.add(annotation); |
241 | 241 |
242 Map additions= new HashMap(); | 242 Map additions= new HashMap(); |
243 | 243 |
244 Iterator e= model.getAnnotationIterator(); | 244 Iterator e= model.getAnnotationIterator(); |
245 while (e.hasNext()) { | 245 while (e.hasNext()) { |
246 ProjectionAnnotation projection= (ProjectionAnnotation) e.next(); | 246 ProjectionAnnotation projection= cast(ProjectionAnnotation) e.next(); |
247 if (projection.isCollapsed()) { | 247 if (projection.isCollapsed()) { |
248 Position position= model.getPosition(projection); | 248 Position position= model.getPosition(projection); |
249 if (position !is null) { | 249 if (position !is null) { |
250 IRegion[] summaryRegions= fProjectionViewer.computeCollapsedRegions(position); | 250 IRegion[] summaryRegions= fProjectionViewer.computeCollapsedRegions(position); |
251 if (summaryRegions !is null) { | 251 if (summaryRegions !is null) { |
260 return; | 260 return; |
261 } | 261 } |
262 | 262 |
263 if (additions.size() > 0) { | 263 if (additions.size() > 0) { |
264 if (fAnnotationModel instanceof IAnnotationModelExtension) { | 264 if (fAnnotationModel instanceof IAnnotationModelExtension) { |
265 IAnnotationModelExtension extension= (IAnnotationModelExtension) fAnnotationModel; | 265 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fAnnotationModel; |
266 if (!isCanceled(monitor)) | 266 if (!isCanceled(monitor)) |
267 extension.replaceAnnotations(null, additions); | 267 extension.replaceAnnotations(null, additions); |
268 } else { | 268 } else { |
269 Iterator e1= additions.keySet().iterator(); | 269 Iterator e1= additions.keySet().iterator(); |
270 while (e1.hasNext()) { | 270 while (e1.hasNext()) { |
271 AnnotationBag bag= (AnnotationBag) e1.next(); | 271 AnnotationBag bag= cast(AnnotationBag) e1.next(); |
272 Position position= (Position) additions.get(bag); | 272 Position position= cast(Position) additions.get(bag); |
273 if (isCanceled(monitor)) | 273 if (isCanceled(monitor)) |
274 return; | 274 return; |
275 fAnnotationModel.addAnnotation(bag, position); | 275 fAnnotationModel.addAnnotation(bag, position); |
276 } | 276 } |
277 } | 277 } |
286 synchronized (fLock) { | 286 synchronized (fLock) { |
287 if (fConfiguredAnnotationTypes !is null) { | 287 if (fConfiguredAnnotationTypes !is null) { |
288 size= fConfiguredAnnotationTypes.size(); | 288 size= fConfiguredAnnotationTypes.size(); |
289 map= new HashMap(); | 289 map= new HashMap(); |
290 for (int i= 0; i < size; i++) { | 290 for (int i= 0; i < size; i++) { |
291 String type= (String) fConfiguredAnnotationTypes.get(i); | 291 String type= cast(String) fConfiguredAnnotationTypes.get(i); |
292 map.put(type, new AnnotationBag(type)); | 292 map.put(type, new AnnotationBag(type)); |
293 } | 293 } |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
300 IAnnotationModel model= fProjectionViewer.getAnnotationModel(); | 300 IAnnotationModel model= fProjectionViewer.getAnnotationModel(); |
301 if (model is null) | 301 if (model is null) |
302 return; | 302 return; |
303 Iterator e= model.getAnnotationIterator(); | 303 Iterator e= model.getAnnotationIterator(); |
304 while (e.hasNext()) { | 304 while (e.hasNext()) { |
305 Annotation annotation= (Annotation) e.next(); | 305 Annotation annotation= cast(Annotation) e.next(); |
306 AnnotationBag bag= findBagForType(map, annotation.getType()); | 306 AnnotationBag bag= findBagForType(map, annotation.getType()); |
307 if (bag !is null) { | 307 if (bag !is null) { |
308 Position position= model.getPosition(annotation); | 308 Position position= model.getPosition(annotation); |
309 if (includes(summaryRegions, position)) | 309 if (includes(summaryRegions, position)) |
310 bag.add(annotation); | 310 bag.add(annotation); |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 for (int i= 0; i < size; i++) { | 314 for (int i= 0; i < size; i++) { |
315 AnnotationBag bag= (AnnotationBag) map.get(fConfiguredAnnotationTypes.get(i)); | 315 AnnotationBag bag= cast(AnnotationBag) map.get(fConfiguredAnnotationTypes.get(i)); |
316 if (!bag.isEmpty()) | 316 if (!bag.isEmpty()) |
317 additions.put(bag, new Position(summaryAnchor.getOffset(), summaryAnchor.getLength())); | 317 additions.put(bag, new Position(summaryAnchor.getOffset(), summaryAnchor.getLength())); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 private AnnotationBag findBagForType(Map bagMap, String annotationType) { | 321 private AnnotationBag findBagForType(Map bagMap, String annotationType) { |
322 AnnotationBag bag= (AnnotationBag) bagMap.get(annotationType); | 322 AnnotationBag bag= cast(AnnotationBag) bagMap.get(annotationType); |
323 if (bag is null && fAnnotationAccess instanceof IAnnotationAccessExtension) { | 323 if (bag is null && fAnnotationAccess instanceof IAnnotationAccessExtension) { |
324 IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess; | 324 IAnnotationAccessExtension extension= cast(IAnnotationAccessExtension) fAnnotationAccess; |
325 Object[] superTypes= extension.getSupertypes(annotationType); | 325 Object[] superTypes= extension.getSupertypes(annotationType); |
326 for (int i= 0; i < superTypes.length && bag is null; i++) { | 326 for (int i= 0; i < superTypes.length && bag is null; i++) { |
327 bag= (AnnotationBag) bagMap.get(superTypes[i]); | 327 bag= cast(AnnotationBag) bagMap.get(superTypes[i]); |
328 } | 328 } |
329 } | 329 } |
330 return bag; | 330 return bag; |
331 } | 331 } |
332 | 332 |