Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-05-26 13:58:04 -0400
committerAlexander Kurtakov2019-06-13 14:03:31 -0400
commit45c0a30d7027df909b78fa167cf3da83488581d9 (patch)
treed38f0754453da55322ea62a1c2b82dfdca2652ae
parent8816cdaddd2f38ac3be6e6a70a0e8a683c772d83 (diff)
downloadeclipse.platform.text-45c0a30d7027df909b78fa167cf3da83488581d9.tar.gz
eclipse.platform.text-45c0a30d7027df909b78fa167cf3da83488581d9.tar.xz
eclipse.platform.text-45c0a30d7027df909b78fa167cf3da83488581d9.zip
Use jdk 5 for-each loopI20190614-0330I20190613-1800
Replace simple uses of Iterator with a corresponding for-each loop. Also add missing braces on loops as necessary. Change-Id: Ibde37d56a7962f432ed771f4a215f5903161bde0 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java4
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java12
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java7
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java13
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java5
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java3
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java40
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java5
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java7
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java7
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java12
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java4
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java10
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java16
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java3
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java4
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java17
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java16
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java12
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java5
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java6
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java15
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java8
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java4
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java6
-rw-r--r--org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java15
-rw-r--r--org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java5
-rw-r--r--org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java3
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java19
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java39
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java13
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/CompositeRevertAction.java19
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java17
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java17
-rwxr-xr-xorg.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java22
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java17
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java16
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java3
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java28
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java5
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java8
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java41
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java8
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java3
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java15
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java5
-rw-r--r--org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/NatureLabelHoverProvider.java7
-rw-r--r--org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/CompoundEditExitStrategy.java5
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java7
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java18
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java12
-rwxr-xr-xorg.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnDescriptor.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java5
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java41
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java20
85 files changed, 431 insertions, 442 deletions
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java
index 0b8172d83..d3e8f62a9 100644
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java
+++ b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java
@@ -121,8 +121,8 @@ public abstract class AbstractFileBufferDocCreationTests {
private void assertParticipantsInvoked(String path, Class<?>[] expectedDSPsArray) {
LocationKind[] lks= getSupportLocationKinds();
- for(int i=0; i<lks.length; i++) {
- IDocument document= fManager.createEmptyDocument(new Path(path), lks[i]);
+ for (LocationKind lk : lks) {
+ IDocument document = fManager.createEmptyDocument(new Path(path), lk);
String content= document.get();
Set<String> expectedDSPs= new HashSet<>(Arrays.asList(toString(expectedDSPsArray)));
Set<String> actualDSPs= new HashSet<>(Arrays.asList(content.split("\n")));
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
index e823ba32d..7742571d6 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
@@ -176,9 +176,10 @@ public class GenericFileBufferOperationRunner {
private IFileBuffer[] findUnsynchronizedFileBuffers(IFileBuffer[] fileBuffers) {
ArrayList<IFileBuffer> list= new ArrayList<>();
- for (int i= 0; i < fileBuffers.length; i++) {
- if (!fileBuffers[i].isSynchronizationContextRequested())
- list.add(fileBuffers[i]);
+ for (IFileBuffer fileBuffer : fileBuffers) {
+ if (!fileBuffer.isSynchronizationContextRequested()) {
+ list.add(fileBuffer);
+ }
}
return list.toArray(new IFileBuffer[list.size()]);
}
@@ -231,9 +232,10 @@ public class GenericFileBufferOperationRunner {
}
private boolean isCommitable(IFileBuffer[] fileBuffers) {
- for (int i= 0; i < fileBuffers.length; i++) {
- if (!fileBuffers[i].isCommitable())
+ for (IFileBuffer fileBuffer : fileBuffers) {
+ if (!fileBuffer.isCommitable()) {
return false;
+ }
}
return true;
}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
index 086ca3a7f..bc141bc19 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
@@ -251,9 +251,10 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
private IFileBuffer[] findFileBuffersToValidate(IFileBuffer[] fileBuffers) {
ArrayList<IFileBuffer> list= new ArrayList<>();
- for (int i= 0; i < fileBuffers.length; i++) {
- if (!fileBuffers[i].isStateValidated())
- list.add(fileBuffers[i]);
+ for (IFileBuffer fileBuffer : fileBuffers) {
+ if (!fileBuffer.isStateValidated()) {
+ list.add(fileBuffer);
+ }
}
return list.toArray(new IFileBuffer[list.size()]);
}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
index f8c2518a9..7e71c22be 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
@@ -66,8 +66,9 @@ public class TextPresentationTest {
private void setUpTextPresentation() {
fTextPresentation= new TextPresentation();
fTextPresentation.setDefaultStyleRange(createStyleRange(0, 140, NORMAL));
- for (int i= 0; i < fAllRanges.length; i++)
- fTextPresentation.addStyleRange(fAllRanges[i]);
+ for (StyleRange fAllRange : fAllRanges) {
+ fTextPresentation.addStyleRange(fAllRange);
+ }
}
private StyleRange createStyleRange(int start, int end, int style) {
@@ -100,16 +101,16 @@ public class TextPresentationTest {
private void checkRegions(StyleRange[] expectedAllRanges, StyleRange[] expectedNonDefaultRanges) {
Iterator<StyleRange> e= fTextPresentation.getAllStyleRangeIterator();
- for (int i= 0; i < expectedAllRanges.length; i++) {
+ for (StyleRange expectedAllRange : expectedAllRanges) {
assertTrue(e.hasNext());
- assertEquals(expectedAllRanges[i], e.next());
+ assertEquals(expectedAllRange, e.next());
}
assertTrue(!e.hasNext());
e= fTextPresentation.getNonDefaultStyleRangeIterator();
- for (int i= 0; i < expectedNonDefaultRanges.length; i++) {
+ for (StyleRange expectedNonDefaultRange : expectedNonDefaultRanges) {
assertTrue(e.hasNext());
- assertEquals(expectedNonDefaultRanges[i], e.next());
+ assertEquals(expectedNonDefaultRange, e.next());
}
assertTrue(!e.hasNext());
}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
index 3c4717b43..422d2442b 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java
@@ -179,8 +179,9 @@ public class ProjectionAnnotationModel extends AnnotationModel {
try {
replaceAnnotations(deletions, additions, false);
if (modifications != null) {
- for (int i= 0; i < modifications.length; i++)
- modifyAnnotation(modifications[i], false);
+ for (Annotation modification : modifications) {
+ modifyAnnotation(modification, false);
+ }
}
} catch (BadLocationException x) {
}
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
index 2d11988e9..15bdd8ac9 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
@@ -290,8 +290,7 @@ class ProjectionSummary {
}
private boolean includes(IRegion[] regions, Position position) {
- for (int i= 0; i < regions.length; i++) {
- IRegion region= regions[i];
+ for (IRegion region : regions) {
if (position != null && !position.isDeleted()
&& region.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength())
return true;
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
index 8babac849..403af6398 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
@@ -823,11 +823,13 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
// collapse contained regions
ProjectionAnnotation[] collapsed= computeCollapsedNestedAnnotations(offset, length);
if (collapsed != null) {
- for (int i= 0; i < collapsed.length; i++) {
- IRegion[] regions= computeCollapsedRegions(fProjectionAnnotationModel.getPosition(collapsed[i]));
- if (regions != null)
- for (int j= 0; j < regions.length; j++)
- removeMasterDocumentRange(projection, regions[j].getOffset(), regions[j].getLength());
+ for (ProjectionAnnotation c : collapsed) {
+ IRegion[] regions = computeCollapsedRegions(fProjectionAnnotationModel.getPosition(c));
+ if (regions != null) {
+ for (IRegion region : regions) {
+ removeMasterDocumentRange(projection, region.getOffset(), region.getLength());
+ }
+ }
}
}
@@ -1047,8 +1049,8 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
* We pass the removed annotation into this method for performance reasons only. Otherwise, they could be fetch from the event.
*/
private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, boolean fireRedraw) throws BadLocationException {
- for (int i= 0; i < removedAnnotations.length; i++) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) removedAnnotations[i];
+ for (Annotation removedAnnotation : removedAnnotations) {
+ ProjectionAnnotation annotation = (ProjectionAnnotation) removedAnnotation;
if (annotation.isCollapsed()) {
Position expanded= event.getPositionOfRemovedAnnotation(annotation);
expand(expanded.getOffset(), expanded.getLength(), fireRedraw);
@@ -1141,8 +1143,8 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
}
private void processChanges(Annotation[] annotations, boolean fireRedraw, List<Position> coverage) throws BadLocationException {
- for (int i= 0; i < annotations.length; i++) {
- ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i];
+ for (Annotation a : annotations) {
+ ProjectionAnnotation annotation = (ProjectionAnnotation) a;
Position position= fProjectionAnnotationModel.getPosition(annotation);
if (position == null)
@@ -1152,9 +1154,11 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
if (annotation.isCollapsed()) {
coverage.add(position);
IRegion[] regions= computeCollapsedRegions(position);
- if (regions != null)
- for (int j= 0; j < regions.length; j++)
- collapse(regions[j].getOffset(), regions[j].getLength(), fireRedraw);
+ if (regions != null) {
+ for (IRegion region : regions) {
+ collapse(region.getOffset(), region.getLength(), fireRedraw);
+ }
+ }
} else {
expand(position.getOffset(), position.getLength(), fireRedraw);
}
@@ -1203,8 +1207,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
if (position != null) {
IRegion[] regions= computeCollapsedRegions(position);
if (regions != null)
- for (int i= 0; i < regions.length; i++)
- removeMasterDocumentRange(projection, regions[i].getOffset(), regions[i].getLength());
+ for (IRegion region : regions) {
+ removeMasterDocumentRange(projection, region.getOffset(), region.getLength());
+ }
}
}
}
@@ -1615,12 +1620,11 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
int widgetSelectionExclusiveEnd= widgetSelection.x + widgetSelection.y;
Position[] annotationPositions= computeOverlappingAnnotationPositions(modelSelection);
- for (int i= 0; i < annotationPositions.length; i++) {
- IRegion[] regions= computeCollapsedRegions(annotationPositions[i]);
+ for (Position annotationPosition : annotationPositions) {
+ IRegion[] regions = computeCollapsedRegions(annotationPosition);
if (regions == null)
continue;
- for (int j= 0; j < regions.length; j++) {
- IRegion modelRange= regions[j];
+ for (IRegion modelRange : regions) {
IRegion widgetRange= modelRange2ClosestWidgetRange(modelRange);
// only take collapsed ranges, i.e. widget length is 0
if (widgetRange != null && widgetRange.getLength() == 0) {
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java
index 06a768f58..dbd758413 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java
@@ -165,8 +165,9 @@ class SourceViewerInformationControl implements IInformationControl, IInformatio
fStatusField.setText(statusFieldText);
Font font= fStatusField.getFont();
FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
+ for (FontData fontData : fontDatas) {
+ fontData.setHeight(fontData.getHeight() * 9 / 10);
+ }
fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
fStatusField.setFont(fStatusTextFont);
GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index 38c6be651..302648441 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -613,10 +613,11 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
@Override
public void verifyKey(VerifyEvent e) {
IContentAssistListener2[] listeners= fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- if (!listeners[i].verifyKey(e) || !e.doit)
+ for (IContentAssistListener2 listener : listeners) {
+ if (listener != null) {
+ if (!listener.verifyKey(e) || !e.doit) {
return;
+ }
}
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index a301bbd81..1d707db84 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -804,10 +804,11 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
@Override
public void verifyKey(VerifyEvent e) {
IContentAssistListener[] listeners= fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- if (!listeners[i].verifyKey(e) || !e.doit)
+ for (IContentAssistListener listener : listeners) {
+ if (listener != null) {
+ if (!listener.verifyKey(e) || !e.doit) {
break;
+ }
}
}
if (fAutoAssistListener != null)
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
index 39e0e6736..46f9e15c5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
@@ -1126,15 +1126,13 @@ public class LinkedModeUI {
viewer.removeTextInputListener(fCloser);
}
- for (int i= 0; i < fTargets.length; i++) {
-
- if (fTargets[i].fAnnotationModel != null) {
- fTargets[i].fAnnotationModel.removeAllAnnotations();
- fTargets[i].fAnnotationModel.disconnect(fTargets[i].getViewer().getDocument());
- fTargets[i].fAnnotationModel= null;
+ for (LinkedModeUITarget fTarget : fTargets) {
+ if (fTarget.fAnnotationModel != null) {
+ fTarget.fAnnotationModel.removeAllAnnotations();
+ fTarget.fAnnotationModel.disconnect(fTarget.getViewer().getDocument());
+ fTarget.fAnnotationModel = null;
}
-
- uninstallAnnotationModel(fTargets[i]);
+ uninstallAnnotationModel(fTarget);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
index 29886829d..0ac7a8364 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
@@ -275,9 +275,10 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
private void addListener(Class<? extends EventListener> clazz, EventListener listener) {
Control[] children= getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] != null && !children[i].isDisposed())
- addListener(clazz, children[i], listener);
+ for (Control c : children) {
+ if (c != null && !c.isDisposed()) {
+ addListener(clazz, c, listener);
+ }
}
ListenerInfo info= new ListenerInfo();
@@ -309,9 +310,10 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
}
}
- for (int i= 0; i < children.length; i++) {
- if (children[i] != null && !children[i].isDisposed())
- removeListener(clazz, children[i], listener);
+ for (Control c : children) {
+ if (c != null && !c.isDisposed()) {
+ removeListener(clazz, c, listener);
+ }
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java
index 41337d81d..cce89f885 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java
@@ -376,8 +376,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar
}
while ((pos1 >= lowerBoundary && !lowerFound) || (pos2 < upperBoundary && !upperFound)) {
- for (int i= 0; i < counts.length; i++) {
- counts[i][0]= counts[i][1]= 0;
+ for (int[] count : counts) {
+ count[0] = count[1] = 0;
}
outer1: while (pos1 >= lowerBoundary && !lowerFound) {
@@ -389,8 +389,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar
} else {
counts[i / 2][0]++; //end
}
- for (int j= 0; j < counts.length; j++) {
- if (counts[j][0] == -1) {
+ for (int[] count : counts) {
+ if (count[0] == -1) {
lowerFound= true;
break outer1;
}
@@ -408,8 +408,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar
} else {
counts[i / 2][1]--; //end
}
- for (int j= 0; j < counts.length; j++) {
- if (counts[j][1] == -1 && counts[j][0] == -1) {
+ for (int[] count : counts) {
+ if (count[1] == -1 && count[0] == -1) {
upperFound= true;
break outer2;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java
index cc897c554..c74ff5ea9 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java
@@ -634,8 +634,8 @@ public class InlinedAnnotationSupport {
*/
FontData[] getFontData(int style) {
FontData[] fontDatas= regularFont.getFontData();
- for (int i= 0; i < fontDatas.length; i++) {
- fontDatas[i].setStyle(style);
+ for (FontData fontData : fontDatas) {
+ fontData.setStyle(style);
}
return fontDatas;
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
index 5a30dad4b..e3462a9ab 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
@@ -32,9 +32,10 @@ public class QueryManagerTest {
InternalSearchUI.getInstance().addQuery(query);
InternalSearchUI.getInstance().removeQuery(query);
ISearchQuery[] all= InternalSearchUI.getInstance().getQueries();
- for (int i= 0; i < all.length; i++) {
- if (query == all[i])
+ for (ISearchQuery a : all) {
+ if (query == a) {
assertTrue(false);
+ }
}
}
@@ -43,9 +44,10 @@ public class QueryManagerTest {
ISearchQuery query= new NullQuery();
InternalSearchUI.getInstance().addQuery(query);
ISearchQuery[] all= NewSearchUI.getQueries();
- for (int i= 0; i < all.length; i++) {
- if (query == all[i])
+ for (ISearchQuery a : all) {
+ if (query == a) {
return;
+ }
}
assertTrue(false);
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
index 568f52df9..0cad8d1f5 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
@@ -85,8 +85,8 @@ public class AnnotationManagerTest {
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
Object[] files= result.getElements();
try {
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile)files[i];
+ for (Object f : files) {
+ IFile file = (IFile) f;
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
annotationModel.getAnnotationIterator();
@@ -128,8 +128,8 @@ public class AnnotationManagerTest {
InternalSearchUI.getInstance().removeQuery(fQuery1);
try {
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile)files[i];
+ for (Object f : files) {
+ IFile file = (IFile) f;
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
@@ -153,8 +153,8 @@ public class AnnotationManagerTest {
Object[] files= result.getElements();
NewSearchUI.runQueryInForeground(null, fQuery2);
try {
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile)files[i];
+ for (Object f : files) {
+ IFile file = (IFile) f;
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
@@ -182,8 +182,8 @@ public class AnnotationManagerTest {
NewSearchUI.runQueryInForeground(null, fQuery2);
SearchTestPlugin.getDefault().getSearchView().showSearchResult(result);
try {
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile)files[i];
+ for (Object f : files) {
+ IFile file = (IFile) f;
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
index 047a0dce4..887affd31 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
@@ -516,8 +516,7 @@ public class FileSearchTests {
private void assertMatches(TestResult[] results, int expectedCount, IFile file, String fileContent, String string) {
int k= 0;
- for (int i= 0; i < results.length; i++) {
- TestResult curr= results[i];
+ for (TestResult curr : results) {
if (file.equals(curr.resource)) {
k++;
assertEquals("Wrong positions", string, fileContent.substring(curr.offset, curr.offset + curr.length));
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
index 0cfcfb16d..62f728658 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
@@ -81,8 +81,8 @@ public class LineAnnotationManagerTest {
AbstractTextSearchResult result= (AbstractTextSearchResult) fLineQuery.getSearchResult();
Object[] files= result.getElements();
try {
- for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
+ for (Object f : files) {
+ IFile file= (IFile) f;
ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
index a3ee6addb..65fd8ebf0 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
@@ -64,8 +64,8 @@ public class PositionTrackerTest {
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
Object[] elements= result.getElements();
try {
- for (int i = 0; i < elements.length; i++) {
- checkInsertAtZero(result, (IFile) elements[i]);
+ for (Object element : elements) {
+ checkInsertAtZero(result, (IFile) element);
}
} finally {
SearchPlugin.getActivePage().closeAllEditors(false);
@@ -78,8 +78,8 @@ public class PositionTrackerTest {
FileSearchResult result= (FileSearchResult) fQuery1.getSearchResult();
Object[] elements= result.getElements();
try {
- for (int i = 0; i < elements.length; i++) {
- checkInsertInsideMatch(result, (IFile) elements[i]);
+ for (Object element : elements) {
+ checkInsertInsideMatch(result, (IFile) element);
}
} finally {
SearchPlugin.getActivePage().closeAllEditors(false);
@@ -94,14 +94,13 @@ public class PositionTrackerTest {
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
- for (int i= 0; i < matches.length; i++) {
- Position currentPosition= InternalSearchUI.getInstance().getPositionTracker().getCurrentPosition(matches[i]);
+ for (Match matche : matches) {
+ Position currentPosition = InternalSearchUI.getInstance().getPositionTracker().getCurrentPosition(matche);
assertNotNull(currentPosition);
doc.replace(currentPosition.offset + 1, 0, "Test");
}
-
- for (int i= 0; i < matches.length; i++) {
- Position currentPosition= InternalSearchUI.getInstance().getPositionTracker().getCurrentPosition(matches[i]);
+ for (Match matche : matches) {
+ Position currentPosition = InternalSearchUI.getInstance().getPositionTracker().getCurrentPosition(matche);
assertNotNull(currentPosition);
String text= doc.get(currentPosition.offset, currentPosition.length);
StringBuilder buf= new StringBuilder();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
index ecf0290a1..feda1f397 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
@@ -78,9 +78,9 @@ public class SearchResultPageTest {
if (viewer instanceof AbstractTreeViewer)
((AbstractTreeViewer)viewer).expandAll();
Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
+ for (Object element : elements) {
// make sure all elements in the test result are present in the viewer and have the proper count displayed
- checkElementDisplay(viewer, result, elements[i]);
+ checkElementDisplay(viewer, result, element);
}
}
@@ -98,12 +98,12 @@ public class SearchResultPageTest {
viewer.expandAll();
Object[] elements= result.getElements();
//page.setUpdateTracing(true);
- for (int i= 0; i < elements.length; i++) {
- Match[] matches= result.getMatches(elements[i]);
- viewer.reveal(elements[i]);
- for (int j= 0; j < matches.length; j++) {
- checkElementDisplay(viewer, result, elements[i]);
- result.removeMatch(matches[j]);
+ for (Object element : elements) {
+ Match[] matches = result.getMatches(element);
+ viewer.reveal(element);
+ for (Match matche : matches) {
+ checkElementDisplay(viewer, result, element);
+ result.removeMatch(matche);
consumeEvents(page);
}
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
index d18b70f80..ca15cbd9e 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
@@ -53,10 +53,10 @@ public class SortingTest {
// first, collect all matches
Object[] elements= result.getElements();
- for (int i= 0; i < elements.length; i++) {
- Match[] matches= result.getMatches(elements[i]);
- for (int j= 0; j < matches.length; j++) {
- allMatches.add(matches[j]);
+ for (Object element : elements) {
+ Match[] matches = result.getMatches(element);
+ for (Match matche : matches) {
+ allMatches.add(matche);
}
}
// now remove them and readd them in reverse order
@@ -70,8 +70,8 @@ public class SortingTest {
assertEquals("Test that all matches have been added again", result.getMatchCount(), originalMatchCount);
// now check that they're ordered by position.
- for (int i= 0; i < elements.length; i++) {
- Match[] matches= result.getMatches(elements[i]);
+ for (Object element : elements) {
+ Match[] matches = result.getMatches(element);
assertTrue("has matches", matches.length > 0);
for (int j= 1; j < matches.length; j++) {
assertTrue("order problem", isLessOrEqual(matches[j-1], matches[j]));
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 a3f53b0e7..d3a7cd1dc 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
@@ -1099,9 +1099,10 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
int count= 0;
Match[] matches= result.getMatches(element);
- for (int i= 0; i < matches.length; i++) {
- if (!matches[i].isFiltered())
+ for (Match match : matches) {
+ if (!match.isFiltered()) {
count++;
+ }
}
return count;
}
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 008561942..9b7ed4466 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
@@ -50,9 +50,9 @@ public class MatchFilterAction extends Action implements IUpdate {
return;
}
- for (int i= 0; i < activeMatchFilters.length; i++) {
- if (!activeMatchFilters[i].equals(fFilter)) {
- newFilters.add(activeMatchFilters[i]);
+ for (MatchFilter activeMatchFilter : activeMatchFilters) {
+ if (!activeMatchFilter.equals(fFilter)) {
+ newFilters.add(activeMatchFilter);
}
}
boolean newState= isChecked();
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
index d2588397a..4869e854c 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java
@@ -29,9 +29,10 @@ class RemoveAllSearchesAction extends Action {
@Override
public void run() {
ISearchQuery[] queries= NewSearchUI.getQueries();
- for (int i = 0; i < queries.length; i++) {
- if (!NewSearchUI.isQueryRunning(queries[i]))
- InternalSearchUI.getInstance().removeQuery(queries[i]);
+ for (ISearchQuery querie : queries) {
+ if (!NewSearchUI.isQueryRunning(querie)) {
+ InternalSearchUI.getInstance().removeQuery(querie);
+ }
}
}
}
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 363a0485d..e38f226d7 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
@@ -194,16 +194,17 @@ public class FileTreeContentProvider implements ITreeContentProvider, IFileSearc
@Override
public synchronized void elementsChanged(Object[] updatedElements) {
- for (int i= 0; i < updatedElements.length; i++) {
- if (!(updatedElements[i] instanceof LineElement)) {
+ for (Object updatedElement : updatedElements) {
+ if (!(updatedElement instanceof LineElement)) {
// change events to elements are reported in file search
- if (fResult.getMatchCount(updatedElements[i]) > 0)
- insert(updatedElements[i], true);
- else
- remove(updatedElements[i], true);
+ if (fResult.getMatchCount(updatedElement) > 0) {
+ insert(updatedElement, true);
+ } else {
+ remove(updatedElement, true);
+ }
} else {
// change events to line elements are reported in text search
- LineElement lineElement= (LineElement) updatedElements[i];
+ LineElement lineElement = (LineElement) updatedElement;
int nMatches= lineElement.getNumberOfMatches(fResult);
if (nMatches > 0) {
if (hasChild(lineElement.getParent(), lineElement)) {
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java
index 02fdf396b..cf68998fd 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java
@@ -136,12 +136,12 @@ public class AnnotationModelExtension2Test {
private void assertEquals(Annotation[] expected, Annotation[] actual, IAnnotationModel insideModel, IAnnotationModel beforeModel, IAnnotationModel afterModel) {
HashSet<Annotation> expectedSet= new HashSet<>(Arrays.asList(expected));
- for (int i= 0; i < actual.length; i++) {
- if (!expectedSet.contains(actual[i])) {
- String message= "Unexpected annotation " + getName(actual[i]) + " in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
+ for (Annotation a : actual) {
+ if (!expectedSet.contains(a)) {
+ String message = "Unexpected annotation " + getName(a) + " in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
assertTrue(message, false);
}
- expectedSet.remove(actual[i]);
+ expectedSet.remove(a);
}
if (!expectedSet.isEmpty()) {
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
index c34eb9e8e..575649876 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
@@ -319,8 +319,8 @@ public class TextEditTests {
private static void flatten(List<TextEdit> result, TextEdit edit) {
result.add(edit);
TextEdit[] children= edit.getChildren();
- for (int i= 0; i < children.length; i++) {
- flatten(result, children[i]);
+ for (TextEdit c : children) {
+ flatten(result, c);
}
}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java
index 462ac90ee..ddec67907 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java
@@ -556,8 +556,7 @@ public class LinkedModeModelTest {
private void assertEquals(LinkedPositionGroup group, String expected) throws BadLocationException {
LinkedPosition[] positions= group.getPositions();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition pos= positions[i];
+ for (LinkedPosition pos : positions) {
if (!pos.isDeleted())
Assert.assertEquals(expected, pos.getContent());
}
@@ -647,8 +646,7 @@ public class LinkedModeModelTest {
}
private IDocument getOriginal(IDocument doc) {
- for (Iterator<IDocument[]> it = fDocumentMap.iterator(); it.hasNext(); ) {
- IDocument[] docs = it.next();
+ for (IDocument[] docs : fDocumentMap) {
if (docs[0] == doc)
return docs[1];
}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
index 9e32b0e70..547c59b87 100644
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
+++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionDocument.java
@@ -233,8 +233,8 @@ public class ProjectionDocument extends AbstractDocument {
int offset= 0;
Position[] fragments= getFragments();
- for (int i= 0; i < fragments.length; i++) {
- Fragment fragment= (Fragment) fragments[i];
+ for (Position f : fragments) {
+ Fragment fragment = (Fragment) f;
Segment segment= new Segment(offset, fragment.getLength());
segment.fragment= fragment;
addPosition(fSegmentsCategory, segment);
@@ -369,8 +369,8 @@ public class ProjectionDocument extends AbstractDocument {
*/
private Fragment findFragment(int offsetInMaster, int lengthInMaster) {
Position[] fragments= getFragments();
- for (int i= 0; i < fragments.length; i++) {
- Fragment f= (Fragment) fragments[i];
+ for (Position fragment : fragments) {
+ Fragment f = (Fragment) fragment;
if (f.getOffset() <= offsetInMaster && offsetInMaster + lengthInMaster <= f.getOffset() + f.getLength())
return f;
}
@@ -589,8 +589,7 @@ public class ProjectionDocument extends AbstractDocument {
if (fragments == null || fragments.length == 0)
return;
- for (int i= 0; i < fragments.length; i++) {
- IRegion fragment= fragments[i];
+ for (IRegion fragment : fragments) {
internalRemoveMasterDocumentRange(fragment.getOffset(), fragment.getLength());
}
}
@@ -870,8 +869,8 @@ public class ProjectionDocument extends AbstractDocument {
super.fireDocumentAboutToBeChanged(event);
Position[] fragments= getFragments();
- for (int i= 0; i < fragments.length; i++) {
- Fragment fragment= (Fragment) fragments[i];
+ for (Position fragment1 : fragments) {
+ Fragment fragment = (Fragment) fragment1;
fMasterDocument.removePosition(fFragmentsCategory, fragment);
removePosition(fSegmentsCategory, fragment.segment);
}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java
index 74d8d50fc..1c02f7f4b 100644
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java
+++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionMapping.java
@@ -548,8 +548,9 @@ public class ProjectionMapping implements IDocumentInformationMapping , IDocumen
public int getImageLength() {
Position[] segments= getSegments();
int length= 0;
- for (int i= 0; i < segments.length; i++)
- length += segments[i].length;
+ for (Position segment : segments) {
+ length += segment.length;
+ }
return length;
}
diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java
index e05f26d81..b035a9908 100644
--- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java
+++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java
@@ -132,8 +132,7 @@ class ProjectionTextStore implements ITextStore {
try {
IRegion[] fragments= fMapping.toExactOriginRegions(new Region(offset, length));
StringBuilder buffer= new StringBuilder();
- for (int i= 0; i < fragments.length; i++) {
- IRegion fragment= fragments[i];
+ for (IRegion fragment : fragments) {
buffer.append(fMasterDocument.get(fragment.getOffset(), fragment.getLength()));
}
return buffer.toString();
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java
index 9fa29aa01..8832678dd 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java
@@ -77,9 +77,10 @@ public class MarkerAnnotationOrderTest {
// remove the marker updater extension point
IExtensionRegistry registry= Platform.getExtensionRegistry();
IExtension[] extensions = registry.getExtensions(pointContributor);
- for (int i= 0; i < extensions.length; i++) {
- if ("org.eclipse.ui.editors.markerUpdaters".equals(extensions[i].getExtensionPointUniqueIdentifier()))
- registry.removeExtension(extensions[i], masterToken);
+ for (IExtension extension : extensions) {
+ if ("org.eclipse.ui.editors.markerUpdaters".equals(extension.getExtensionPointUniqueIdentifier())) {
+ registry.removeExtension(extension, masterToken);
+ }
}
TestUtil.cleanUp();
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
index 965acf016..79ff07064 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
@@ -411,11 +411,11 @@ public class EncodingActionGroup extends ActionGroup {
editor.setAction(IEncodingActionsConstants.SYSTEM, a);
}
- for (int i= 0; i < ENCODINGS.length; i++) {
- a= new PredefinedEncodingAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ConvertEncoding." + ENCODINGS[i][0] + ".", ENCODINGS[i][0], editor); //$NON-NLS-1$ //$NON-NLS-2$
- a.setHelpContextId( ENCODINGS[i][1]);
- a.setActionDefinitionId( ENCODINGS[i][2]);
- editor.setAction(ENCODINGS[i][0], a);
+ for (String[] e : ENCODINGS) {
+ a = new PredefinedEncodingAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ConvertEncoding." + e[0] + ".", e[0], editor); //$NON-NLS-1$ //$NON-NLS-2$
+ a.setHelpContextId(e[1]);
+ a.setActionDefinitionId(e[2]);
+ editor.setAction(e[0], a);
}
a= new CustomEncodingAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ConvertEncoding." + IEncodingActionsConstants.CUSTOM + ".", editor); //$NON-NLS-1$ //$NON-NLS-2$
@@ -435,8 +435,8 @@ public class EncodingActionGroup extends ActionGroup {
if (a instanceof IUpdate)
((IUpdate) a).update();
- for (int i= 0; i < ENCODINGS.length; i++) {
- a= fTextEditor.getAction(ENCODINGS[i][0]);
+ for (String[] e : ENCODINGS) {
+ a = fTextEditor.getAction(e[0]);
if (a instanceof IUpdate)
((IUpdate) a).update();
}
@@ -450,8 +450,9 @@ public class EncodingActionGroup extends ActionGroup {
public void dispose() {
if (fTextEditor != null) {
fTextEditor.setAction(IEncodingActionsConstants.SYSTEM, null);
- for (int i= 0; i < ENCODINGS.length; i++)
- fTextEditor.setAction(ENCODINGS[i][0], null);
+ for (String[] e : ENCODINGS) {
+ fTextEditor.setAction(e[0], null);
+ }
fTextEditor.setAction(IEncodingActionsConstants.CUSTOM, null);
fTextEditor= null;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java
index 8789be2cb..c2798ab34 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java
@@ -158,8 +158,7 @@ public class FileBufferOperationAction extends Action implements IWorkbenchWindo
*/
protected IFile[] collectFiles(IResource[] resources) {
Set<IResource> files= new HashSet<>();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if ((IResource.FILE & resource.getType()) > 0)
files.add(resource);
}
@@ -206,8 +205,8 @@ public class FileBufferOperationAction extends Action implements IWorkbenchWindo
progressMonitor.beginTask(TextEditorMessages.FileBufferOperationAction_collectionFiles_label, files.length);
try {
Set<IPath> locations= new HashSet<>();
- for (int i= 0; i < files.length; i++) {
- IPath fullPath= files[i].getFullPath();
+ for (IFile file : files) {
+ IPath fullPath = file.getFullPath();
if (isAcceptableLocation(fullPath))
locations.add(fullPath);
progressMonitor.worked(1);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java
index d05ae47bd..b092b806f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationHandler.java
@@ -174,8 +174,7 @@ public class FileBufferOperationHandler extends AbstractHandler {
*/
protected IFile[] collectFiles(IResource[] resources) {
Set<IResource> files= new HashSet<>();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if ((IResource.FILE & resource.getType()) > 0)
files.add(resource);
}
@@ -246,8 +245,8 @@ public class FileBufferOperationHandler extends AbstractHandler {
progressMonitor.beginTask(TextEditorMessages.FileBufferOperationHandler_collectionFiles_label, files.length);
try {
Set<IPath> locations= new HashSet<>();
- for (int i= 0; i < files.length; i++) {
- IPath fullPath= files[i].getFullPath();
+ for (IFile file : files) {
+ IPath fullPath = file.getFullPath();
if (isAcceptableLocation(fullPath))
locations.add(fullPath);
progressMonitor.worked(1);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
index ac9309a95..4c2ac4fe7 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
@@ -90,14 +90,15 @@ public class ContributionContextTypeRegistry extends ContextTypeRegistry {
IConfigurationElement[] extensions= getTemplateExtensions();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(REGISTRY)) {
- String id= extensions[i].getAttribute(ID);
+ for (IConfigurationElement extension : extensions) {
+ if (extension.getName().equals(REGISTRY)) {
+ String id = extension.getAttribute(ID);
if (registryId.equals(id)) {
- for (int j= 0; j < extensions.length; j++) {
- if (extensions[j].getName().equals(CONTEXT_TYPE)) {
- if (registryId.equals(extensions[j].getAttribute(REGISTRY_ID)))
- addContextType(extensions[j].getAttribute(ID));
+ for (IConfigurationElement extension2 : extensions) {
+ if (extension2.getName().equals(CONTEXT_TYPE)) {
+ if (registryId.equals(extension2.getAttribute(REGISTRY_ID))) {
+ addContextType(extension2.getAttribute(ID));
+ }
}
}
return;
@@ -150,8 +151,9 @@ public class ContributionContextTypeRegistry extends ContextTypeRegistry {
type= createContextType(extensions, id);
if (type != null) {
TemplateVariableResolver[] resolvers= createResolvers(extensions, id);
- for (int i= 0; i < resolvers.length; i++)
- type.addResolver(resolvers[i]);
+ for (TemplateVariableResolver resolver : resolvers) {
+ type.addResolver(resolver);
+ }
}
} catch (CoreException e) {
EditorsPlugin.log(e);
@@ -162,12 +164,13 @@ public class ContributionContextTypeRegistry extends ContextTypeRegistry {
}
private static TemplateContextType createContextType(IConfigurationElement[] extensions, String contextTypeId) throws CoreException {
- for (int i= 0; i < extensions.length; i++) {
+ for (IConfigurationElement extension : extensions) {
// TODO create half-order over contributions
- if (extensions[i].getName().equals(CONTEXT_TYPE)) {
- String id= extensions[i].getAttribute(ID);
- if (contextTypeId.equals(id))
- return createContextType(extensions[i]);
+ if (extension.getName().equals(CONTEXT_TYPE)) {
+ String id = extension.getAttribute(ID);
+ if (contextTypeId.equals(id)) {
+ return createContextType(extension);
+ }
}
}
@@ -186,12 +189,12 @@ public class ContributionContextTypeRegistry extends ContextTypeRegistry {
*/
private static TemplateVariableResolver[] createResolvers(IConfigurationElement[] extensions, String contextTypeId) {
List<TemplateVariableResolver> resolvers= new ArrayList<>();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(RESOLVER)) {
- String declaredId= extensions[i].getAttribute(CONTEXT_TYPE_ID);
+ for (IConfigurationElement extension : extensions) {
+ if (extension.getName().equals(RESOLVER)) {
+ String declaredId = extension.getAttribute(CONTEXT_TYPE_ID);
if (contextTypeId.equals(declaredId)) {
try {
- TemplateVariableResolver resolver= createResolver(extensions[i]);
+ TemplateVariableResolver resolver = createResolver(extension);
if (resolver != null)
resolvers.add(resolver);
} catch (CoreException e) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
index ba64a531f..5b81e1d31 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
@@ -118,11 +118,11 @@ public class ContributionTemplateStore extends TemplateStore {
private Collection<TemplatePersistenceData> readContributedTemplates(IConfigurationElement[] extensions) throws IOException {
Collection<TemplatePersistenceData> templates= new ArrayList<>();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(TEMPLATE))
- createTemplate(templates, extensions[i]);
- else if (extensions[i].getName().equals(INCLUDE)) {
- readIncludedTemplates(templates, extensions[i]);
+ for (IConfigurationElement extension : extensions) {
+ if (extension.getName().equals(TEMPLATE)) {
+ createTemplate(templates, extension);
+ } else if (extension.getName().equals(INCLUDE)) {
+ readIncludedTemplates(templates, extension);
}
}
@@ -149,8 +149,7 @@ public class ContributionTemplateStore extends TemplateStore {
try (InputStream stream= new BufferedInputStream(url.openStream())) {
TemplateReaderWriter reader= new TemplateReaderWriter();
TemplatePersistenceData[] datas= reader.read(stream, bundle);
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
+ for (TemplatePersistenceData data : datas) {
if (data.isCustom()) {
if (data.getId() == null)
EditorsPlugin.logErrorMessage(NLSUtility.format(ContributionTemplateMessages.ContributionTemplateStore_ignore_no_id, data.getTemplate().getName()));
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/CompositeRevertAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/CompositeRevertAction.java
index 2c62bc841..3362d46a2 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/CompositeRevertAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/CompositeRevertAction.java
@@ -47,8 +47,9 @@ public final class CompositeRevertAction extends Action implements IUpdate, ISel
*/
public CompositeRevertAction(ITextEditor editor, IAction[] actions) {
fActions= new IAction[actions.length];
- for (int i= 0; i < actions.length; i++)
- Assert.isNotNull(actions[i]);
+ for (IAction action : actions) {
+ Assert.isNotNull(action);
+ }
System.arraycopy(actions, 0, fActions, 0, actions.length);
@@ -61,9 +62,10 @@ public final class CompositeRevertAction extends Action implements IUpdate, ISel
@Override
public void update() {
- for (int i= 0; i < fActions.length; i++) {
- if (fActions[i] instanceof IUpdate)
- ((IUpdate) fActions[i]).update();
+ for (IAction fAction : fActions) {
+ if (fAction instanceof IUpdate) {
+ ((IUpdate) fAction).update();
+ }
}
IAction action= getEnabledAction();
setEnabled(getEnabledAction() != null);
@@ -93,9 +95,10 @@ public final class CompositeRevertAction extends Action implements IUpdate, ISel
* enabled
*/
private IAction getEnabledAction() {
- for (int i= 0; i < fActions.length; i++) {
- if (fActions[i].isEnabled())
- return fActions[i];
+ for (IAction fAction : fActions) {
+ if (fAction.isEnabled()) {
+ return fAction;
+ }
}
return null;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
index c10707008..e3667a55c 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
@@ -224,8 +224,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
public int getIndex(EnumValue enumValue) {
int i= 0;
- for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
- EnumValue ev= it.next();
+ for (EnumValue ev : fItems) {
if (ev.equals(enumValue))
return i;
i++;
@@ -240,8 +239,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
}
public EnumValue getValueByInteger(int intValue) {
- for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
- EnumValue e= it.next();
+ for (EnumValue e : fItems) {
if (e.getIntValue() == intValue)
return e;
}
@@ -443,8 +441,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
private void initializeFields() {
- for (Iterator<Initializer> it= fInitializers.iterator(); it.hasNext();) {
- Initializer initializer= it.next();
+ for (Initializer initializer : fInitializers) {
initializer.initialize();
}
@@ -517,16 +514,16 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
indent(slaves[0]);
boolean masterState= fOverlayStore.getBoolean(preference.getKey());
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(masterState);
+ for (Control slave : slaves) {
+ slave.setEnabled(masterState);
}
SelectionListener listener= new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean state= master.getSelection();
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(state);
+ for (Control slave : slaves) {
+ slave.setEnabled(state);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
index 6c6a82665..a07d3991e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
@@ -438,8 +438,7 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
if (!(data instanceof String))
return;
- for (int i= 0; i < fListModel.length; i++) {
- final ListItem element= fListModel[i];
+ for (ListItem element : fListModel) {
if (data.equals(element.label)) {
final Control control= fAnnotationTypeViewer.getControl();
control.getDisplay().asyncExec(() -> {
@@ -646,8 +645,7 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
public void dispose() {
ImageRegistry registry= EditorsPlugin.getDefault().getImageRegistry();
- for (Iterator<String> it= fImageKeys.iterator(); it.hasNext();) {
- String string= it.next();
+ for (String string : fImageKeys) {
registry.remove(string);
}
@@ -690,8 +688,7 @@ class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
// set selection
if (selection == null) {
String val= item.textStyleKey == null ? SQUIGGLES[1] : fStore.getString(item.textStyleKey);
- for (Iterator<String[]> iter= list.iterator(); iter.hasNext();) {
- String[] elem= iter.next();
+ for (String[] elem : list) {
if (elem[1].equals(val)) {
selection= elem;
break;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java
index 47d92444c..a0b6eea45 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ConvertLineDelimitersAction.java
@@ -140,8 +140,7 @@ public class ConvertLineDelimitersAction extends FileBufferOperationAction {
* @since 3.2
*/
private boolean containsOnlyFiles(IResource[] resources) {
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if ((IResource.FILE & resource.getType()) == 0)
return false;
}
@@ -158,8 +157,7 @@ public class ConvertLineDelimitersAction extends FileBufferOperationAction {
private IFile[] filterUnacceptableFiles(IFile[] files) {
boolean askForBinary= true;
Set<IFile> filtered= new HashSet<>();
- for (int i= 0; i < files.length; i++) {
- IFile file= files[i];
+ for (IFile file : files) {
if (isAcceptableLocation(file.getFullPath())) {
filtered.add(file);
} else if (askForBinary) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
index af3c1c944..770021d8a 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
@@ -178,9 +178,9 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
- for (int i= 0; i < fHyperlinkDetectorDescriptors.length; i++) {
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, fHyperlinkDetectorDescriptors[i].getId()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, fHyperlinkDetectorDescriptors[i].getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX));
+ for (HyperlinkDetectorDescriptor fHyperlinkDetectorDescriptor : fHyperlinkDetectorDescriptors) {
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, fHyperlinkDetectorDescriptor.getId()));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, fHyperlinkDetectorDescriptor.getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX));
}
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER));
@@ -432,9 +432,11 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
private Object[] getCheckedItems() {
List<ListItem> result= new ArrayList<>();
- for (int i= 0; i < fListModel.length; i++)
- if (!fStore.getBoolean(fListModel[i].id))
- result.add(fListModel[i]);
+ for (ListItem i : fListModel) {
+ if (!fStore.getBoolean(i.id)) {
+ result.add(i);
+ }
+ }
return result.toArray();
}
@@ -498,8 +500,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
private ListItem[] createListModel() {
ArrayList<ListItem> listModelItems= new ArrayList<>();
- for (int i= 0; i < fHyperlinkDetectorDescriptors.length; i++) {
- HyperlinkDetectorDescriptor desc= fHyperlinkDetectorDescriptors[i];
+ for (HyperlinkDetectorDescriptor desc : fHyperlinkDetectorDescriptors) {
HyperlinkDetectorTargetDescriptor target= desc.getTarget();
int stateMask= fStore.getInt(desc.getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
index 05604cf89..4b85bb894 100755
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/LinkedModeConfigurationBlock.java
@@ -466,8 +466,7 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
// set selection
if (selection == null) {
String val= getPreferenceStore().getString(item.textStyleKey);
- for (Iterator<String[]> iter= list.iterator(); iter.hasNext();) {
- String[] elem= iter.next();
+ for (String[] elem : list) {
if (elem[1].equals(val)) {
selection= elem;
break;
@@ -527,8 +526,8 @@ class LinkedModeConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void widgetSelected(SelectionEvent e) {
boolean state= master.getSelection();
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(state);
+ for (Control slave : slaves) {
+ slave.setEnabled(state);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
index c28ed5974..18814d168 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
@@ -144,8 +144,8 @@ public abstract class NextPreviousPulldownActionDelegate extends Action implemen
private void fillMenu(Menu menu) {
IAction[] actions= getActionsFromDescriptors();
- for (int i= 0; i < actions.length; i++) {
- ActionContributionItem item= new ActionContributionItem(actions[i]);
+ for (IAction action : actions) {
+ ActionContributionItem item = new ActionContributionItem(action);
item.fill(menu, -1);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java
index 360927d4f..1c18a2823 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java
@@ -102,9 +102,10 @@ class OverlayPreferenceStore implements IPreferenceStore {
* @return the overlay key or <code>null</code> if none can be found
*/
private OverlayKey findOverlayKey(String key) {
- for (int i= 0; i < fOverlayKeys.length; i++) {
- if (fOverlayKeys[i].fKey.equals(key))
- return fOverlayKeys[i];
+ for (OverlayKey fOverlayKey : fOverlayKeys) {
+ if (fOverlayKey.fKey.equals(key)) {
+ return fOverlayKey;
+ }
}
return null;
}
@@ -185,8 +186,9 @@ class OverlayPreferenceStore implements IPreferenceStore {
* Propagates all overlay keys from this store to the parent store.
*/
public void propagate() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- propagateProperty(fStore, fOverlayKeys[i], fParent);
+ for (OverlayKey fOverlayKey : fOverlayKeys) {
+ propagateProperty(fStore, fOverlayKey, fParent);
+ }
}
/**
@@ -248,8 +250,9 @@ class OverlayPreferenceStore implements IPreferenceStore {
* Loads the values from the parent into this store.
*/
public void load() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- loadProperty(fParent, fOverlayKeys[i], fStore, true);
+ for (OverlayKey fOverlayKey : fOverlayKeys) {
+ loadProperty(fParent, fOverlayKey, fStore, true);
+ }
fLoaded= true;
}
@@ -258,8 +261,9 @@ class OverlayPreferenceStore implements IPreferenceStore {
* Loads the default values.
*/
public void loadDefaults() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- setToDefault(fOverlayKeys[i].fKey);
+ for (OverlayKey fOverlayKey : fOverlayKeys) {
+ setToDefault(fOverlayKey.fKey);
+ }
}
/**
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
index 0970136b8..c3f5fec0a 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
@@ -259,8 +259,8 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
fQuickDiffOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- for (int i= 0; i < fQuickDiffModel.length; i++) {
- fStore.setValue(fQuickDiffModel[i][1], fQuickDiffOverviewRulerCheckBox.getSelection());
+ for (String[] fQuickDiff : fQuickDiffModel) {
+ fStore.setValue(fQuickDiff[1], fQuickDiffOverviewRulerCheckBox.getSelection());
}
}
@@ -378,12 +378,13 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
final boolean enabled= fEnablementCheckbox.getSelection();
fQuickDiffOverviewRulerCheckBox.setEnabled(enabled);
fQuickDiffProviderCombo.setEnabled(enabled);
- for (int i= 0; i < fQuickDiffColorEditors.length; i++)
- fQuickDiffColorEditors[i].setEnabled(enabled);
+ for (ColorSelector fQuickDiffColorEditor : fQuickDiffColorEditors) {
+ fQuickDiffColorEditor.setEnabled(enabled);
+ }
fQuickDiffProviderNote.setEnabled(enabled);
Control[] quickDiffProviderNoteChildren= fQuickDiffProviderNote.getChildren();
- for (int i= 0; i < quickDiffProviderNoteChildren.length; i++) {
- quickDiffProviderNoteChildren[i].setEnabled(enabled);
+ for (Control child : quickDiffProviderNoteChildren) {
+ child.setEnabled(enabled);
}
}
@@ -400,8 +401,8 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void initialize() {
- for (int i= 0; i < fQuickDiffProviderListModel.length; i++) {
- String label= fQuickDiffProviderListModel[i][1];
+ for (String[] fQuickDiffProvider : fQuickDiffProviderListModel) {
+ String label = fQuickDiffProvider[1];
fQuickDiffProviderCombo.add(label);
}
fQuickDiffProviderCombo.getDisplay().asyncExec(() -> updateProviderList());
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java
index c25a0aa87..1962c0cbd 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/RemoveTrailingWhitespaceHandler.java
@@ -91,8 +91,7 @@ public class RemoveTrailingWhitespaceHandler extends FileBufferOperationHandler
* @since 3.2
*/
private boolean containsOnlyFiles(IResource[] resources) {
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if ((IResource.FILE & resource.getType()) == 0)
return false;
}
@@ -108,8 +107,7 @@ public class RemoveTrailingWhitespaceHandler extends FileBufferOperationHandler
*/
private IFile[] filterUnacceptableFiles(IFile[] files) {
Set<IFile> filtered= new HashSet<>();
- for (int i= 0; i < files.length; i++) {
- IFile file= files[i];
+ for (IFile file : files) {
if (isAcceptableLocation(file.getFullPath()))
filtered.add(file);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
index 9ff215c94..dc429846b 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
@@ -345,8 +345,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
}
Object[] treeChildren= treeContentProvider.getChildren(treeElement);
- for (int i= 0; i < treeChildren.length; i++) {
- Object child= treeChildren[i];
+ for (Object child : treeChildren) {
if (addAll)
findAllSelectedListElements(child, fullLabel, true, filter);
else { //Only continue for those with checked state
@@ -417,8 +416,8 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
@Override
public void filterElements(Object[] elements) throws InterruptedException {
- for (int i= 0; i < elements.length; i++) {
- returnValue.add(elements[i]);
+ for (Object element : elements) {
+ returnValue.add(element);
}
}
};
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
index 75ec3955a..eece2dcc2 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesDialog.java
@@ -136,8 +136,8 @@ class SelectResourcesDialog extends Dialog {
public Object[] getChildren(Object o) {
if (o instanceof IWorkspaceRoot) {
HashSet<IResource> projects= new HashSet<>();
- for (int i= 0; i < fInput.length; i++) {
- IResource project= fInput[i].getProject();
+ for (IResource f : fInput) {
+ IResource project = f.getProject();
if ((project.getType() & resourceType) > 0)
projects.add(project);
}
@@ -155,10 +155,10 @@ class SelectResourcesDialog extends Dialog {
//filter out the desired resource types
ArrayList<IResource> results = new ArrayList<>();
- for (int i = 0; i < members.length; i++) {
+ for (IResource member : members) {
//And the test bits with the resource types to see if they are what we want
- if ((members[i].getType() & resourceType) > 0 && (resourceType != IResource.FILE || fAcceptableLocationsFilter == null || fAcceptableLocationsFilter.accept(members[i]))) {
- results.add(members[i]);
+ if ((member.getType() & resourceType) > 0 && (resourceType != IResource.FILE || fAcceptableLocationsFilter == null || fAcceptableLocationsFilter.accept(member))) {
+ results.add(member);
}
}
return results.toArray();
@@ -278,8 +278,7 @@ class SelectResourcesDialog extends Dialog {
protected void setSelection(IResource[] input, IFilter filter) {
Map<IContainer, List<Object>> selectionMap= new Hashtable<>();
- for (int i= 0; i < input.length; i++) {
- IResource resource= input[i];
+ for (IResource resource : input) {
if ((resource.getType() & IResource.FILE) > 0) {
if (filter.accept(resource)) {
List<Object> files= null;
@@ -305,8 +304,7 @@ class SelectResourcesDialog extends Dialog {
IResource[] resources= parent.members();
List<Object> selections= new ArrayList<>();
- for (int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if ((resource.getType() & IResource.FILE) > 0) {
if (filter.accept(resource))
selections.add(resource);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
index 5788f4971..7f886cc47 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
@@ -202,8 +202,8 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
private Map<String, SpellingEngineDescriptor> createListModel() {
SpellingEngineDescriptor[] descs= EditorsUI.getSpellingService().getSpellingEngineDescriptors();
Map<String, SpellingEngineDescriptor> map= new HashMap<>();
- for (int i= 0; i < descs.length; i++) {
- map.put(descs[i].getId(), descs[i]);
+ for (SpellingEngineDescriptor desc : descs) {
+ map.put(desc.getId(), desc);
}
return map;
}
@@ -421,8 +421,9 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
private void setEnabled(Control control, boolean enabled) {
if (control instanceof Composite) {
Control[] children= ((Composite) control).getChildren();
- for (int i= 0; i < children.length; i++)
- setEnabled(children[i], enabled);
+ for (Control c : children) {
+ setEnabled(c, enabled);
+ }
}
control.setEnabled(enabled);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java
index d52fcfd99..c9cd6b850 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java
@@ -51,8 +51,7 @@ public class StatusUtil {
*/
public static IStatus getMostSevere(IStatus[] status) {
IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
+ for (IStatus curr : status) {
if (curr.matches(IStatus.ERROR)) {
return curr;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java
index 5f95b5c26..ba477d723 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java
@@ -64,8 +64,8 @@ class TabFolderLayout extends Layout {
Rectangle rect= composite.getClientArea();
Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setBounds(rect);
+ for (Control c : children) {
+ c.setBounds(rect);
}
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index 23e161535..43a5380a7 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -270,8 +270,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
public int getIndex(EnumValue enumValue) {
int i= 0;
- for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
- EnumValue ev= it.next();
+ for (EnumValue ev : fItems) {
if (ev.equals(enumValue))
return i;
i++;
@@ -286,8 +285,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
public EnumValue getValueByInteger(int intValue) {
- for (Iterator<EnumValue> it= fItems.iterator(); it.hasNext();) {
- EnumValue e= it.next();
+ for (EnumValue e : fItems) {
if (e.getIntValue() == intValue)
return e;
}
@@ -449,8 +447,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
private void initializeShowWhitespaceCharactersPreferences() {
- for (Iterator<Initializer> it= fDialogInitializers.iterator(); it.hasNext();) {
- Initializer initializer= it.next();
+ for (Initializer initializer : fDialogInitializers) {
initializer.initialize();
}
}
@@ -1039,8 +1036,9 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
initializeFields();
- for (int i= 0; i < fAppearanceColorListModel.length; i++)
- fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
+ for (String[] fAppearanceColor : fAppearanceColorListModel) {
+ fAppearanceColorList.add(fAppearanceColor[0]);
+ }
fAppearanceColorList.getDisplay().asyncExec(() -> {
if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
fAppearanceColorList.select(0);
@@ -1050,8 +1048,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
}
private void initializeFields() {
- for (Iterator<Initializer> it= fInitializers.iterator(); it.hasNext();) {
- Initializer initializer= it.next();
+ for (Initializer initializer : fInitializers) {
initializer.initialize();
}
@@ -1212,8 +1209,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
combo.setLayoutData(gd);
combo.setToolTipText(preference.getDescription());
- for (Iterator<EnumValue> it= domain.fItems.iterator(); it.hasNext();) {
- EnumValue value= it.next();
+ for (EnumValue value : domain.fItems) {
combo.add(value.getLabel());
}
@@ -1315,16 +1311,16 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
indent(slaves[0]);
boolean masterState= fOverlayStore.getBoolean(preference.getKey());
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(masterState);
+ for (Control slave : slaves) {
+ slave.setEnabled(masterState);
}
SelectionListener listener= new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean state= master.getSelection();
- for (int i= 0; i < slaves.length; i++) {
- slaves[i].setEnabled(state);
+ for (Control slave : slaves) {
+ slave.setEnabled(state);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
index 0131f8790..b45d30561 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
@@ -92,9 +92,7 @@ public final class AnnotationTypeHierarchy {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "annotationTypes"); //$NON-NLS-1$
if (extensionPoint != null) {
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
-
+ for (IConfigurationElement element : elements) {
String name= element.getAttribute("name"); //$NON-NLS-1$
if (name == null || name.trim().length() == 0)
continue;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
index 93ad4c6cf..10006a962 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
@@ -53,8 +53,8 @@ public class DelegatingAnnotationPreference extends AnnotationPreference {
return p;
String[] superTypes= fType.getSuperTypes();
- for (int i= 0; i < superTypes.length; i++) {
- p= fLookup.getAnnotationPreferenceFragment(superTypes[i]);
+ for (String superType : superTypes) {
+ p = fLookup.getAnnotationPreferenceFragment(superType);
if (p != null && p.hasValue(attribute))
return p;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java
index c91c7f421..0f2b24c8e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/LineNumberColumn.java
@@ -399,9 +399,9 @@ public class LineNumberColumn extends AbstractContributedRulerColumn implements
if (column instanceof IRevisionRulerColumnExtension) {
String option= store.getString(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE);
RenderingMode[] modes= { IRevisionRulerColumnExtension.AUTHOR, IRevisionRulerColumnExtension.AGE, IRevisionRulerColumnExtension.AUTHOR_SHADED_BY_AGE };
- for (int i= 0; i < modes.length; i++) {
- if (modes[i].name().equals(option)) {
- ((IRevisionRulerColumnExtension) column).setRevisionRenderingMode(modes[i]);
+ for (RenderingMode mode : modes) {
+ if (mode.name().equals(option)) {
+ ((IRevisionRulerColumnExtension) column).setRevisionRenderingMode(mode);
return;
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java
index 3177c6478..604865342 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java
@@ -174,8 +174,9 @@ class SourceViewerInformationControl implements IInformationControl, IInformatio
fStatusField.setText(statusFieldText);
Font font= fStatusField.getFont();
FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
+ for (FontData fontData : fontDatas) {
+ fontData.setHeight(fontData.getHeight() * 9 / 10);
+ }
fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
fStatusField.setFont(fStatusTextFont);
GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
index 6c0f9af90..76e411f0c 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
@@ -880,8 +880,8 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
if (sourceViewer instanceof ITextViewerExtension6) {
HyperlinkDetectorDescriptor[] descriptor= EditorsUI.getHyperlinkDetectorRegistry().getHyperlinkDetectorDescriptors();
- for (int i= 0; i < descriptor.length; i++) {
- if (descriptor[i].getId().equals(property) || (descriptor[i].getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX).equals(property)) {
+ for (HyperlinkDetectorDescriptor d : descriptor) {
+ if (d.getId().equals(property) || (d.getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX).equals(property)) {
IHyperlinkDetector[] detectors= getSourceViewerConfiguration().getHyperlinkDetectors(sourceViewer);
int stateMask= getSourceViewerConfiguration().getHyperlinkStateMask(sourceViewer);
ITextViewerExtension6 textViewer6= (ITextViewerExtension6)sourceViewer;
@@ -1113,9 +1113,10 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
return !isReadOnlyLocalStatus(status);
IStatus[] childrenStatus= status.getChildren();
- for (int i= 0; i < childrenStatus.length; i++) {
- if (childrenStatus[i].getSeverity() == IStatus.ERROR && !isReadOnlyLocalStatus(childrenStatus[i]))
+ for (IStatus childrenStatu : childrenStatus) {
+ if (childrenStatu.getSeverity() == IStatus.ERROR && !isReadOnlyLocalStatus(childrenStatu)) {
return true;
+ }
}
return false;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
index 79f55b89d..96f2f1c40 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
@@ -723,13 +723,13 @@ public class AbstractDecoratedTextEditorPreferenceConstants {
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER_MASK, SWT.MOD1);
HyperlinkDetectorDescriptor[] descriptors= EditorsUI.getHyperlinkDetectorRegistry().getHyperlinkDetectorDescriptors();
- for (int i= 0; i < descriptors.length; i++) {
- int stateMask= computeStateMask(descriptors[i].getModifierKeys());
+ for (HyperlinkDetectorDescriptor descriptor : descriptors) {
+ int stateMask = computeStateMask(descriptor.getModifierKeys());
if (stateMask == SWT.SHIFT) {
- EditorsPlugin.logErrorMessage("The '" + descriptors[i].getId() + "' hyperlink detector specifies 'Shift' as modifier. This is not allowed and hence replaced with the default modifier."); //$NON-NLS-1$ //$NON-NLS-2$
+ EditorsPlugin.logErrorMessage("The '" + descriptor.getId() + "' hyperlink detector specifies 'Shift' as modifier. This is not allowed and hence replaced with the default modifier."); //$NON-NLS-1$ //$NON-NLS-2$
stateMask= -1;
}
- store.setDefault(descriptors[i].getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX, stateMask);
+ store.setDefault(descriptor.getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX, stateMask);
}
boolean isInstalled= EditorsUI.getSpellingService().getSpellingEngineDescriptors().length > 0;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index 2afcf8f03..4cecc2c9f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -280,16 +280,18 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
}
//start sorting based on required-updater definition
HashMap<String, ArrayList<String>> markerUpdaterRequiredByOrderMap= new HashMap<>(2);
- for (int i= 0; i < elements.length; i++) {
+ for (IConfigurationElement element : elements) {
// Required marker should execute before other updater markers
- IConfigurationElement[] requiredUpdaters= elements[i].getChildren("required-updater"); //$NON-NLS-1$
+ IConfigurationElement[] requiredUpdaters = element.getChildren("required-updater"); //$NON-NLS-1$
if (requiredUpdaters.length > 0) {
//ArrayList requiredUpdaters= new ArrayList(2);
- for (int j= 0; j < requiredUpdaters.length; j++) { // If required updaters have been defined
- String requiredID= requiredUpdaters[j].getAttribute(ID);
+ for (IConfigurationElement requiredUpdater : requiredUpdaters) {
+ // If required updaters have been defined
+ String requiredID = requiredUpdater.getAttribute(ID);
// If required ID is not a valid id
- if (requiredID == null || (markerUpdaterOrderMap.get(requiredID) == null)) { // ID missing or invalid - log the message and move to next contribution
- String msg= NLSUtility.format(TextEditorMessages.AbstractMarkerAnnotationModel_updaterInvalidDefinition, new Object[] { elements[i].getAttribute(ID), requiredID });
+ if (requiredID == null || (markerUpdaterOrderMap.get(requiredID) == null)) {
+ // ID missing or invalid - log the message and move to next contribution
+ String msg = NLSUtility.format(TextEditorMessages.AbstractMarkerAnnotationModel_updaterInvalidDefinition, new Object[]{element.getAttribute(ID), requiredID});
EditorsPlugin.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, msg));
continue;
}
@@ -304,26 +306,27 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
requiredByUpdaters= markerUpdaterRequiredByOrderMap.get(requiredID);
}
// Build up extended required id list to identify Case 2
- if (markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID)) != null) {
- ArrayList<String> requiredByList= markerUpdaterRequiredByOrderMap.get(elements[i].getAttribute(ID));
+ if (markerUpdaterRequiredByOrderMap.get(element.getAttribute(ID)) != null) {
+ ArrayList<String> requiredByList = markerUpdaterRequiredByOrderMap.get(element.getAttribute(ID));
requiredByUpdaters.addAll(requiredByList);
}
- if (requiredByUpdaters.contains(requiredID)) { //log error if marker ID is in the required list of required ID
- String msg= NLSUtility.format(TextEditorMessages.AbstractMarkerAnnotationModel_markerUpdaterCyclicDefinition, new Object[] { elements[i].getAttribute(ID), requiredID });
+ if (requiredByUpdaters.contains(requiredID)) {
+ //log error if marker ID is in the required list of required ID
+ String msg = NLSUtility.format(TextEditorMessages.AbstractMarkerAnnotationModel_markerUpdaterCyclicDefinition, new Object[]{element.getAttribute(ID), requiredID});
EditorsPlugin.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, msg));
continue;
}
- requiredByUpdaters.add(elements[i].getAttribute(ID));
+ requiredByUpdaters.add(element.getAttribute(ID));
markerUpdaterRequiredByOrderMap.put(requiredID, requiredByUpdaters);
Integer requiredLocation= markerUpdaterOrderMap.get(requiredID);
- if (requiredLocation.intValue() > markerUpdaterOrderMap.get(elements[i].getAttribute(ID)).intValue()) { // If required marker is not ordered before
- int newLocation= (markerUpdaterOrderMap.get(elements[i].getAttribute(ID)).intValue() == 0) ? 0 : (markerUpdaterOrderMap.get(elements[i]
- .getAttribute(ID)).intValue() - 1);
+ if (requiredLocation.intValue() > markerUpdaterOrderMap.get(element.getAttribute(ID)).intValue()) {
+ // If required marker is not ordered before
+ int newLocation = (markerUpdaterOrderMap.get(element.getAttribute(ID)).intValue() == 0) ? 0 : (markerUpdaterOrderMap.get(element.getAttribute(ID)).intValue() - 1);
IConfigurationElement requiredMarker= markerUpdaterSpecificationsLinkedList.remove(requiredLocation.intValue());
markerUpdaterSpecificationsLinkedList.add(newLocation, requiredMarker); // Put the required location before the marker
markerUpdaterOrderMap.put(requiredID, Integer.valueOf(newLocation));
- markerUpdaterOrderMap.put(elements[i].getAttribute(ID), Integer.valueOf(newLocation + 1));
+ markerUpdaterOrderMap.put(element.getAttribute(ID), Integer.valueOf(newLocation + 1));
}
}
}
@@ -398,8 +401,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
if (annotations != null && annotations.size() > 0) {
List<Annotation> markerAnnotations= new ArrayList<>();
- for (Iterator<? extends Annotation> e= annotations.iterator(); e.hasNext();) {
- Annotation a= e.next();
+ for (Annotation a : annotations) {
if (a instanceof MarkerAnnotation)
markerAnnotations.add(a);
@@ -467,8 +469,9 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
IMarker[] markers= retrieveMarkers();
if (markers != null) {
- for (int i= 0; i < markers.length; i++)
- addMarkerAnnotation(markers[i]);
+ for (IMarker marker : markers) {
+ addMarkerAnnotation(marker);
+ }
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
index 151eaf187..996737dc1 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
@@ -93,8 +93,8 @@ public final class AnnotationTypeLookup {
if (annotationType != null)
return annotationType;
String[] superTypes= MarkerUtilities.getSuperTypes(markerType);
- for (int i= 0; i < superTypes.length; i++) {
- annotationType= lookupAnnotationType(superTypes[i], markerSeverity);
+ for (String superType : superTypes) {
+ annotationType = lookupAnnotationType(superType, markerSeverity);
if (annotationType != null)
return annotationType;
}
@@ -180,8 +180,8 @@ public final class AnnotationTypeLookup {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, extensionPointName);
if (extensionPoint != null) {
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- AnnotationTypeMapping mapping= createMapping(elements[i], typeAttributeName);
+ for (IConfigurationElement element : elements) {
+ AnnotationTypeMapping mapping = createMapping(element, typeAttributeName);
if (mapping != null)
annotationTypeMappings.add(mapping);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
index c08410cc0..8954d3f75 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
@@ -135,9 +135,9 @@ public class DocumentProviderRegistry {
}
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- read(fExtensionMapping, elements[i], "extensions"); //$NON-NLS-1$
- read(fInputTypeMapping, elements[i], "inputTypes"); //$NON-NLS-1$
+ for (IConfigurationElement element : elements) {
+ read(fExtensionMapping, element, "extensions"); //$NON-NLS-1$
+ read(fInputTypeMapping, element, "inputTypes"); //$NON-NLS-1$
}
}
@@ -245,8 +245,7 @@ public class DocumentProviderRegistry {
List<Class<?>> toBeVisited= new ArrayList<>(interfaces.length);
- for (int i= 0; i < interfaces.length; i++) {
- Class<?> iface= interfaces[i];
+ for (Class<?> iface : interfaces) {
if (visited.get(iface) == null) {
visited.put(iface, iface);
result.add(iface);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
index 9de18d0a4..d2c66462f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
@@ -290,8 +290,8 @@ public class MarkerAnnotationPreferences {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "markerAnnotationSpecification"); //$NON-NLS-1$
if (extensionPoint != null) {
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- AnnotationPreference spec= createSpec(elements[i]);
+ for (IConfigurationElement element : elements) {
+ AnnotationPreference spec = createSpec(element);
if (spec != null)
fFragments.add(spec);
if (isComplete(spec))
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
index 3039f5246..41aaed68b 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
@@ -350,9 +350,9 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
try {
IMarker[] allMarkers= resource.findMarkers(fMarkerType, true, IResource.DEPTH_ZERO);
if (allMarkers != null) {
- for (int i= 0; i < allMarkers.length; i++) {
- if (includesRulerLine(model.getMarkerPosition(allMarkers[i]), document)) {
- markers.add(allMarkers[i]);
+ for (IMarker allMarker : allMarkers) {
+ if (includesRulerLine(model.getMarkerPosition(allMarker), document)) {
+ markers.add(allMarker);
}
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
index fd228130b..23b6fa8e5 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
@@ -89,8 +89,7 @@ public final class MarkerUtilities {
private <T> void appendAll(List<T> list, T[] objects) {
if (objects == null)
return;
- for (int i= 0; i < objects.length; i++) {
- T o= objects[i];
+ for (T o : objects) {
if (!list.contains(o))
list.add(o);
}
@@ -107,8 +106,7 @@ public final class MarkerUtilities {
IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS);
if (point != null) {
IExtension[] extensions = point.getExtensions();
- for (int i= 0; i < extensions.length; i++) {
- IExtension extension= extensions[i];
+ for (IExtension extension : extensions) {
ArrayList<String> types= new ArrayList<>();
IConfigurationElement[] configElements= extension.getConfigurationElements();
for (int j= 0; j < configElements.length; ++j) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
index 9e2df9216..236cc50e3 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
@@ -123,8 +123,7 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel
HashSet<IMarker> removedMarkers= new HashSet<>(markerDeltas.length);
HashSet<IMarker> modifiedMarkers= new HashSet<>(markerDeltas.length);
- for (int i= 0; i < markerDeltas.length; i++) {
- IMarkerDelta delta= markerDeltas[i];
+ for (IMarkerDelta delta : markerDeltas) {
switch (delta.getKind()) {
case IResourceDelta.ADDED:
addMarkerAnnotation(delta.getMarker());
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java
index 1e9ad6fb8..7f54b52d0 100644
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaCodeScanner.java
@@ -69,12 +69,15 @@ public class JavaCodeScanner extends RuleBasedScanner {
// Add word rule for keywords, types, and constants.
WordRule wordRule= new WordRule(new JavaWordDetector(), other);
- for (int i= 0; i < fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], keyword);
- for (int i= 0; i < fgTypes.length; i++)
- wordRule.addWord(fgTypes[i], type);
- for (int i= 0; i < fgConstants.length; i++)
- wordRule.addWord(fgConstants[i], type);
+ for (String fgKeyword : fgKeywords) {
+ wordRule.addWord(fgKeyword, keyword);
+ }
+ for (String fgType : fgTypes) {
+ wordRule.addWord(fgType, type);
+ }
+ for (String fgConstant : fgConstants) {
+ wordRule.addWord(fgConstant, type);
+ }
rules.add(wordRule);
IRule[] result= new IRule[rules.size()];
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java
index 25ac327f2..94122266b 100644
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/javadoc/JavaDocScanner.java
@@ -80,8 +80,9 @@ public class JavaDocScanner extends RuleBasedScanner {
// Add word rule for keywords.
WordRule wordRule= new WordRule(new JavaDocWordDetector());
- for (int i= 0; i < fgKeywords.length; i++)
- wordRule.addWord(fgKeywords[i], keyword);
+ for (String fgKeyword : fgKeywords) {
+ wordRule.addWord(fgKeyword, keyword);
+ }
list.add(wordRule);
IRule[] result= new IRule[list.size()];
diff --git a/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/NatureLabelHoverProvider.java b/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/NatureLabelHoverProvider.java
index 21c142ab7..4c3935024 100644
--- a/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/NatureLabelHoverProvider.java
+++ b/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/NatureLabelHoverProvider.java
@@ -39,9 +39,10 @@ public class NatureLabelHoverProvider implements ITextHover {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectNatureDescriptor[] natureDescriptors= workspace.getNatureDescriptors();
- for (int i= 0; i < natureDescriptors.length; i++) {
- if (natureDescriptors[i].getNatureId().equals(selection))
- return natureDescriptors[i].getLabel();
+ for (IProjectNatureDescriptor natureDescriptor : natureDescriptors) {
+ if (natureDescriptor.getNatureId().equals(selection)) {
+ return natureDescriptor.getLabel();
+ }
}
return null;
}
diff --git a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
index 59cb08b02..34dfad097 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
+++ b/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java
@@ -145,8 +145,7 @@ public class ScreenshotTest {
Shell[] shells= display.getShells();
if (shells.length > 0) {
out.println("Shells: ");
- for (int i= 0; i < shells.length; i++) {
- Shell shell= shells[i];
+ for (Shell shell : shells) {
out.print(display.getActiveShell() == shell ? " active, " : " inactive, ");
out.print((shell.isVisible() ? "visible: " : "invisible: ") + shell);
out.println(" @ " + shell.getBounds().toString());
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/CompoundEditExitStrategy.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/CompoundEditExitStrategy.java
index deda8adbe..1b5f8dc35 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/CompoundEditExitStrategy.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/CompoundEditExitStrategy.java
@@ -97,9 +97,10 @@ public final class CompoundEditExitStrategy {
@Override
public void preExecute(String commandId, ExecutionEvent event) {
// any command other than the known ones end the compound change
- for (int i= 0; i < fCommandIds.length; i++) {
- if (commandId.equals(fCommandIds[i]))
+ for (String fCommandId : fCommandIds) {
+ if (commandId.equals(fCommandId)) {
return;
+ }
}
fireEndCompoundEdit();
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java
index 8c24259fa..8e3748753 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java
@@ -217,8 +217,7 @@ public final class HippieCompletionEngine {
HashSet<String> seenAlready= new HashSet<>();
ArrayList<String> uniqueSuggestions= new ArrayList<>();
- for (Iterator<String> i= suggestions.iterator(); i.hasNext();) {
- String suggestion= i.next();
+ for (String suggestion : suggestions) {
if (!seenAlready.contains(suggestion)) {
seenAlready.add(suggestion);
uniqueSuggestions.add(suggestion);
@@ -259,8 +258,8 @@ public final class HippieCompletionEngine {
IWorkbenchWindow window= currentTextEditor.getSite().getWorkbenchWindow();
IEditorReference editorsArray[]= window.getActivePage().getEditorReferences();
- for (int i= 0; i < editorsArray.length; i++) {
- IEditorPart realEditor= editorsArray[i].getEditor(false);
+ for (IEditorReference editor : editorsArray) {
+ IEditorPart realEditor = editor.getEditor(false);
if (realEditor instanceof ITextEditor && !realEditor.equals(currentTextEditor)) {
ITextEditor textEditor= (ITextEditor)realEditor;
provider= textEditor.getDocumentProvider();
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java
index bd1cd04c8..2c192d9ce 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java
@@ -72,8 +72,7 @@ public class CodeMiningProviderRegistry {
List<CodeMiningProviderDescriptor> descriptors = new ArrayList<>();
IConfigurationElement[] elements = Platform.getExtensionRegistry()
.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, CODEMINING_PROVIDERS_EXTENSION_POINT);
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
+ for (IConfigurationElement element : elements) {
try {
CodeMiningProviderDescriptor descriptor = new CodeMiningProviderDescriptor(element);
descriptors.add(descriptor);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
index 454e663eb..594ca6471 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
@@ -880,16 +880,13 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// inform listeners about change
if (fUpdateNeeded) {
AnnotationModelEvent ame= new AnnotationModelEvent(this, false);
- for (Iterator<QuickDiffRangeDifference> it= fAdded.iterator(); it.hasNext(); ) {
- QuickDiffRangeDifference rd= it.next();
+ for (QuickDiffRangeDifference rd : fAdded) {
ame.annotationAdded(rd.getDiffRegion(fDifferences, fLeftDocument));
}
- for (Iterator<QuickDiffRangeDifference> it= fRemoved.iterator(); it.hasNext(); ) {
- QuickDiffRangeDifference rd= it.next();
+ for (QuickDiffRangeDifference rd : fRemoved) {
ame.annotationRemoved(rd.getDiffRegion(fDifferences, fLeftDocument));
}
- for (Iterator<QuickDiffRangeDifference> it= fChanged.iterator(); it.hasNext(); ) {
- QuickDiffRangeDifference rd= it.next();
+ for (QuickDiffRangeDifference rd : fChanged) {
ame.annotationChanged(rd.getDiffRegion(fDifferences, fLeftDocument));
}
fireModelChanged(ame);
@@ -1032,8 +1029,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// shift the partial diffs to the absolute document positions
- for (Iterator<QuickDiffRangeDifference> it= diffs.iterator(); it.hasNext();) {
- QuickDiffRangeDifference d= it.next();
+ for (QuickDiffRangeDifference d : diffs) {
d.shiftLeft(leftStartLine);
d.shiftRight(rightStartLine);
}
@@ -1369,8 +1365,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* @return the corresponding RangeDifference, or <code>null</code>
*/
private QuickDiffRangeDifference getRangeDifferenceForLeftLine(int leftLine) {
- for (Iterator<QuickDiffRangeDifference> it= fDifferences.iterator(); it.hasNext();) {
- QuickDiffRangeDifference d= it.next();
+ for (QuickDiffRangeDifference d : fDifferences) {
if (leftLine >= d.leftStart() && leftLine < d.leftEnd()) {
return d;
}
@@ -1387,8 +1382,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
private QuickDiffRangeDifference getRangeDifferenceForRightLine(int rightLine) {
final List<QuickDiffRangeDifference> differences= fDifferences;
synchronized (differences) {
- for (Iterator<QuickDiffRangeDifference> it= differences.iterator(); it.hasNext();) {
- QuickDiffRangeDifference d= it.next();
+ for (QuickDiffRangeDifference d : differences) {
if (rightLine >= d.rightStart() && rightLine < d.rightEnd()) {
return d;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
index 3707acf01..327b92f19 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
@@ -85,8 +85,8 @@ public class QuickDiffExtensionsRegistry {
List<ReferenceProviderDescriptor> list= new ArrayList<>();
IConfigurationElement[] elements= registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, TextEditorPlugin.REFERENCE_PROVIDER_EXTENSION_POINT);
- for (int i= 0; i < elements.length; i++) {
- ReferenceProviderDescriptor desc= new ReferenceProviderDescriptor(elements[i]);
+ for (IConfigurationElement element : elements) {
+ ReferenceProviderDescriptor desc = new ReferenceProviderDescriptor(element);
if (desc.getId().equals("org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider")) //$NON-NLS-1$
fDefaultDescriptor= desc;
list.add(desc);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java
index 70a79f12f..91a158f72 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java
@@ -178,8 +178,7 @@ public final class DAG<E> {
private static <T> Set<T> computeZeroEdgeVertices(MultiMap<T, T> map) {
Set<T> candidates= map.keySet();
Set<T> roots= new LinkedHashSet<>(candidates.size());
- for (Iterator<T> it= candidates.iterator(); it.hasNext();) {
- T candidate= it.next();
+ for (T candidate : candidates) {
if (map.get(candidate).isEmpty())
roots.add(candidate);
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java
index aa75d0009..29628e9f3 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java
@@ -60,8 +60,7 @@ public final class RulerColumnPlacement {
private Set<RulerColumnPlacementConstraint> readIds(IConfigurationElement[] children) throws CoreException {
Set<RulerColumnPlacementConstraint> constraints= new LinkedHashSet<>((int) (children.length / 0.75) + 1, 0.75f);
- for (int i= 0; i < children.length; i++) {
- IConfigurationElement child= children[i];
+ for (IConfigurationElement child : children) {
String name= child.getName();
ExtensionPointHelper childHelper= new ExtensionPointHelper(child);
boolean before;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java
index 7b46fa0f8..2a9accfd4 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java
@@ -98,8 +98,8 @@ public class SpellingEngineRegistry {
fDescriptorsMap= new HashMap<>();
fDefaultDescriptor= null;
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, SPELLING_ENGINE_EXTENSION_POINT);
- for (int i= 0; i < elements.length; i++) {
- SpellingEngineDescriptor descriptor= new SpellingEngineDescriptor(elements[i]);
+ for (IConfigurationElement element : elements) {
+ SpellingEngineDescriptor descriptor = new SpellingEngineDescriptor(element);
descriptors.add(descriptor);
fDescriptorsMap.put(descriptor.getId(), descriptor);
if (fDefaultDescriptor == null && descriptor.isDefault())
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java
index 66cd56ceb..36cbd278e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java
@@ -14,7 +14,6 @@
package org.eclipse.ui.texteditor.quickdiff;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -96,8 +95,7 @@ public class QuickDiff {
List<ReferenceProviderDescriptor> descs= getReferenceProviderDescriptors();
// try to fetch preferred provider; load if needed
- for (Iterator<ReferenceProviderDescriptor> iter= descs.iterator(); iter.hasNext();) {
- ReferenceProviderDescriptor desc= iter.next();
+ for (ReferenceProviderDescriptor desc : descs) {
if (desc.getId().equals(id)) {
IQuickDiffReferenceProvider provider= desc.createProvider();
if (provider != null) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
index 91af3e8ae..33c5f690c 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
@@ -14,7 +14,6 @@
package org.eclipse.ui.texteditor.quickdiff;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.action.IAction;
@@ -100,8 +99,7 @@ public class QuickDiffToggleAction implements IEditorActionDelegate, IUpdate {
// create quickdiff menu
menu= new MenuManager(QuickDiffMessages.quickdiff_menu_label, MENU_ID);
List<ReferenceProviderDescriptor> descriptors= new QuickDiff().getReferenceProviderDescriptors();
- for (Iterator<ReferenceProviderDescriptor> it= descriptors.iterator(); it.hasNext();) {
- ReferenceProviderDescriptor desc= it.next();
+ for (ReferenceProviderDescriptor desc : descriptors) {
ReferenceSelectionAction action= new ReferenceSelectionAction(desc, fEditor);
if (action.isEnabled())
menu.add(action);
@@ -110,8 +108,8 @@ public class QuickDiffToggleAction implements IEditorActionDelegate, IUpdate {
// create restore menu if this action is enabled
if (isConnected()) {
- for (int i= 0; i < fRestoreActions.length; i++) {
- fRestoreActions[i].update();
+ for (QuickDiffRestoreAction fRestoreAction : fRestoreActions) {
+ fRestoreAction.update();
}
// only add block action if selection action is not enabled
if (fRestoreActions[0].isEnabled())
@@ -135,8 +133,8 @@ public class QuickDiffToggleAction implements IEditorActionDelegate, IUpdate {
fEditor= (ITextEditor)targetEditor;
} else
fEditor= null;
- for (int i= 0; i < fRestoreActions.length; i++) {
- fRestoreActions[i].setEditor(fEditor);
+ for (QuickDiffRestoreAction fRestoreAction : fRestoreActions) {
+ fRestoreAction.setEditor(fEditor);
}
setPopupMenu();
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnDescriptor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnDescriptor.java
index 5af451aad..7a6c6f9e1 100755
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnDescriptor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnDescriptor.java
@@ -119,18 +119,15 @@ public final class RulerColumnDescriptor {
fTarget= null; // dummy
} else {
RulerColumnTarget combined= null;
- for (int i= 0; i < targetEditors.length; i++) {
- IConfigurationElement targetEditor= targetEditors[i];
+ for (IConfigurationElement targetEditor : targetEditors) {
RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID));
combined= RulerColumnTarget.createOrTarget(combined, target);
}
- for (int i= 0; i < targetContentTypes.length; i++) {
- IConfigurationElement targetContentType= targetContentTypes[i];
+ for (IConfigurationElement targetContentType : targetContentTypes) {
RulerColumnTarget target= RulerColumnTarget.createContentTypeTarget(new ExtensionPointHelper(targetContentType).getNonNullAttribute(ID));
combined= RulerColumnTarget.createOrTarget(combined, target);
}
- for (int i= 0; i < targetClasses.length; i++) {
- IConfigurationElement targetClass= targetClasses[i];
+ for (IConfigurationElement targetClass : targetClasses) {
RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS));
combined= RulerColumnTarget.createOrTarget(combined, target);
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java
index 09175c090..18f2e4411 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java
@@ -207,19 +207,15 @@ public final class RulerColumnRegistry {
sorter.sort(array);
Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<>();
- for (int i= 0; i < array.length; i++) {
- RulerColumnDescriptor desc= array[i];
+ for (RulerColumnDescriptor desc : array) {
descriptorsById.put(desc.getId(), desc);
}
DAG<RulerColumnDescriptor> dag= new DAG<>();
- for (int i= 0; i < array.length; i++) {
- RulerColumnDescriptor desc= array[i];
+ for (RulerColumnDescriptor desc : array) {
dag.addVertex(desc);
-
Set<RulerColumnPlacementConstraint> before= desc.getPlacement().getConstraints();
- for (Iterator<RulerColumnPlacementConstraint> it= before.iterator(); it.hasNext();) {
- RulerColumnPlacementConstraint constraint= it.next();
+ for (RulerColumnPlacementConstraint constraint : before) {
String id= constraint.getId();
RulerColumnDescriptor target= descriptorsById.get(id);
if (target == null) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java
index 12533f7b4..21145ec4c 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java
@@ -93,8 +93,9 @@ public final class SpellingCorrectionProcessor implements IQuickAssistProcessor
private List<ICompletionProposal> computeProposals(IQuickAssistInvocationContext context, SpellingProblem[] spellingProblems) {
List<ICompletionProposal> proposals= new ArrayList<>();
- for (int i= 0; i < spellingProblems.length; i++)
- proposals.addAll(Arrays.asList(spellingProblems[i].getProposals(context)));
+ for (SpellingProblem spellingProblem : spellingProblems) {
+ proposals.addAll(Arrays.asList(spellingProblem.getProposals(context)));
+ }
return proposals;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
index 12bdb29f5..9e0deea45 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
@@ -347,9 +347,10 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
private TemplatePersistenceData[] getTemplates(String contextId) {
List<TemplatePersistenceData> templateList= new ArrayList<>();
TemplatePersistenceData[] datas= getTemplateStore().getTemplateData(false);
- for (int i= 0; i < datas.length; i++) {
- if (datas[i].isEnabled() && datas[i].getTemplate().getContextTypeId().equals(contextId))
- templateList.add(datas[i]);
+ for (TemplatePersistenceData data : datas) {
+ if (data.isEnabled() && data.getTemplate().getContextTypeId().equals(contextId)) {
+ templateList.add(data);
+ }
}
return templateList
.toArray(new TemplatePersistenceData[templateList.size()]);
@@ -376,9 +377,10 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
if (datas.length <= 0)
return false;
- for (int i= 0; i < datas.length; i++) {
- if (datas[i].isEnabled() && datas[i].getTemplate().getContextTypeId().equals(contextId))
+ for (TemplatePersistenceData data : datas) {
+ if (data.isEnabled() && data.getTemplate().getContextTypeId().equals(contextId)) {
return true;
+ }
}
return false;
}
@@ -1327,9 +1329,9 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
*
*/
private void moveTemplates(TemplatePersistenceData[] templates, String contextId) {
- for (int i= 0; i < templates.length; i++) {
- Template t= templates[i].getTemplate();
- templates[i].setTemplate(new Template(t.getName(), t.getDescription(), contextId, t
+ for (TemplatePersistenceData template : templates) {
+ Template t = template.getTemplate();
+ template.setTemplate(new Template(t.getName(), t.getDescription(), contextId, t
.getPattern(), t.isAutoInsertable()));
}
saveTemplateStore();
@@ -1374,8 +1376,8 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
new Object[] { Integer.valueOf(selectedTemplates.length) });
if (!MessageDialog.openQuestion(getShell(), title, message))
return;
- for (int i= 0; i < selectedTemplates.length; i++) {
- getTemplateStore().delete(selectedTemplates[i]);
+ for (TemplatePersistenceData selectedTemplate : selectedTemplates) {
+ getTemplateStore().delete(selectedTemplate);
}
saveTemplateStore();
fTreeViewer.setSelection(new StructuredSelection(new Object[] {}), true);
@@ -1499,9 +1501,8 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
*/
private void storeCollapseState() {
TreeItem[] items= fTreeViewer.getTree().getItems();
- for (int i= 0; i < items.length; i++) {
- fPreferenceStore.setValue(CONTEXT_COLLAPSE_PREF_ID
- + ((TemplateContextType) items[i].getData()).getId(), !items[i].getExpanded());
+ for (TreeItem item : items) {
+ fPreferenceStore.setValue(CONTEXT_COLLAPSE_PREF_ID + ((TemplateContextType) item.getData()).getId(), !item.getExpanded());
}
}
@@ -1514,13 +1515,13 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
try {
fTreeViewer.refresh();
TreeItem[] items= fTreeViewer.getTree().getItems();
- for (int i= 0; i < items.length; i++) {
- boolean isExpanded= !fPreferenceStore.getBoolean(CONTEXT_COLLAPSE_PREF_ID
- + ((TemplateContextType) items[i].getData()).getId());
- if (isExpanded)
- fTreeViewer.expandToLevel(items[i].getData(), AbstractTreeViewer.ALL_LEVELS);
- else
- fTreeViewer.collapseToLevel(items[i].getData(), AbstractTreeViewer.ALL_LEVELS);
+ for (TreeItem item : items) {
+ boolean isExpanded = !fPreferenceStore.getBoolean(CONTEXT_COLLAPSE_PREF_ID + ((TemplateContextType) item.getData()).getId());
+ if (isExpanded) {
+ fTreeViewer.expandToLevel(item.getData(), AbstractTreeViewer.ALL_LEVELS);
+ } else {
+ fTreeViewer.collapseToLevel(item.getData(), AbstractTreeViewer.ALL_LEVELS);
+ }
}
} finally {
fTreeViewer.getTree().setRedraw(true);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
index 1583a795f..095b86076 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
@@ -329,8 +329,8 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
createLabel(composite, TemplatesMessages.EditTemplateDialog_context);
fContextCombo= new Combo(composite, SWT.READ_ONLY);
- for (int i= 0; i < fContextTypes.length; i++) {
- fContextCombo.add(fContextTypes[i][1]);
+ for (String[] fContextType : fContextTypes) {
+ fContextCombo.add(fContextType[1]);
}
fContextCombo.addModifyListener(listener);
@@ -406,9 +406,9 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private String getContextId() {
if (fContextCombo != null && !fContextCombo.isDisposed()) {
String name= fContextCombo.getText();
- for (int i= 0; i < fContextTypes.length; i++) {
- if (name.equals(fContextTypes[i][1])) {
- return fContextTypes[i][0];
+ for (String[] fContextType : fContextTypes) {
+ if (name.equals(fContextType[1])) {
+ return fContextType[0];
}
}
}
@@ -1027,9 +1027,10 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private TemplatePersistenceData[] getEnabledTemplates() {
List<TemplatePersistenceData> enabled= new ArrayList<>();
TemplatePersistenceData[] datas= fTemplateStore.getTemplateData(false);
- for (int i= 0; i < datas.length; i++) {
- if (datas[i].isEnabled())
- enabled.add(datas[i]);
+ for (TemplatePersistenceData data : datas) {
+ if (data.isEnabled()) {
+ enabled.add(data);
+ }
}
return enabled.toArray(new TemplatePersistenceData[enabled.size()]);
}
@@ -1235,8 +1236,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
if (file.exists()) {
try (InputStream input = new BufferedInputStream(new FileInputStream(file))) {
TemplatePersistenceData[] datas= reader.read(input, null);
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
+ for (TemplatePersistenceData data : datas) {
fTemplateStore.add(data);
String id= data.getId();
if (id == null) {

Back to the top