Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Stanik2017-07-17 14:53:45 -0400
committerAlexander Kurtakov2017-08-07 04:12:55 -0400
commit896e9624a30afb9e3f75daa648707b808d26ae0b (patch)
treefecf12e2a81a5065e23097c09860eb508f5792a1
parent30c01e1e4b9f3f6feb22bf12a7248de589b24b9b (diff)
downloadeclipse.platform.text-896e9624a30afb9e3f75daa648707b808d26ae0b.tar.gz
eclipse.platform.text-896e9624a30afb9e3f75daa648707b808d26ae0b.tar.xz
eclipse.platform.text-896e9624a30afb9e3f75daa648707b808d26ae0b.zip
Bug 519785 - Use enhanced for loops in org.eclipse.searchI20170808-2000I20170807-2000
Change-Id: I3b6d471d4a889bf7769cd9d3d1cd9bbba3447361 Signed-off-by: Christoph Stanik <stanik@informatik.uni-hamburg.de>
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java3
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java29
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java33
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java10
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java6
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java4
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java8
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java3
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java11
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java13
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java10
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java4
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java6
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java20
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java33
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java3
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java10
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java21
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java20
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java3
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java3
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java12
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java12
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java18
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java10
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java3
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java3
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java6
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java12
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java10
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java8
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java39
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java14
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java4
42 files changed, 193 insertions, 252 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java b/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java
index c81126d10..d2d9167b3 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java
@@ -76,8 +76,7 @@ public class TextSearchGroup extends ActionGroup {
private void createActions(IEditorPart editor) {
fActions= new FindInRecentScopeActionDelegate[] {
new FindInWorkspaceActionDelegate(), new FindInProjectActionDelegate(), new FindInFileActionDelegate(), new FindInWorkingSetActionDelegate()};
- for (int i= 0; i < fActions.length; i++) {
- FindInRecentScopeActionDelegate action= fActions[i];
+ for (FindInRecentScopeActionDelegate action : fActions) {
action.setActiveEditor(action, editor);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
index f4ba3d60c..70be72679 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java
@@ -96,9 +96,9 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
public void addMatches(Match[] matches) {
Collection<Match> reallyAdded= new ArrayList<>();
synchronized (fElementsToMatches) {
- for (int i = 0; i < matches.length; i++) {
- if (doAddMatch(matches[i]))
- reallyAdded.add(matches[i]);
+ for (Match match : matches) {
+ if (doAddMatch(match))
+ reallyAdded.add(match);
}
}
if (!reallyAdded.isEmpty())
@@ -208,9 +208,9 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
public void removeMatches(Match[] matches) {
Collection<Match> existing= new ArrayList<>();
synchronized (fElementsToMatches) {
- for (int i = 0; i < matches.length; i++) {
- if (doRemoveMatch(matches[i]))
- existing.add(matches[i]); // no duplicate matches at this point
+ for (Match match : matches) {
+ if (doRemoveMatch(match))
+ existing.add(match); // no duplicate matches at this point
}
}
if (!existing.isEmpty())
@@ -266,11 +266,11 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
boolean disableFiltering= getActiveMatchFilters() == null;
ArrayList<Match> changed= new ArrayList<>();
Object[] elements= getElements();
- for (int i= 0; i < elements.length; i++) {
- Match[] matches= getMatches(elements[i]);
- for (int k= 0; k < matches.length; k++) {
- if (disableFiltering || updateFilterState(matches[k])) {
- changed.add(matches[k]);
+ for (Object element : elements) {
+ Match[] matches= getMatches(element);
+ for (Match match : matches) {
+ if (disableFiltering || updateFilterState(match)) {
+ changed.add(match);
}
}
}
@@ -288,8 +288,8 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
}
boolean oldState= match.isFiltered();
- for (int i= 0; i < matchFilters.length; i++) {
- if (matchFilters[i].filters(match)) {
+ for (MatchFilter matchFilter : matchFilters) {
+ if (matchFilter.filters(match)) {
match.setFiltered(true);
return !oldState;
}
@@ -307,8 +307,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult {
public int getMatchCount() {
int count= 0;
synchronized (fElementsToMatches) {
- for (Iterator<List<Match>> elements= fElementsToMatches.values().iterator(); elements.hasNext();) {
- List<Match> element= elements.next();
+ for (List<Match> element : fElementsToMatches.values()) {
if (element != null)
count+= element.size();
}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
index cbcfd328b..fcc481a5b 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
@@ -13,7 +13,6 @@ package org.eclipse.search.ui.text;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.eclipse.swt.SWT;
@@ -201,8 +200,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
public void selectionChanged(SelectionChangedEvent event) {
// forward to my listeners
SelectionChangedEvent wrappedEvent= new SelectionChangedEvent(this, event.getSelection());
- for (Iterator<ISelectionChangedListener> listeners= fListeners.iterator(); listeners.hasNext();) {
- ISelectionChangedListener listener= listeners.next();
+ for (ISelectionChangedListener listener : fListeners) {
listener.selectionChanged(wrappedEvent);
}
}
@@ -855,8 +853,8 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
IMenuManager menu= bars.getMenuManager();
if (filterActions != null) {
- for (int i= 0; i < filterActions.length; i++) {
- menu.remove(filterActions[i].getId());
+ for (IAction filterAction : filterActions) {
+ menu.remove(filterAction.getId());
}
}
menu.remove(MatchFilterSelectionAction.ACTION_ID);
@@ -892,8 +890,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
private void updateFilterActions(IAction[] filterActions) {
if (filterActions != null) {
- for (int i= 0; i < filterActions.length; i++) {
- IAction curr= filterActions[i];
+ for (IAction curr : filterActions) {
if (curr instanceof IUpdate) {
((IUpdate) curr).update();
}
@@ -1238,8 +1235,8 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
* @since 3.4
*/
protected void evaluateChangedElements(Match[] matches, Set<Object> changedElements) {
- for (int i = 0; i < matches.length; i++) {
- changedElements.add(matches[i].getElement());
+ for (Match match : matches) {
+ changedElements.add(match.getElement());
}
}
@@ -1369,21 +1366,21 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
}
private void collectAllMatches(HashSet<Match> set, Object[] elements) {
- for (int j = 0; j < elements.length; j++) {
- Match[] matches = getDisplayedMatches(elements[j]);
- for (int i = 0; i < matches.length; i++) {
- set.add(matches[i]);
+ for (Object element : elements) {
+ Match[] matches = getDisplayedMatches(element);
+ for (Match match : matches) {
+ set.add(match);
}
}
}
private void collectAllMatchesBelow(AbstractTextSearchResult result, Set<Match> set, ITreeContentProvider cp, Object[] elements) {
- for (int j = 0; j < elements.length; j++) {
- Match[] matches = getDisplayedMatches(elements[j]);
- for (int i = 0; i < matches.length; i++) {
- set.add(matches[i]);
+ for (Object element : elements) {
+ Match[] matches = getDisplayedMatches(element);
+ for (Match match : matches) {
+ set.add(match);
}
- Object[] children = cp.getChildren(elements[j]);
+ Object[] children = cp.getChildren(element);
collectAllMatchesBelow(result, set, cp, children);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
index 870b5d5c0..fcb467938 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
@@ -262,8 +262,7 @@ public final class FileTextSearchScope extends TextSearchScope {
private static IResource[] removeRedundantEntries(IResource[] elements, boolean includeDerived) {
ArrayList<IResource> res= new ArrayList<>();
- for (int i= 0; i < elements.length; i++) {
- IResource curr= elements[i];
+ for (IResource curr : elements) {
addToList(res, curr, includeDerived);
}
return res.toArray(new IResource[res.size()]);
@@ -271,14 +270,13 @@ public final class FileTextSearchScope extends TextSearchScope {
private static IResource[] convertToResources(IWorkingSet[] workingSets, boolean includeDerived) {
ArrayList<IResource> res= new ArrayList<>();
- for (int i= 0; i < workingSets.length; i++) {
- IWorkingSet workingSet= workingSets[i];
+ for (IWorkingSet workingSet : workingSets) {
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
return new IResource[] { ResourcesPlugin.getWorkspace().getRoot() };
}
IAdaptable[] elements= workingSet.getElements();
- for (int k= 0; k < elements.length; k++) {
- IResource curr= elements[k].getAdapter(IResource.class);
+ for (IAdaptable element : elements) {
+ IResource curr= element.getAdapter(IResource.class);
if (curr != null) {
addToList(res, curr, includeDerived);
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
index 70a539cb5..5b2a7b494 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
@@ -321,8 +321,7 @@ public class InternalSearchUI {
int numberQueriesNotShown= 0;
SearchViewManager searchViewManager= getSearchViewManager();
ISearchQuery[] queries= searchManager.getQueries();
- for (int i= 0; i < queries.length; i++) {
- ISearchQuery query= queries[i];
+ for (ISearchQuery query : queries) {
if (!searchViewManager.isShown(query)) {
if (++numberQueriesNotShown >= historyLimit) {
removeQuery(query);
@@ -332,8 +331,7 @@ public class InternalSearchUI {
}
public void removeAllQueries() {
- for (Iterator<ISearchQuery> queries= fSearchJobs.keySet().iterator(); queries.hasNext();) {
- ISearchQuery query= queries.next();
+ for (ISearchQuery query : fSearchJobs.keySet()) {
cancelSearch(query);
}
fSearchJobs.clear();
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java
index 27978fe4b..56344316b 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java
@@ -67,8 +67,8 @@ public class MatchFilterAction extends Action implements IUpdate {
AbstractTextSearchResult input= fPage.getInput();
if (input != null) {
MatchFilter[] activeMatchFilters= input.getActiveMatchFilters();
- for (int i= 0; i < activeMatchFilters.length; i++) {
- if (fFilter.equals(activeMatchFilters[i])) {
+ for (MatchFilter activeMatchFilter : activeMatchFilters) {
+ if (fFilter.equals(activeMatchFilter)) {
return true;
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java
index b2acc9a03..e9c68ef8c 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java
@@ -117,10 +117,10 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator {
ISearchQuery[] searches= NewSearchUI.getQueries();
if (searches.length > 0) {
- for (int i= 0; i < searches.length; i++) {
- ISearchResult search= searches[i].getSearchResult();
- ShowSearchFromHistoryAction action= new ShowSearchFromHistoryAction(search);
- action.setChecked(search.equals(currentSearch));
+ for (ISearchQuery search : searches) {
+ ISearchResult searchResult= search.getSearchResult();
+ ShowSearchFromHistoryAction action= new ShowSearchFromHistoryAction(searchResult);
+ action.setChecked(searchResult.equals(currentSearch));
addActionToMenu(fMenu, action);
}
new MenuItem(fMenu, SWT.SEPARATOR);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java
index 939b8edca..5d41472ec 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java
@@ -421,8 +421,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog {
setResult(((IStructuredSelection) fViewer.getSelection()).toList());
// remove queries
- for (Iterator<ISearchResult> iter= fRemovedEntries.iterator(); iter.hasNext();) {
- ISearchResult result= iter.next();
+ for (ISearchResult result : fRemovedEntries) {
ISearchQuery query= result.getQuery();
if (query != null) { // must not be null: invalid implementation of a search query
InternalSearchUI.getInstance().removeQuery(query);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
index 0eb8fc7c2..05b49c990 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java
@@ -43,8 +43,8 @@ public class SearchPageRegistry {
fExtensionToInstance= new HashMap<>();
fResultClassNameToExtension= new HashMap<>();
fExtensions= Platform.getExtensionRegistry().getConfigurationElementsFor(ID_EXTENSION_POINT);
- for (int i= 0; i < fExtensions.length; i++) {
- fResultClassNameToExtension.put(fExtensions[i].getAttribute(ATTRIB_SEARCH_RESULT_CLASS), fExtensions[i]);
+ for (IConfigurationElement fExtension : fExtensions) {
+ fResultClassNameToExtension.put(fExtension.getAttribute(ATTRIB_SEARCH_RESULT_CLASS), fExtension);
}
}
@@ -108,8 +108,7 @@ public class SearchPageRegistry {
}
private IConfigurationElement findConfigurationElement(String pageId) {
- for (int i= 0; i < fExtensions.length; i++) {
- IConfigurationElement curr= fExtensions[i];
+ for (IConfigurationElement curr : fExtensions) {
if (pageId.equals(curr.getAttribute(ATTRIB_ID))) {
return curr;
}
@@ -133,8 +132,8 @@ public class SearchPageRegistry {
}
Class<?>[] interfaces= resultClass.getInterfaces();
- for (int i= 0; i < interfaces.length; i++) {
- IConfigurationElement foundExtension= findConfigurationElement(interfaces[i]);
+ for (Class<?> interface1 : interfaces) {
+ IConfigurationElement foundExtension= findConfigurationElement(interface1);
if (foundExtension != null) {
fResultClassNameToExtension.put(className, configElement);
return foundExtension;
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
index b64c170db..d1822251b 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
@@ -15,7 +15,6 @@
package org.eclipse.search2.internal.ui;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map.Entry;
import com.ibm.icu.text.MessageFormat;
@@ -556,8 +555,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
int bestActivation= -1;
IMemento restorePageMemento= null;
IMemento[] children= fPageState.getChildren(MEMENTO_TYPE);
- for (int i= 0; i < children.length; i++) {
- IMemento pageMemento= children[i];
+ for (IMemento pageMemento : children) {
if (pageMemento.getString(MEMENTO_KEY_RESTORE) != null) {
Integer lastActivation= pageMemento.getInteger(MEMENTO_KEY_LAST_ACTIVATION);
if (lastActivation != null && lastActivation.intValue() > bestActivation) {
@@ -690,8 +688,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
@Override
public void saveState(IMemento memento) {
- for (Iterator<Entry<ISearchResultPage, DummyPart>> iter= fPagesToParts.entrySet().iterator(); iter.hasNext();) {
- Entry<ISearchResultPage, DummyPart> entry= iter.next();
+ for (Entry<ISearchResultPage, DummyPart> entry : fPagesToParts.entrySet()) {
ISearchResultPage page= entry.getKey();
DummyPart part= entry.getValue();
@@ -725,9 +722,9 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
IMemento memento= null;
if (fPageState != null) {
IMemento[] mementos= fPageState.getChildren(MEMENTO_TYPE);
- for (int i= 0; i < mementos.length; i++) {
- if (mementos[i].getID().equals(srPage.getID())) {
- memento= mementos[i];
+ for (IMemento memento2 : mementos) {
+ if (memento2.getID().equals(srPage.getID())) {
+ memento= memento2;
break;
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java
index 0d0f7d3ea..c7e13e9a8 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java
@@ -11,7 +11,6 @@
package org.eclipse.search2.internal.ui;
-import java.util.Iterator;
import java.util.LinkedList;
import org.eclipse.ui.IViewReference;
@@ -120,8 +119,7 @@ public class SearchViewManager {
}
public boolean isShown(ISearchQuery query) {
- for (Iterator<SearchView> iter= fLRUSearchViews.iterator(); iter.hasNext();) {
- SearchView view= iter.next();
+ for (SearchView view : fLRUSearchViews) {
ISearchResult currentSearchResult= view.getCurrentSearchResult();
if (currentSearchResult != null && query == currentSearchResult.getQuery()) {
return true;
@@ -142,8 +140,7 @@ public class SearchViewManager {
private ISearchResultViewPart findLRUSearchResultView(IWorkbenchPage page, boolean avoidPinnedViews) {
boolean viewFoundInPage= false;
- for (Iterator<SearchView> iter= fLRUSearchViews.iterator(); iter.hasNext();) {
- SearchView view= iter.next();
+ for (SearchView view : fLRUSearchViews) {
if (page.equals(view.getSite().getPage())) {
if (!avoidPinnedViews || !view.isPinned()) {
return view;
@@ -154,8 +151,7 @@ public class SearchViewManager {
if (!viewFoundInPage) {
// find unresolved views
IViewReference[] viewReferences= page.getViewReferences();
- for (int i= 0; i < viewReferences.length; i++) {
- IViewReference curr= viewReferences[i];
+ for (IViewReference curr : viewReferences) {
if (NewSearchUI.SEARCH_VIEW_ID.equals(curr.getId()) && page.equals(curr.getPage())) {
SearchView view= (SearchView) curr.getView(true);
if (view != null && (!avoidPinnedViews || !view.isPinned())) {
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java
index bfee6fcfb..47ed4a626 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java
@@ -44,8 +44,8 @@ class ShowSearchHistoryDialogAction extends Action {
ISearchQuery[] queries= NewSearchUI.getQueries();
ArrayList<ISearchResult> input= new ArrayList<>();
- for (int j= 0; j < queries.length; j++) {
- ISearchResult search= queries[j].getSearchResult();
+ for (ISearchQuery query : queries) {
+ ISearchResult search= query.getSearchResult();
input.add(search);
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java
index c9d03ab00..860569e63 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java
@@ -52,9 +52,9 @@ public class TreeViewerNavigator implements INavigate {
TreeItem[] roots= fViewer.getTree().getItems();
if (roots.length == 0)
return null;
- for (int i = 0; i < roots.length; i++) {
- if (hasMatches(roots[i]))
- return roots[i];
+ for (TreeItem root : roots) {
+ if (hasMatches(root))
+ return root;
TreeItem firstChild= getFirstChildWithMatches(roots[0]);
if (firstChild != null)
return firstChild;
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 76fbd83d5..24efa76ff 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);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
index b18f9dacc..406e46a3c 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java
@@ -13,7 +13,6 @@ package org.eclipse.search2.internal.ui.text;
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;
@@ -51,19 +50,19 @@ public class EditorAccessHighlighter extends Highlighter {
@Override
public void addHighlights(Match[] matches) {
Map<IAnnotationModel, HashMap<Annotation, Position>> mapsByAnnotationModel= new HashMap<>();
- 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) {
try {
- Position position= createPosition(matches[i]);
+ Position position= createPosition(match);
if (position != null) {
- Map<Annotation, Position> map= getMap(mapsByAnnotationModel, matches[i]);
+ Map<Annotation, Position> map= getMap(mapsByAnnotationModel, match);
if (map != 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);
}
}
@@ -124,17 +123,16 @@ public class EditorAccessHighlighter extends Highlighter {
@Override
public void removeHighlights(Match[] matches) {
Map<IAnnotationModel, HashSet<Annotation>> setsByAnnotationModel= new HashMap<>();
- 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) {
- Set<Annotation> annotations= getSet(setsByAnnotationModel, matches[i]);
+ Set<Annotation> annotations= getSet(setsByAnnotationModel, match);
if (annotations != null)
annotations.add(annotation);
}
}
- for (Iterator<IAnnotationModel> maps= setsByAnnotationModel.keySet().iterator(); maps.hasNext();) {
- IAnnotationModel model= maps.next();
+ for (IAnnotationModel model : setsByAnnotationModel.keySet()) {
Set<Annotation> set= setsByAnnotationModel.get(model);
removeAnnotations(model, set);
}
@@ -146,8 +144,7 @@ public class EditorAccessHighlighter extends Highlighter {
IAnnotationModelExtension ame= (IAnnotationModelExtension) model;
ame.replaceAnnotations(new Annotation[0], annotationToPositionMap);
} else {
- for (Iterator<Annotation> elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) {
- Annotation element= elements.next();
+ for (Annotation element : annotationToPositionMap.keySet()) {
Position p= annotationToPositionMap.get(element);
model.addAnnotation(element, p);
}
@@ -167,8 +164,7 @@ public class EditorAccessHighlighter 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) {
model.removeAnnotation(element);
}
}
@@ -187,8 +183,7 @@ public class EditorAccessHighlighter extends Highlighter {
return;
IDocument document= null;
ITextFileBuffer textBuffer= (ITextFileBuffer) buffer;
- for (Iterator<Match> matches = fMatchesToAnnotations.keySet().iterator(); matches.hasNext();) {
- Match match = matches.next();
+ for (Match match : fMatchesToAnnotations.keySet()) {
document= fEditorAcess.getDocument(match);
if (document != null)
break;
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
index 30334152f..e4f662f85 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
@@ -155,8 +155,7 @@ public class EditorAnnotationManager implements ISearchResultListener {
}
ArrayList<Match> matchesInEditor= null; // lazy initialization
- for (int i= 0; i < matches.length; i++) {
- Match curr= matches[i];
+ for (Match curr : matches) {
if (adapter.isShownInEditor(curr, fEditor)) {
if (matchesInEditor == null) {
matchesInEditor= new ArrayList<>();
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
index 6e83797ce..7c557ab1d 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java
@@ -47,11 +47,11 @@ public class MarkerHighlighter extends Highlighter {
SearchPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- for (int i = 0; i < matches.length; i++) {
+ for (Match match : matches) {
IMarker marker;
- marker = createMarker(matches[i]);
+ marker = createMarker(match);
if (marker != null)
- fMatchesToAnnotations.put(matches[i], marker);
+ fMatchesToAnnotations.put(match, marker);
}
}
}, fFile, IWorkspace.AVOID_UPDATE, null);
@@ -87,8 +87,8 @@ public class MarkerHighlighter extends Highlighter {
@Override
public void removeHighlights(Match[] matches) {
- for (int i= 0; i < matches.length; i++) {
- IMarker marker= fMatchesToAnnotations.remove(matches[i]);
+ for (Match match : matches) {
+ IMarker marker= fMatchesToAnnotations.remove(match);
if (marker != null) {
try {
marker.delete();
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
index b5ed04173..613c79772 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java
@@ -12,7 +12,6 @@ package org.eclipse.search2.internal.ui.text;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -86,10 +85,10 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
Match[] matches = evt.getMatches();
int kind = evt.getKind();
AbstractTextSearchResult result = (AbstractTextSearchResult) e.getSearchResult();
- for (int i = 0; i < matches.length; i++) {
- ITextFileBuffer fb= getTrackedFileBuffer(result, matches[i].getElement());
+ for (Match match : matches) {
+ ITextFileBuffer fb= getTrackedFileBuffer(result, match.getElement());
if (fb != null) {
- updateMatch(matches[i], fb, kind, result);
+ updateMatch(match, fb, kind, result);
}
}
} else if (e instanceof RemoveAllEvent) {
@@ -109,8 +108,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
private void untrackAll(AbstractTextSearchResult result) {
Set<Match> matchSet= new HashSet<>(fMatchesToPositions.keySet());
- for (Iterator<Match> matches= matchSet.iterator(); matches.hasNext();) {
- Match match= matches.next();
+ for (Match match : matchSet) {
AbstractTextSearchResult matchContainer= fMatchesToSearchResults.get(match);
if (result.equals(matchContainer)) {
ITextFileBuffer fb= getTrackedFileBuffer(result, match.getElement());
@@ -249,16 +247,16 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
return;
ISearchQuery[] queries= NewSearchUI.getQueries();
- for (int i = 0; i < queries.length; i++) {
- ISearchResult result = queries[i].getSearchResult();
+ for (ISearchQuery query : queries) {
+ ISearchResult result = query.getSearchResult();
if (result instanceof AbstractTextSearchResult) {
AbstractTextSearchResult textResult = (AbstractTextSearchResult) result;
IFileMatchAdapter adapter = textResult.getFileMatchAdapter();
if (adapter != null) {
Match[] matches = adapter.computeContainedMatches(textResult, file);
- for (int j = 0; j < matches.length; j++) {
+ for (Match match : matches) {
trackCount[0]++;
- trackPosition((AbstractTextSearchResult) result, (ITextFileBuffer) buffer, matches[j]);
+ trackPosition((AbstractTextSearchResult) result, (ITextFileBuffer) buffer, match);
}
}
}
@@ -271,8 +269,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I
Set<Match> matches= fFileBuffersToMatches.get(buffer);
if (matches != null) {
Set<Match> matchSet= new HashSet<>(matches);
- for (Iterator<Match> matchIterator= matchSet.iterator(); matchIterator.hasNext();) {
- Match element= matchIterator.next();
+ for (Match element : matchSet) {
operation.run((ITextFileBuffer) buffer, element);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java
index 65ff7f2cd..3c39c448a 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java
@@ -12,7 +12,6 @@ package org.eclipse.search2.internal.ui.text;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.ui.IEditorPart;
@@ -103,11 +102,11 @@ public class WindowAnnotationManager {
private void initEditors() {
IWorkbenchPage[] pages= fWindow.getPages();
- for (int i = 0; i < pages.length; i++) {
- IEditorReference[] editors= pages[i].getEditorReferences();
- for (int j = 0; j < editors.length; j++) {
- IEditorPart editor= editors[j].getEditor(false);
- if (editor != null && pages[i].isPartVisible(editor)) {
+ for (IWorkbenchPage page : pages) {
+ IEditorReference[] editors= page.getEditorReferences();
+ for (IEditorReference editor2 : editors) {
+ IEditorPart editor= editor2.getEditor(false);
+ if (editor != null && page.isPartVisible(editor)) {
startHighlighting(editor);
}
}
@@ -131,8 +130,7 @@ public class WindowAnnotationManager {
void dispose() {
fWindow.getPartService().removePartListener(fPartListener);
- for (Iterator<EditorAnnotationManager> mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
- EditorAnnotationManager mgr = mgrs.next();
+ for (EditorAnnotationManager mgr : fAnnotationManagers.values()) {
mgr.dispose();
}
fAnnotationManagers= null;
@@ -142,8 +140,7 @@ public class WindowAnnotationManager {
boolean alreadyShown= fSearchResults.contains(result);
fSearchResults.add(result);
if (!alreadyShown) {
- for (Iterator<EditorAnnotationManager> mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
- EditorAnnotationManager mgr = mgrs.next();
+ for (EditorAnnotationManager mgr : fAnnotationManagers.values()) {
mgr.addSearchResult(result);
}
}
@@ -153,8 +150,7 @@ public class WindowAnnotationManager {
fSearchResults.remove(result);
boolean stillShown= fSearchResults.contains(result);
if (!stillShown) {
- for (Iterator<EditorAnnotationManager> mgrs = fAnnotationManagers.values().iterator(); mgrs.hasNext();) {
- EditorAnnotationManager mgr = mgrs.next();
+ for (EditorAnnotationManager mgr : fAnnotationManagers.values()) {
mgr.removeSearchResult(result);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
index 10f146c5a..a35e6378a 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
@@ -73,8 +73,7 @@ public class TextSearchQueryProviderRegistry {
@Override
public void run() throws Exception {
IConfigurationElement[] extensions= Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
- for (int i= 0; i < extensions.length; i++) {
- IConfigurationElement curr= extensions[i];
+ for (IConfigurationElement curr : extensions) {
if (PROVIDER_NODE_NAME.equals(curr.getName()) && id.equals(curr.getAttribute(ATTRIB_ID))) {
res[0]= (TextSearchQueryProvider) curr.createExecutableExtension(ATTRIB_CLASS);
return;
@@ -95,8 +94,7 @@ public class TextSearchQueryProviderRegistry {
res.add(new String[] { SearchMessages.TextSearchQueryProviderRegistry_defaultProviderLabel, "" }); //$NON-NLS-1$
IConfigurationElement[] extensions= Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
- for (int i= 0; i < extensions.length; i++) {
- IConfigurationElement engine= extensions[i];
+ for (IConfigurationElement engine : extensions) {
if (PROVIDER_NODE_NAME.equals(engine.getName())) {
res.add(new String[] { engine.getAttribute(ATTRIB_LABEL), engine.getAttribute(ATTRIB_ID) });
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java
index a93aa568d..0d2e83ffd 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java
@@ -156,8 +156,7 @@ public class FileNamePatternSearchScope extends TextSearchScope {
private static IResource[] removeRedundantEntries(IResource[] elements, boolean includeDerived) {
ArrayList<IResource> res= new ArrayList<>();
- for (int i= 0; i < elements.length; i++) {
- IResource curr= elements[i];
+ for (IResource curr : elements) {
addToList(res, curr, includeDerived);
}
return res.toArray(new IResource[res.size()]);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java
index b4b2ec1c7..91ace2479 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/FilesOfScopeCalculator.java
@@ -47,9 +47,8 @@ public class FilesOfScopeCalculator implements IResourceProxyVisitor {
fFiles= new ArrayList<>();
try {
IResource[] roots= fScope.getRoots();
- for (int i= 0; i < roots.length; i++) {
+ for (IResource resource : roots) {
try {
- IResource resource= roots[i];
if (resource.isAccessible()) {
resource.accept(this, 0);
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
index 20ab53caa..db5acafa0 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
@@ -82,8 +82,7 @@ public class TextSearchEngineRegistry {
@Override
public void run() throws Exception {
IConfigurationElement[] extensions= Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
- for (int i= 0; i < extensions.length; i++) {
- IConfigurationElement curr= extensions[i];
+ for (IConfigurationElement curr : extensions) {
if (ENGINE_NODE_NAME.equals(curr.getName()) && id.equals(curr.getAttribute(ATTRIB_ID))) {
res[0]= (TextSearchEngine) curr.createExecutableExtension(ATTRIB_CLASS);
return;
@@ -104,8 +103,7 @@ public class TextSearchEngineRegistry {
res.add(new String[] { SearchMessages.TextSearchEngineRegistry_defaulttextsearch_label, "" }); //$NON-NLS-1$
IConfigurationElement[] extensions= Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
- for (int i= 0; i < extensions.length; i++) {
- IConfigurationElement engine= extensions[i];
+ for (IConfigurationElement engine : extensions) {
if (ENGINE_NODE_NAME.equals(engine.getName())) {
res.add(new String[] { engine.getAttribute(ATTRIB_LABEL), engine.getAttribute(ATTRIB_ID) });
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
index 552c24111..63a10cbc7 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
@@ -438,12 +438,12 @@ public class TextSearchVisitor {
Map<IFile, IDocument> result= new HashMap<>();
IWorkbench workbench= SearchPlugin.getDefault().getWorkbench();
IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- for (int i= 0; i < windows.length; i++) {
- IWorkbenchPage[] pages= windows[i].getPages();
- for (int x= 0; x < pages.length; x++) {
- IEditorReference[] editorRefs= pages[x].getEditorReferences();
- for (int z= 0; z < editorRefs.length; z++) {
- IEditorPart ep= editorRefs[z].getEditor(false);
+ for (IWorkbenchWindow window : windows) {
+ IWorkbenchPage[] pages= window.getPages();
+ for (IWorkbenchPage page : pages) {
+ IEditorReference[] editorRefs= page.getEditorReferences();
+ for (IEditorReference editorRef : editorRefs) {
+ IEditorPart ep= editorRef.getEditor(false);
if (ep instanceof ITextEditor && ep.isDirty()) { // only dirty editors
evaluateTextEditor(result, ep);
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java
index 33ebb3c12..ade38dfb8 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/OpenSearchDialogPageAction.java
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.search.internal.ui;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.events.MenuAdapter;
@@ -77,8 +76,7 @@ public class OpenSearchDialogPageAction implements IWorkbenchWindowPulldownDeleg
private void fillMenu(final Menu localMenu) {
List<SearchPageDescriptor> pageDescriptors= SearchPlugin.getDefault().getSearchPageDescriptors();
int accelerator= 1;
- for (Iterator<SearchPageDescriptor> iter= pageDescriptors.iterator(); iter.hasNext();) {
- SearchPageDescriptor desc= iter.next();
+ for (SearchPageDescriptor desc : pageDescriptors) {
if (!WorkbenchActivityHelper.filterItem(desc) && desc.isEnabled()) {
SearchPageAction action= new SearchPageAction(fWorkbenchWindow, desc);
addToMenu(localMenu, action, accelerator++);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
index bc8c9d7be..63686b457 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
@@ -126,8 +126,8 @@ public class ScopePart {
IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
if (lruWorkingSetNames != null) {
Set<IWorkingSet> existingWorkingSets= new HashSet<>(lruWorkingSetNames.length);
- for (int i= 0; i < lruWorkingSetNames.length; i++) {
- IWorkingSet workingSet= getWorkingSet(workingSetManager, lruWorkingSetNames[i]);
+ for (String lruWorkingSetName : lruWorkingSetNames) {
+ IWorkingSet workingSet= getWorkingSet(workingSetManager, lruWorkingSetName);
if (workingSet != null) {
existingWorkingSets.add(workingSet);
}
@@ -231,8 +231,8 @@ public class ScopePart {
setSelectedScope(ISearchPageContainer.WORKING_SET_SCOPE);
fWorkingSets= null;
Set<IWorkingSet> existingWorkingSets= new HashSet<>(workingSets.length);
- for (int i= 0; i < workingSets.length; i++) {
- String name= workingSets[i].getName();
+ for (IWorkingSet workingSet2 : workingSets) {
+ String name= workingSet2.getName();
IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name);
if (workingSet != null)
existingWorkingSets.add(workingSet);
@@ -417,8 +417,8 @@ public class ScopePart {
if (workingSets != null && workingSets.length > 0) {
Arrays.sort(workingSets, new WorkingSetComparator());
boolean firstFound= false;
- for (int i= 0; i < workingSets.length; i++) {
- String workingSetName= workingSets[i].getLabel();
+ for (IWorkingSet workingSet : workingSets) {
+ String workingSetName= workingSet.getLabel();
if (firstFound)
result= Messages.format(SearchMessages.ScopePart_workingSetConcatenation, new String[] { result, workingSetName });
else {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
index 3875d25ef..d0503cad2 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
@@ -107,8 +107,8 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
int x= 0;
int y= 0;
Control[] children= composite.getChildren();
- for (int i= 0; i < children.length; i++) {
- Point size= children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ for (Control element : children) {
+ Point size= element.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
x= Math.max(x, size.x);
y= Math.max(y, size.y);
}
@@ -128,8 +128,8 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
Rectangle rect= composite.getClientArea();
Control[] children= composite.getChildren();
- for (int i= 0; i < children.length; i++) {
- children[i].setBounds(rect);
+ for (Control element : children) {
+ element.setBounds(rect);
}
}
}
@@ -204,16 +204,15 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
IWorkingSet workingSet= (IWorkingSet) curr;
if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i= 0; i < projects.length; i++) {
- IProject proj= projects[i];
+ for (IProject proj : projects) {
if (proj.isOpen()) {
res.add(proj.getName());
}
}
} else {
IAdaptable[] elements= workingSet.getElements();
- for (int i= 0; i < elements.length; i++) {
- String name= evaluateEnclosingProject(elements[i]);
+ for (IAdaptable element : elements) {
+ String name= evaluateEnclosingProject(element);
if (name != null) {
res.add(name);
}
@@ -395,8 +394,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
private List<SearchPageDescriptor> filterByActivities(List<SearchPageDescriptor> input) {
ArrayList<SearchPageDescriptor> filteredList= new ArrayList<>(input.size());
- for (Iterator<SearchPageDescriptor> descriptors= input.iterator(); descriptors.hasNext();) {
- SearchPageDescriptor descriptor= descriptors.next();
+ for (SearchPageDescriptor descriptor : input) {
if (!WorkbenchActivityHelper.filterItem(descriptor))
filteredList.add(descriptor);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
index 0eb749fcc..35c7f62b9 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchManager.java
@@ -373,8 +373,8 @@ public class SearchManager implements IResourceChangeListener {
while (iter.hasNext())
iter.next().getControl().setRedraw(false);
- for (int i=0; i < markerDeltas.length; i++) {
- handleSearchMarkerChanged(markerDeltas[i]);
+ for (IMarkerDelta markerDelta : markerDeltas) {
+ handleSearchMarkerChanged(markerDelta);
}
iter= fListeners.iterator();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
index 3c59e8b5d..8716b9622 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java
@@ -233,9 +233,9 @@ class SearchPageDescriptor implements IPluginContribution, Comparable<SearchPage
static void setEnabled(Object[] enabledDescriptors) {
fgEnabledPageIds= new ArrayList<>(5);
- for (int i= 0; i < enabledDescriptors.length; i++) {
- if (enabledDescriptors[i] instanceof SearchPageDescriptor)
- fgEnabledPageIds.add(((SearchPageDescriptor)enabledDescriptors[i]).getId());
+ for (Object enabledDescriptor : enabledDescriptors) {
+ if (enabledDescriptor instanceof SearchPageDescriptor)
+ fgEnabledPageIds.add(((SearchPageDescriptor)enabledDescriptor).getId());
}
storeEnabledPageIds();
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
index 1d2766069..74e11066a 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPlugin.java
@@ -143,8 +143,8 @@ public class SearchPlugin extends AbstractUIPlugin {
shell= shell.getParent();
}
Shell shells[]= display.getShells();
- for (int i= 0; i < shells.length; i++) {
- Object data= shells[i].getData();
+ for (Shell shell2 : shells) {
+ Object data= shell2.getData();
if (data instanceof IWorkbenchWindow) {
windowRef.window= (IWorkbenchWindow)data;
return;
@@ -282,8 +282,7 @@ public class SearchPlugin extends AbstractUIPlugin {
*/
private List<SearchPageDescriptor> createSearchPageDescriptors(IConfigurationElement[] elements) {
List<SearchPageDescriptor> result= new ArrayList<>(5);
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
+ for (IConfigurationElement element : elements) {
if (SearchPageDescriptor.PAGE_TAG.equals(element.getName())) {
SearchPageDescriptor desc= new SearchPageDescriptor(element);
result.add(desc);
@@ -326,8 +325,7 @@ public class SearchPlugin extends AbstractUIPlugin {
*/
private List<SorterDescriptor> createSorterDescriptors(IConfigurationElement[] elements) {
List<SorterDescriptor> result= new ArrayList<>(5);
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
+ for (IConfigurationElement element : elements) {
if (SorterDescriptor.SORTER_TAG.equals(element.getName()))
result.add(new SorterDescriptor(element));
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
index 04dc29226..9df5c73ee 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
@@ -678,8 +678,7 @@ public class SearchResultViewer extends TableViewer {
Object[] changed= event.getElements();
if (changed != null && !fResourceToItemsMapper.isEmpty()) {
ArrayList<Object> others= new ArrayList<>(changed.length);
- for (int i= 0; i < changed.length; i++) {
- Object curr= changed[i];
+ for (Object curr : changed) {
if (curr instanceof IResource)
fResourceToItemsMapper.resourceChanged((IResource) curr);
else if (curr instanceof IAdaptable) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
index 1e497535b..d78545c22 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SelectAllAction.java
@@ -45,8 +45,7 @@ public class SelectAllAction extends Action {
}
private void collectExpandedAndVisible(TreeItem[] items, List<TreeItem> result) {
- for (int i= 0; i < items.length; i++) {
- TreeItem item= items[i];
+ for (TreeItem item : items) {
result.add(item);
if (item.getExpanded()) {
collectExpandedAndVisible(item.getItems(), result);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
index 0130c9cc7..30246108e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SortDropDownAction.java
@@ -190,9 +190,9 @@ class SortDropDownAction extends Action implements IMenuCreator {
if (memento == null)
return;
IMemento[] mementoElements= memento.getChildren(TAG_ELEMENT);
- for (int i= 0; i < mementoElements.length; i++) {
- String pageId= mementoElements[i].getString(TAG_PAGE_ID);
- String sorterId= mementoElements[i].getString(TAG_SORTER_ID);
+ for (IMemento mementoElement : mementoElements) {
+ String pageId= mementoElement.getString(TAG_PAGE_ID);
+ String sorterId= mementoElement.getString(TAG_SORTER_ID);
SorterDescriptor sorterDesc= getSorter(sorterId);
if (sorterDesc != null)
map.put(pageId, sorterDesc);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
index 4673b3eaa..96d561365 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
@@ -459,8 +459,8 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
@Override
protected void evaluateChangedElements(Match[] matches, Set<Object> changedElements) {
if (showLineMatches()) {
- for (int i = 0; i < matches.length; i++) {
- changedElements.add(((FileMatch) matches[i]).getLineElement());
+ for (Match match : matches) {
+ changedElements.add(((FileMatch) match).getLineElement());
}
} else {
super.evaluateChangedElements(matches, changedElements);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
index a42870ecd..01b194212 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
@@ -259,8 +259,8 @@ public class FileSearchQuery implements ISearchQuery {
String[] fileNamePatterns= fScope.getFileNamePatterns();
if (fileNamePatterns == null)
return true;
- for (int i= 0; i < fileNamePatterns.length; i++) {
- if ("*".equals(fileNamePatterns[i])) { //$NON-NLS-1$
+ for (String fileNamePattern : fileNamePatterns) {
+ if ("*".equals(fileNamePattern)) { //$NON-NLS-1$
return true;
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java
index 2f8121cca..06362f406 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTableContentProvider.java
@@ -59,16 +59,16 @@ public class FileTableContentProvider implements IStructuredContentProvider, IFi
TableViewer viewer= getViewer();
int elementLimit= getElementLimit();
boolean tableLimited= elementLimit != -1;
- for (int i= 0; i < updatedElements.length; i++) {
- if (fResult.getMatchCount(updatedElements[i]) > 0) {
- if (viewer.testFindItem(updatedElements[i]) != null)
- viewer.update(updatedElements[i], null);
+ for (Object updatedElement : updatedElements) {
+ if (fResult.getMatchCount(updatedElement) > 0) {
+ if (viewer.testFindItem(updatedElement) != null)
+ viewer.update(updatedElement, null);
else {
if (!tableLimited || viewer.getTable().getItemCount() < elementLimit)
- viewer.add(updatedElements[i]);
+ viewer.add(updatedElement);
}
} else
- viewer.remove(updatedElements[i]);
+ viewer.remove(updatedElement);
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
index b8c6b27de..f254c0b06 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java
@@ -78,14 +78,14 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
if (result != null) {
Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
+ for (Object element : elements) {
if (showLineMatches) {
- Match[] matches= result.getMatches(elements[i]);
- for (int j= 0; j < matches.length; j++) {
- insert(((FileMatch) matches[j]).getLineElement(), false);
+ Match[] matches= result.getMatches(element);
+ for (Match match : matches) {
+ insert(((FileMatch) match).getLineElement(), false);
}
} else {
- insert(elements[i], false);
+ insert(element, false);
}
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java
index cb9c0d2ff..60402ecf7 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/LineElement.java
@@ -64,8 +64,8 @@ public class LineElement {
public FileMatch[] getMatches(AbstractTextSearchResult result) {
ArrayList<FileMatch> res= new ArrayList<>();
Match[] matches= result.getMatches(fParent);
- for (int i= 0; i < matches.length; i++) {
- FileMatch curr= (FileMatch) matches[i];
+ for (Match match : matches) {
+ FileMatch curr= (FileMatch) match;
if (curr.getLineElement() == this) {
res.add(curr);
}
@@ -76,8 +76,8 @@ public class LineElement {
public int getNumberOfMatches(AbstractTextSearchResult result) {
int count= 0;
Match[] matches= result.getMatches(fParent);
- for (int i= 0; i < matches.length; i++) {
- FileMatch curr= (FileMatch) matches[i];
+ for (Match match : matches) {
+ FileMatch curr= (FileMatch) match;
if (curr.getLineElement() == this) {
count++;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
index 1e7697f10..6ae6d9da1 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
@@ -17,7 +17,6 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
@@ -126,8 +125,7 @@ public class ReplaceRefactoring extends Refactoring {
private Match[] getMatches() {
if (fMatches == null) {
ArrayList<FileMatch> matches= new ArrayList<>();
- for (int i= 0; i < fMatchGroups.length; i++) {
- MatchGroup curr= fMatchGroups[i];
+ for (MatchGroup curr : fMatchGroups) {
if (curr.group.isEnabled()) {
FileMatch match= curr.match;
matches.add(match);
@@ -211,13 +209,13 @@ public class ReplaceRefactoring extends Refactoring {
fMatches.clear();
if (fSelection != null) {
- for (int i= 0; i < fSelection.length; i++) {
- collectMatches(fSelection[i]);
+ for (Object element : fSelection) {
+ collectMatches(element);
}
} else {
Object[] elements= fResult.getElements();
- for (int i= 0; i < elements.length; i++) {
- collectMatches(elements[i]);
+ for (Object element : elements) {
+ collectMatches(element);
}
}
if (!hasMatches()) {
@@ -230,8 +228,7 @@ public class ReplaceRefactoring extends Refactoring {
if (object instanceof LineElement) {
LineElement lineElement= (LineElement) object;
FileMatch[] matches= lineElement.getMatches(fResult);
- for (int i= 0; i < matches.length; i++) {
- FileMatch fileMatch= matches[i];
+ for (FileMatch fileMatch : matches) {
if (isMatchToBeIncluded(fileMatch)) {
getBucket(fileMatch.getFile()).add(fileMatch);
}
@@ -239,15 +236,15 @@ public class ReplaceRefactoring extends Refactoring {
} else if (object instanceof IContainer) {
IContainer container= (IContainer) object;
IResource[] members= container.members();
- for (int i= 0; i < members.length; i++) {
- collectMatches(members[i]);
+ for (IResource member : members) {
+ collectMatches(member);
}
} else if (object instanceof IFile) {
Match[] matches= fResult.getMatches(object);
if (matches.length > 0) {
Collection<FileMatch> bucket= null;
- for (int i= 0; i < matches.length; i++) {
- FileMatch fileMatch= (FileMatch) matches[i];
+ for (Match match : matches) {
+ FileMatch fileMatch= (FileMatch) match;
if (isMatchToBeIncluded(fileMatch)) {
if (bucket == null) {
bucket= getBucket((IFile)object);
@@ -265,8 +262,7 @@ public class ReplaceRefactoring extends Refactoring {
public int getNumberOfMatches() {
int count= 0;
- for (Iterator<Set<FileMatch>> iterator= fMatches.values().iterator(); iterator.hasNext();) {
- Set<FileMatch> bucket= iterator.next();
+ for (Set<FileMatch> bucket : fMatches.values()) {
count += bucket.size();
}
return count;
@@ -290,8 +286,8 @@ public class ReplaceRefactoring extends Refactoring {
if (uri == null)
return true;
- for (Iterator<URI> iter= fAlreadyCollected.keySet().iterator(); iter.hasNext();) {
- if (URIUtil.equals(iter.next(), uri)) {
+ for (URI uri2 : fAlreadyCollected.keySet()) {
+ if (URIUtil.equals(uri2, uri)) {
if (file.equals(fAlreadyCollected.get(uri)))
return true; // another FileMatch for an IFile which already had matches
@@ -358,8 +354,7 @@ public class ReplaceRefactoring extends Refactoring {
ArrayList<MatchGroup> matchGroups= new ArrayList<>();
boolean hasChanges= false;
try {
- for (int i= 0; i < allFiles.length; i++) {
- IFile file= allFiles[i];
+ for (IFile file : allFiles) {
Set<FileMatch> bucket= fMatches.get(file);
if (!bucket.isEmpty()) {
try {
@@ -390,8 +385,7 @@ public class ReplaceRefactoring extends Refactoring {
private void checkFilesToBeChanged(IFile[] filesToBeChanged, RefactoringStatus resultingStatus) throws CoreException {
ArrayList<IFile> readOnly= new ArrayList<>();
- for (int i= 0; i < filesToBeChanged.length; i++) {
- IFile file= filesToBeChanged[i];
+ for (IFile file : filesToBeChanged) {
if (file.isReadOnly())
readOnly.add(file);
}
@@ -425,8 +419,7 @@ public class ReplaceRefactoring extends Refactoring {
IDocument document= textFileBuffer.getDocument();
String lineDelimiter= TextUtilities.getDefaultLineDelimiter(document);
- for (Iterator<FileMatch> iterator= matches.iterator(); iterator.hasNext();) {
- FileMatch match= iterator.next();
+ for (FileMatch match : matches) {
int offset= match.getOffset();
int length= match.getLength();
Position currentPosition= tracker.getCurrentPosition(match);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
index 4e7c49376..786d34a9e 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
@@ -349,8 +349,8 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived);
}
IAdaptable[] elements= workingSet.getElements();
- for (int i= 0; i < elements.length; i++) {
- IResource resource= elements[i].getAdapter(IResource.class);
+ for (IAdaptable element : elements) {
+ IResource resource= element.getAdapter(IResource.class);
if (resource != null && resource.isAccessible()) {
resources.add(resource);
}
@@ -390,8 +390,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private SearchPatternData findInPrevious(String pattern) {
- for (Iterator<SearchPatternData> iter= fPreviousSearchPatterns.iterator(); iter.hasNext();) {
- SearchPatternData element= iter.next();
+ for (SearchPatternData element : fPreviousSearchPatterns) {
if (pattern.equals(element.textPattern)) {
return element;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
index 70819f646..949193be2 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExtendedDialogWindow.java
@@ -14,7 +14,6 @@ package org.eclipse.search.internal.ui.util;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.SWT;
@@ -174,8 +173,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
* @param state The new state
*/
public void setPerformActionEnabled(boolean state) {
- for (Iterator<Button> buttons = fActionButtons.iterator(); buttons.hasNext(); ) {
- Button element = buttons.next();
+ for (Button element : fActionButtons) {
element.setEnabled(state);
}
}
@@ -271,16 +269,15 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
private void setDisplayCursor(Display d, Cursor c) {
Shell[] shells= d.getShells();
- for (int i= 0; i < shells.length; i++)
- shells[i].setCursor(c);
+ for (Shell shell2 : shells)
+ shell2.setCursor(c);
}
//---- UI state save and restoring ---------------------------------------------
private void restoreUIState(HashMap<Object, Object> state) {
restoreEnableState(fCancelButton, state);
- for (Iterator<Button> actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
- Button button = actionButtons.next();
+ for (Button button : fActionButtons) {
restoreEnableState(button, state);
}
ControlEnableState pageState= (ControlEnableState)state.get("tabForm"); //$NON-NLS-1$
@@ -301,8 +298,7 @@ public abstract class ExtendedDialogWindow extends TrayDialog implements IRunnab
private HashMap<Object, Object> saveUIState(boolean keepCancelEnabled) {
HashMap<Object, Object> savedState= new HashMap<>(10);
saveEnableStateAndSet(fCancelButton, savedState, keepCancelEnabled);
- for (Iterator<Button> actionButtons = fActionButtons.iterator(); actionButtons.hasNext(); ) {
- Button button = actionButtons.next();
+ for (Button button : fActionButtons) {
saveEnableStateAndSet(button, savedState, false);
}
savedState.put("tabForm", ControlEnableState.disable(fContents)); //$NON-NLS-1$
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
index 6556c413b..e3fe72525 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/FileTypeEditor.java
@@ -95,8 +95,8 @@ public class FileTypeEditor extends SelectionAdapter implements DisposeListener
Object[] result= dialog.getResult();
HashSet<String> patterns= new HashSet<>();
boolean starIncluded= false;
- for (int i= 0; i < result.length; i++) {
- String curr= result[i].toString();
+ for (Object element : result) {
+ String curr= element.toString();
if (curr.equals("*")) { //$NON-NLS-1$
starIncluded= true;
} else {

Back to the top