diff options
Diffstat (limited to 'org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java')
-rw-r--r-- | org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java index 76fbd83d51c..24efa76ff4f 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -53,16 +52,16 @@ public class AnnotationHighlighter extends Highlighter { @Override public void addHighlights(Match[] matches) { HashMap<Annotation, Position> map= new HashMap<>(matches.length); - for (int i= 0; i < matches.length; i++) { - int offset= matches[i].getOffset(); - int length= matches[i].getLength(); + for (Match match : matches) { + int offset= match.getOffset(); + int length= match.getLength(); if (offset >= 0 && length >= 0) { - Position position= createPosition(matches[i]); + Position position= createPosition(match); if (position != null) { - Annotation annotation= matches[i].isFiltered() + Annotation annotation= match.isFiltered() ? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null) : new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null); - fMatchesToAnnotations.put(matches[i], annotation); + fMatchesToAnnotations.put(match, annotation); map.put(annotation, position); } } @@ -97,8 +96,8 @@ public class AnnotationHighlighter extends Highlighter { @Override public void removeHighlights(Match[] matches) { HashSet<Annotation> annotations= new HashSet<>(matches.length); - for (int i= 0; i < matches.length; i++) { - Annotation annotation= fMatchesToAnnotations.remove(matches[i]); + for (Match match : matches) { + Annotation annotation= fMatchesToAnnotations.remove(match); if (annotation != null) { annotations.add(annotation); } @@ -138,8 +137,7 @@ public class AnnotationHighlighter extends Highlighter { Annotation[] annotationArray= new Annotation[annotations.size()]; ame.replaceAnnotations(annotations.toArray(annotationArray), Collections.emptyMap()); } else { - for (Iterator<Annotation> iter= annotations.iterator(); iter.hasNext();) { - Annotation element= iter.next(); + for (Annotation element : annotations) { fModel.removeAnnotation(element); } } |