diff options
author | Markus Keller | 2015-11-30 19:23:22 +0000 |
---|---|---|
committer | Markus Keller | 2015-12-01 12:59:16 +0000 |
commit | 96da92a20589d62dad534245c5d9c4d45618ee95 (patch) | |
tree | db7f27dc0839db136db463ad28a7e763a6a07a91 /org.eclipse.search.tests | |
parent | 0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff) | |
download | eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip |
Bug 478673: generify codeI20151201-1100I20151201-0800
Diffstat (limited to 'org.eclipse.search.tests')
5 files changed, 25 insertions, 26 deletions
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java index b227e8dafa1..160ac8fe930 100644 --- a/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java +++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/FileTool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,11 +50,11 @@ public class FileTool { * @throws IOException in case of problem */ public static void unzip(ZipFile zipFile, File dstDir) throws IOException { - Enumeration entries = zipFile.entries(); + Enumeration<? extends ZipEntry> entries = zipFile.entries(); try { while(entries.hasMoreElements()){ - ZipEntry entry = (ZipEntry)entries.nextElement(); + ZipEntry entry = entries.nextElement(); if(entry.isDirectory()){ continue; } 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 e7e8856a337..1c98bdb66f5 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 @@ -97,9 +97,9 @@ public class AnnotationManagerTest extends TestCase { ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file); IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); annotationModel.getAnnotationIterator(); - HashSet positions= new HashSet(); - for (Iterator iter= annotationModel.getAnnotationIterator(); iter.hasNext();) { - Annotation annotation= (Annotation) iter.next(); + HashSet<Position> positions= new HashSet<>(); + for (Iterator<Annotation> iter= annotationModel.getAnnotationIterator(); iter.hasNext();) { + Annotation annotation= iter.next(); if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) { positions.add(annotationModel.getPosition(annotation)); } @@ -138,8 +138,8 @@ public class AnnotationManagerTest extends TestCase { ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file); IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); int annotationCount= 0; - for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) { - Annotation annotation= (Annotation) annotations.next(); + for (Iterator<Annotation> annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) { + Annotation annotation= annotations.next(); if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) { annotationCount++; } @@ -164,8 +164,8 @@ public class AnnotationManagerTest extends TestCase { IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); int annotationCount= 0; IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); - for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) { - Annotation annotation= (Annotation) annotations.next(); + for (Iterator<Annotation> annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) { + Annotation annotation= annotations.next(); if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) { Position p= annotationModel.getPosition(annotation); String text= document.get(p.getOffset(), p.getLength()); @@ -192,8 +192,8 @@ public class AnnotationManagerTest extends TestCase { IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); int annotationCount= 0; IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); - for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) { - Annotation annotation= (Annotation) annotations.next(); + for (Iterator<Annotation> annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) { + Annotation annotation= annotations.next(); if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) { Position p= annotationModel.getPosition(annotation); String text= document.get(p.getOffset(), p.getLength()); 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 097516acecd..86e76d62b84 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 @@ -55,14 +55,14 @@ public class FileSearchTests extends TestCase { private static class TestResultCollector extends TextSearchRequestor { - protected List fResult; + protected List<TestResult> fResult; public TestResultCollector() { reset(); } public TestResult[] getResults() { - return (TestResult[]) fResult.toArray(new TestResult[fResult.size()]); + return fResult.toArray(new TestResult[fResult.size()]); } public int getNumberOfResults() { @@ -70,7 +70,7 @@ public class FileSearchTests extends TestCase { } public void reset() { - fResult= new ArrayList(); + fResult= new ArrayList<>(); } } 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 efc1708dea6..78896fe4e31 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 @@ -94,9 +94,9 @@ public class LineAnnotationManagerTest extends TestCase { IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); annotationModel.getAnnotationIterator(); - ArrayList positions= new ArrayList(); - for (Iterator iter= annotationModel.getAnnotationIterator(); iter.hasNext();) { - Annotation annotation= (Annotation) iter.next(); + ArrayList<Position> positions= new ArrayList<>(); + for (Iterator<Annotation> iter= annotationModel.getAnnotationIterator(); iter.hasNext();) { + Annotation annotation= iter.next(); if (annotation.getType().equals(fAnnotationTypeLookup.getAnnotationType(NewSearchUI.SEARCH_MARKER, IMarker.SEVERITY_INFO))) { positions.add(annotationModel.getPosition(annotation)); } 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 7595720a65b..c45cd30b6f4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,16 +13,15 @@ package org.eclipse.search.tests.filesearch; import java.util.ArrayList; import java.util.List; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - +import org.eclipse.search.internal.ui.text.FileSearchQuery; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.search.ui.text.FileTextSearchScope; import org.eclipse.search.ui.text.Match; -import org.eclipse.search.internal.ui.text.FileSearchQuery; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; public class SortingTest extends TestCase { FileSearchQuery fQuery1; @@ -58,7 +57,7 @@ public class SortingTest extends TestCase { NewSearchUI.runQueryInForeground(null, fQuery1); AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult(); int originalMatchCount= result.getMatchCount(); - List allMatches= new ArrayList(originalMatchCount); + List<Match> allMatches= new ArrayList<>(originalMatchCount); // first, collect all matches Object[] elements= result.getElements(); @@ -73,7 +72,7 @@ public class SortingTest extends TestCase { assertTrue("removed all matches", result.getMatchCount() == 0); for (int i= allMatches.size()-1; i >= 0; i--) { - result.addMatch((Match) allMatches.get(i)); + result.addMatch(allMatches.get(i)); } assertEquals("Test that all matches have been added again", result.getMatchCount(), originalMatchCount); |