Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/DefaultAnnotationHover.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 |
---|---|
131 if (javaAnnotations !is null) { | 131 if (javaAnnotations !is null) { |
132 | 132 |
133 if (javaAnnotations.size() is 1) { | 133 if (javaAnnotations.size() is 1) { |
134 | 134 |
135 // optimization | 135 // optimization |
136 Annotation annotation= (Annotation) javaAnnotations.get(0); | 136 Annotation annotation= cast(Annotation) javaAnnotations.get(0); |
137 String message= annotation.getText(); | 137 String message= annotation.getText(); |
138 if (message !is null && message.trim().length() > 0) | 138 if (message !is null && message.trim().length() > 0) |
139 return formatSingleMessage(message); | 139 return formatSingleMessage(message); |
140 | 140 |
141 } else { | 141 } else { |
142 | 142 |
143 List messages= new ArrayList(); | 143 List messages= new ArrayList(); |
144 | 144 |
145 Iterator e= javaAnnotations.iterator(); | 145 Iterator e= javaAnnotations.iterator(); |
146 while (e.hasNext()) { | 146 while (e.hasNext()) { |
147 Annotation annotation= (Annotation) e.next(); | 147 Annotation annotation= cast(Annotation) e.next(); |
148 String message= annotation.getText(); | 148 String message= annotation.getText(); |
149 if (message !is null && message.trim().length() > 0) | 149 if (message !is null && message.trim().length() > 0) |
150 messages.add(message.trim()); | 150 messages.add(message.trim()); |
151 } | 151 } |
152 | 152 |
153 if (messages.size() is 1) | 153 if (messages.size() is 1) |
154 return formatSingleMessage((String)messages.get(0)); | 154 return formatSingleMessage(cast(String)messages.get(0)); |
155 | 155 |
156 if (messages.size() > 1) | 156 if (messages.size() > 1) |
157 return formatMultipleMessages(messages); | 157 return formatMultipleMessages(messages); |
158 } | 158 } |
159 } | 159 } |
204 buffer.append(JFaceTextMessages.getString("DefaultAnnotationHover.multipleMarkers")); //$NON-NLS-1$ | 204 buffer.append(JFaceTextMessages.getString("DefaultAnnotationHover.multipleMarkers")); //$NON-NLS-1$ |
205 | 205 |
206 Iterator e= messages.iterator(); | 206 Iterator e= messages.iterator(); |
207 while (e.hasNext()) { | 207 while (e.hasNext()) { |
208 buffer.append('\n'); | 208 buffer.append('\n'); |
209 String listItemText= (String) e.next(); | 209 String listItemText= cast(String) e.next(); |
210 buffer.append(JFaceTextMessages.getFormattedString("DefaultAnnotationHover.listItem", new String[] { listItemText })); //$NON-NLS-1$ | 210 buffer.append(JFaceTextMessages.getFormattedString("DefaultAnnotationHover.listItem", new String[] { listItemText })); //$NON-NLS-1$ |
211 } | 211 } |
212 return buffer.toString(); | 212 return buffer.toString(); |
213 } | 213 } |
214 | 214 |
222 return false; | 222 return false; |
223 } | 223 } |
224 | 224 |
225 private IAnnotationModel getAnnotationModel(ISourceViewer viewer) { | 225 private IAnnotationModel getAnnotationModel(ISourceViewer viewer) { |
226 if (viewer instanceof ISourceViewerExtension2) { | 226 if (viewer instanceof ISourceViewerExtension2) { |
227 ISourceViewerExtension2 extension= (ISourceViewerExtension2) viewer; | 227 ISourceViewerExtension2 extension= cast(ISourceViewerExtension2) viewer; |
228 return extension.getVisualAnnotationModel(); | 228 return extension.getVisualAnnotationModel(); |
229 } | 229 } |
230 return viewer.getAnnotationModel(); | 230 return viewer.getAnnotationModel(); |
231 } | 231 } |
232 | 232 |
235 Object value= messagesAtPosition.get(position); | 235 Object value= messagesAtPosition.get(position); |
236 if (message.equals(value)) | 236 if (message.equals(value)) |
237 return true; | 237 return true; |
238 | 238 |
239 if (value instanceof List) { | 239 if (value instanceof List) { |
240 List messages= (List)value; | 240 List messages= cast(List)value; |
241 if (messages.contains(message)) | 241 if (messages.contains(message)) |
242 return true; | 242 return true; |
243 | 243 |
244 messages.add(message); | 244 messages.add(message); |
245 } else { | 245 } else { |
270 List javaAnnotations= new ArrayList(); | 270 List javaAnnotations= new ArrayList(); |
271 HashMap messagesAtPosition= new HashMap(); | 271 HashMap messagesAtPosition= new HashMap(); |
272 Iterator iterator= model.getAnnotationIterator(); | 272 Iterator iterator= model.getAnnotationIterator(); |
273 | 273 |
274 while (iterator.hasNext()) { | 274 while (iterator.hasNext()) { |
275 Annotation annotation= (Annotation) iterator.next(); | 275 Annotation annotation= cast(Annotation) iterator.next(); |
276 | 276 |
277 Position position= model.getPosition(annotation); | 277 Position position= model.getPosition(annotation); |
278 if (position is null) | 278 if (position is null) |
279 continue; | 279 continue; |
280 | 280 |
281 if (!isRulerLine(position, document, line)) | 281 if (!isRulerLine(position, document, line)) |
282 continue; | 282 continue; |
283 | 283 |
284 if (annotation instanceof AnnotationBag) { | 284 if (annotation instanceof AnnotationBag) { |
285 AnnotationBag bag= (AnnotationBag) annotation; | 285 AnnotationBag bag= cast(AnnotationBag) annotation; |
286 Iterator e= bag.iterator(); | 286 Iterator e= bag.iterator(); |
287 while (e.hasNext()) { | 287 while (e.hasNext()) { |
288 annotation= (Annotation) e.next(); | 288 annotation= cast(Annotation) e.next(); |
289 position= model.getPosition(annotation); | 289 position= model.getPosition(annotation); |
290 if (position !is null && includeAnnotation(annotation, position, messagesAtPosition)) | 290 if (position !is null && includeAnnotation(annotation, position, messagesAtPosition)) |
291 javaAnnotations.add(annotation); | 291 javaAnnotations.add(annotation); |
292 } | 292 } |
293 continue; | 293 continue; |