Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-11-30 19:23:22 +0000
committerMarkus Keller2015-12-01 12:59:16 +0000
commit96da92a20589d62dad534245c5d9c4d45618ee95 (patch)
treedb7f27dc0839db136db463ad28a7e763a6a07a91 /org.eclipse.text.tests
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip
Diffstat (limited to 'org.eclipse.text.tests')
-rw-r--r--org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java4
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java16
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelExtension2Test.java28
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java56
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java24
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java35
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java24
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedModeModelTest.java27
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java16
9 files changed, 114 insertions, 116 deletions
diff --git a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
index 314073d9094..e0a0e31583e 100644
--- a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
+++ b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
@@ -1576,7 +1576,7 @@ public class ProjectionDocumentTest extends TestCase {
public void test22() {
// test document events sent out by the slave document when adding segments
- final List receivedEvents= new ArrayList();
+ final List<DocumentEvent> receivedEvents= new ArrayList<>();
IDocumentListener listener= new IDocumentListener() {
@Override
@@ -1606,7 +1606,7 @@ public class ProjectionDocumentTest extends TestCase {
public void test23() {
// test document events sent out by the slave document when removing segments
- final List receivedEvents= new ArrayList();
+ final List<DocumentEvent> receivedEvents= new ArrayList<>();
IDocumentListener listener= new IDocumentListener() {
@Override
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
index 82e70551f8f..0290286ade7 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/Accessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
@@ -28,7 +28,7 @@ import org.eclipse.core.runtime.Assert;
public class Accessor {
/** The class to access. */
- private Class fClass;
+ private Class<?> fClass;
/** The instance to access. */
private Object fInstance;
@@ -40,7 +40,7 @@ public class Accessor {
* @param instance the instance
* @param clazz the class
*/
- public Accessor(Object instance, Class clazz) {
+ public Accessor(Object instance, Class<?> clazz) {
org.eclipse.core.runtime.Assert.isNotNull(instance);
Assert.isNotNull(clazz);
fInstance= instance;
@@ -94,7 +94,7 @@ public class Accessor {
* @param constructorTypes the types of the constructor arguments
* @param constructorArgs the constructor arguments
*/
- public Accessor(String className, ClassLoader classLoader, Class[] constructorTypes, Object[] constructorArgs) {
+ public Accessor(String className, ClassLoader classLoader, Class<?>[] constructorTypes, Object[] constructorArgs) {
try {
fClass= Class.forName(className, true, classLoader);
} catch (ClassNotFoundException e) {
@@ -102,7 +102,7 @@ public class Accessor {
} catch (ExceptionInInitializerError e) {
fail();
}
- Constructor constructor= null;
+ Constructor<?> constructor= null;
try {
constructor= fClass.getDeclaredConstructor(constructorTypes);
} catch (SecurityException e2) {
@@ -168,7 +168,7 @@ public class Accessor {
* @param arguments the method arguments
* @return the method return value
*/
- public Object invoke(String methodName, Class[] types, Object[] arguments) {
+ public Object invoke(String methodName, Class<?>[] types, Object[] arguments) {
Method method= null;
try {
method= fClass.getDeclaredMethod(methodName, types);
@@ -312,12 +312,12 @@ public class Accessor {
return field;
}
- private static Class[] getTypes(Object[] objects) {
+ private static Class<?>[] getTypes(Object[] objects) {
if (objects == null)
return null;
int length= objects.length;
- Class[] classes= new Class[length];
+ Class<?>[] classes= new Class[length];
for (int i= 0; i < length; i++) {
Assert.isNotNull(objects[i]);
classes[i]= objects[i].getClass();
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 764712c150b..c39b3f91a81 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -16,10 +16,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
@@ -28,6 +24,10 @@ import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelListener;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* Tests the {@link org.eclipse.jface.text.source.IAnnotationModelExtension2}.
@@ -38,7 +38,7 @@ public class AnnotationModelExtension2Test extends TestCase {
public class OldAnnotationModel implements IAnnotationModel {
- private final HashMap fAnnotations= new HashMap();
+ private final HashMap<Annotation, Position> fAnnotations= new HashMap<>();
@Override
public void addAnnotation(Annotation annotation, Position position) {
@@ -58,13 +58,13 @@ public class AnnotationModelExtension2Test extends TestCase {
}
@Override
- public Iterator getAnnotationIterator() {
+ public Iterator<Annotation> getAnnotationIterator() {
return fAnnotations.keySet().iterator();
}
@Override
public Position getPosition(Annotation annotation) {
- return (Position) fAnnotations.get(annotation);
+ return fAnnotations.get(annotation);
}
@Override
@@ -135,7 +135,7 @@ public class AnnotationModelExtension2Test extends TestCase {
}
private void assertEquals(Annotation[] expected, Annotation[] actual, IAnnotationModel insideModel, IAnnotationModel beforeModel, IAnnotationModel afterModel) {
- HashSet expectedSet= new HashSet(Arrays.asList(expected));
+ 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) + "]";
@@ -146,8 +146,8 @@ public class AnnotationModelExtension2Test extends TestCase {
if (!expectedSet.isEmpty()) {
String message= "Missing annotations in result with models [" + getAnnotationModelNames(insideModel, beforeModel, afterModel) + "]";
- for (Iterator iterator= expectedSet.iterator(); iterator.hasNext();) {
- Annotation missing= (Annotation) iterator.next();
+ for (Iterator<Annotation> iterator= expectedSet.iterator(); iterator.hasNext();) {
+ Annotation missing= iterator.next();
message= message + "\n" + getName(missing);
}
assertTrue(message, false);
@@ -210,14 +210,14 @@ public class AnnotationModelExtension2Test extends TestCase {
}
private Annotation[] getAnnotations(boolean lookAhead, boolean lookBehind) {
- Iterator iterator= fAnnotationModel.getAnnotationIterator(10, 11, lookAhead, lookBehind);
+ Iterator<Annotation> iterator= fAnnotationModel.getAnnotationIterator(10, 11, lookAhead, lookBehind);
- ArrayList result= new ArrayList();
+ ArrayList<Annotation> result= new ArrayList<>();
while (iterator.hasNext()) {
result.add(iterator.next());
}
- return (Annotation[]) result.toArray(new Annotation[result.size()]);
+ return result.toArray(new Annotation[result.size()]);
}
private void assertPermutations(boolean lookAhead, boolean lookBehind, Annotation[] expected) {
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
index 6926f671e90..4e5bca4b9d6 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 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
@@ -14,16 +14,16 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModel;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* @since 3.4
@@ -1253,8 +1253,8 @@ public class AnnotationModelStressTest extends TestCase {
return null;
}
- private void assertRemove(ArrayList added) {
- AnnotationData first= (AnnotationData) added.remove(0);
+ private void assertRemove(ArrayList<AnnotationData> added) {
+ AnnotationData first= added.remove(0);
IAnnotationModel model= getModel(first.annotationNumber);
assertTrue(model.getPosition(first.annotation) == first.position);
@@ -1262,7 +1262,7 @@ public class AnnotationModelStressTest extends TestCase {
assertTrue(model.getPosition(first.annotation) == null);
}
- private void assertAdd(AnnotationData data, ArrayList added) {
+ private void assertAdd(AnnotationData data, ArrayList<AnnotationData> added) {
Annotation annotation= new Annotation(false);
Position position= new Position(data.offset, data.length);
IAnnotationModel model= getModel(data.annotationNumber);
@@ -1276,18 +1276,18 @@ public class AnnotationModelStressTest extends TestCase {
added.add(data);
}
- private void assertExist(ArrayList added) {
+ private void assertExist(ArrayList<AnnotationData> added) {
for (int i= 0, size= added.size(); i < size; i++) {
- AnnotationData data= (AnnotationData) added.get(i);
+ AnnotationData data= added.get(i);
IAnnotationModel model= getModel(data.annotationNumber);
assertTrue(model.getPosition(data.annotation) == data.position);
}
- ArrayList annotations= getAllAnnotations();
+ ArrayList<Annotation> annotations= getAllAnnotations();
assertEquals(added.size(), annotations.size());
for (int i= 0, size= annotations.size(); i < size; i++) {
- Annotation annotation= (Annotation) annotations.get(i);
+ Annotation annotation= annotations.get(i);
AnnotationData data= getAnnotationData(added, annotation);
assertNotNull(data);
@@ -1296,18 +1296,18 @@ public class AnnotationModelStressTest extends TestCase {
}
}
- private void assertExistNew(ArrayList added) {
+ private void assertExistNew(ArrayList<AnnotationData> added) {
for (int i= 0, size= added.size(); i < size; i++) {
- AnnotationData data= (AnnotationData) added.get(i);
+ AnnotationData data= added.get(i);
IAnnotationModel model= getModel(data.annotationNumber);
assertTrue(model.getPosition(data.annotation) == data.position);
}
- ArrayList annotations= getAllAnnotationsNew();
+ ArrayList<Annotation> annotations= getAllAnnotationsNew();
assertEquals(added.size(), annotations.size());
for (int i= 0, size= annotations.size(); i < size; i++) {
- Annotation annotation= (Annotation) annotations.get(i);
+ Annotation annotation= annotations.get(i);
AnnotationData data= getAnnotationData(added, annotation);
assertNotNull(data);
@@ -1316,19 +1316,19 @@ public class AnnotationModelStressTest extends TestCase {
}
}
- private AnnotationData getAnnotationData(ArrayList datas, Annotation annotation) {
+ private AnnotationData getAnnotationData(ArrayList<AnnotationData> datas, Annotation annotation) {
for (int i= 0, size= datas.size(); i < size; i++) {
- AnnotationData data= (AnnotationData) datas.get(i);
+ AnnotationData data= datas.get(i);
if (data.annotation == annotation)
return data;
}
return null;
}
- private ArrayList getAllAnnotations() {
- ArrayList result= new ArrayList();
+ private ArrayList<Annotation> getAllAnnotations() {
+ ArrayList<Annotation> result= new ArrayList<>();
- Iterator iterator= fAnnotationModel.getAnnotationIterator();
+ Iterator<Annotation> iterator= fAnnotationModel.getAnnotationIterator();
while (iterator.hasNext()) {
result.add(iterator.next());
}
@@ -1336,10 +1336,10 @@ public class AnnotationModelStressTest extends TestCase {
return result;
}
- private ArrayList getAllAnnotationsNew() {
- ArrayList result= new ArrayList();
+ private ArrayList<Annotation> getAllAnnotationsNew() {
+ ArrayList<Annotation> result= new ArrayList<>();
- Iterator iterator= fAnnotationModel.getAnnotationIterator(0, fDocument.getLength(), true, true);
+ Iterator<Annotation> iterator= fAnnotationModel.getAnnotationIterator(0, fDocument.getLength(), true, true);
while (iterator.hasNext()) {
result.add(iterator.next());
}
@@ -1348,7 +1348,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestPlainOld() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
@@ -1378,7 +1378,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestPlainNew() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
@@ -1408,7 +1408,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestMoveOld() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
@@ -1442,7 +1442,7 @@ public class AnnotationModelStressTest extends TestCase {
}
public void testStressTestMoveNew() throws Exception {
- ArrayList added= new ArrayList();
+ ArrayList<AnnotationData> added= new ArrayList<>();
int i= 0;
while (i < 20) {
AnnotationData data= RANDOM_ANNOTATIONS[i];
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
index 47ed07ee7d9..40126d353fe 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
@@ -14,10 +14,6 @@ package org.eclipse.text.tests;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.DocumentEvent;
@@ -27,6 +23,10 @@ import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.projection.ChildDocument;
import org.eclipse.jface.text.projection.ChildDocumentManager;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class DocumentExtensionTest extends TestCase {
@@ -116,15 +116,15 @@ public class DocumentExtensionTest extends TestCase {
static class TestDocumentListener implements IDocumentListener {
private IDocument fDocument1;
- private List fTrace1;
+ private List<TestDocumentEvent> fTrace1;
private TestDocumentEvent fExpected1;
- private List fTrace2;
+ private List<TestDocumentEvent> fTrace2;
private TestDocumentEvent fExpected2;
private boolean fPopped= false;
- public TestDocumentListener(IDocument d1, List t1, List t2) {
+ public TestDocumentListener(IDocument d1, List<TestDocumentEvent> t1, List<TestDocumentEvent> t2) {
fDocument1= d1;
fTrace1= t1;
fTrace2= t2;
@@ -134,8 +134,8 @@ public class DocumentExtensionTest extends TestCase {
public void documentAboutToBeChanged(DocumentEvent received) {
if (!fPopped) {
fPopped= true;
- fExpected1= (TestDocumentEvent) fTrace1.remove(0);
- fExpected2= (TestDocumentEvent) fTrace2.remove(0);
+ fExpected1= fTrace1.remove(0);
+ fExpected2= fTrace2.remove(0);
}
TestDocumentEvent e= (received.getDocument() == fDocument1 ? fExpected1 : fExpected2);
@@ -252,9 +252,9 @@ public class DocumentExtensionTest extends TestCase {
assertTrue("axxxxxbxxxxxcxxxxx".equals(document.get()));
}
- private List createTrace(IDocument document, int repetitions) {
+ private List<TestDocumentEvent> createTrace(IDocument document, int repetitions) {
int i;
- List trace= new ArrayList();
+ List<TestDocumentEvent> trace= new ArrayList<>();
trace.add(new TestDocumentEvent(document, 0, 0, "c"));
for (i= 0; i < repetitions; i++)
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 c5c7b687ba6..16176538ce0 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
@@ -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
@@ -15,10 +15,6 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.text.edits.CopySourceEdit;
import org.eclipse.text.edits.CopyTargetEdit;
import org.eclipse.text.edits.DeleteEdit;
@@ -38,9 +34,13 @@ import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class TextEditTests extends TestCase {
- private static final Class THIS= TextEditTests.class;
+ private static final Class<TextEditTests> THIS= TextEditTests.class;
private IDocument fDocument;
private MultiTextEdit fRoot;
@@ -274,9 +274,9 @@ public class TextEditTests extends TestCase {
TextEdit e2= new ReplaceEdit(2, 3, "3456");
root.addChild(e1);
root.addChild(e2);
- List org= flatten(root);
+ List<TextEdit> org= flatten(root);
TextEditCopier copier= new TextEditCopier(root);
- List copy= flatten(copier.perform());
+ List<TextEdit> copy= flatten(copier.perform());
compare(org, copy);
}
@@ -290,19 +290,19 @@ public class TextEditTests extends TestCase {
root.addChild(s1);
root.addChild(t1);
root.addChild(t2);
- List org= flatten(root);
+ List<TextEdit> org= flatten(root);
TextEditCopier copier= new TextEditCopier(root);
- List copy= flatten(copier.perform());
+ List<TextEdit> copy= flatten(copier.perform());
compare(org, copy);
}
- private List flatten(TextEdit edit) {
- List result= new ArrayList();
+ private List<TextEdit> flatten(TextEdit edit) {
+ List<TextEdit> result= new ArrayList<>();
flatten(result, edit);
return result;
}
- private static void flatten(List result, TextEdit edit) {
+ private static void flatten(List<TextEdit> result, TextEdit edit) {
result.add(edit);
TextEdit[] children= edit.getChildren();
for (int i= 0; i < children.length; i++) {
@@ -310,10 +310,10 @@ public class TextEditTests extends TestCase {
}
}
- private static void compare(List org, List copy) {
+ private static void compare(List<TextEdit> org, List<TextEdit> copy) {
assertTrue("Same length", org.size() == copy.size());
- for (Iterator iter= copy.iterator(); iter.hasNext();) {
- TextEdit edit= (TextEdit)iter.next();
+ for (Iterator<TextEdit> iter= copy.iterator(); iter.hasNext();) {
+ TextEdit edit= iter.next();
assertTrue("Original is part of copy list", !org.contains(edit));
if (edit instanceof MoveSourceEdit) {
MoveSourceEdit source= (MoveSourceEdit)edit;
@@ -1206,7 +1206,8 @@ public class TextEditTests extends TestCase {
public void testComparator() throws Exception {
DeleteEdit d1= new DeleteEdit(1,3);
Accessor accessor= new Accessor(d1, TextEdit.class);
- Comparator comparator= (Comparator)accessor.get("INSERTION_COMPARATOR");
+ @SuppressWarnings("unchecked")
+ Comparator<TextEdit> comparator= (Comparator<TextEdit>)accessor.get("INSERTION_COMPARATOR");
TextEdit edit1= new InsertEdit(1, "test");
TextEdit edit2= new InsertEdit(1, "test");
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java
index 9bddfec24a4..e8390adf42d 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextUtilitiesTest.java
@@ -56,7 +56,7 @@ public class TextUtilitiesTest extends TestCase {
private final DocumentListener fDocumentListener= new DocumentListener();
/** The buffered events. */
- private final List fEvents= new ArrayList();
+ private final List<DocumentEvent> fEvents= new ArrayList<>();
public LazilyMirroredDocument(IDocument document) {
document.addDocumentListener(fDocumentListener);
@@ -107,7 +107,7 @@ public class TextUtilitiesTest extends TestCase {
private final DocumentListener fDocumentListener= new DocumentListener();
/** The buffered events. */
- private final List fEvents= new ArrayList();
+ private final List<DocumentEvent> fEvents= new ArrayList<>();
public LazilyMirroredDocument2(IDocument document) {
document.addDocumentListener(fDocumentListener);
@@ -187,7 +187,7 @@ public class TextUtilitiesTest extends TestCase {
try {
- List events= new ArrayList();
+ List<DocumentEvent> events= new ArrayList<>();
int currentLength= 0;
events.add(new DocumentEvent(reference, 0, 0, "foo bar goo haa"));
@@ -198,8 +198,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(new DocumentEvent(reference, 9, 2, "asd"));
events.add(new DocumentEvent(reference, 0, 2, "asd"));
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
currentLength += event.getText().length() - event.getLength();
}
@@ -210,8 +210,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(event);
}
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
// System.err.println(event.getOffset() + ", " + event.getLength() + ", [" + event.getText() + "]") ;
@@ -239,7 +239,7 @@ public class TextUtilitiesTest extends TestCase {
try {
- List events= new ArrayList();
+ List<DocumentEvent> events= new ArrayList<>();
int currentLength= 0;
events.add(new DocumentEvent(reference, 0, 0, "foo bar goo haa"));
@@ -250,8 +250,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(new DocumentEvent(reference, 9, 2, "asd"));
events.add(new DocumentEvent(reference, 0, 2, "asd"));
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
currentLength += event.getText().length() - event.getLength();
}
@@ -262,8 +262,8 @@ public class TextUtilitiesTest extends TestCase {
events.add(event);
}
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
+ for (Iterator<DocumentEvent> iterator= events.iterator(); iterator.hasNext();) {
+ DocumentEvent event= iterator.next();
reference.replace(event.getOffset(), event.getLength(), event.getText());
if (Math.random() < 0.3) {
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 eb145a344b0..6914890ac05 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 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
@@ -17,8 +17,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -27,12 +25,14 @@ import org.eclipse.jface.text.link.LinkedModeModel;
import org.eclipse.jface.text.link.LinkedPosition;
import org.eclipse.jface.text.link.LinkedPositionGroup;
+import junit.framework.TestCase;
+
public class LinkedModeModelTest extends TestCase {
- private List fPositions= new LinkedList();
+ private List<LinkedPosition> fPositions= new LinkedList<>();
- private List fDocumentMap= new ArrayList();
+ private List<IDocument[]> fDocumentMap= new ArrayList<>();
public void testUpdate() throws BadLocationException {
IDocument doc1= new Document(GARTEN1);
@@ -541,7 +541,7 @@ public class LinkedModeModelTest extends TestCase {
}
private void assertUnchanged(LinkedPositionGroup actual1, LinkedPositionGroup actual2) throws BadLocationException {
- LinkedPosition[] exp= (LinkedPosition[]) fPositions.toArray(new LinkedPosition[0]);
+ LinkedPosition[] exp= fPositions.toArray(new LinkedPosition[0]);
LinkedPosition[] act1= actual1.getPositions();
LinkedPosition[] act2= actual2.getPositions();
LinkedPosition[] act= new LinkedPosition[act1.length + act2.length];
@@ -620,8 +620,8 @@ public class LinkedModeModelTest extends TestCase {
}
private IDocument getOriginal(IDocument doc) {
- for (Iterator it = fDocumentMap.iterator(); it.hasNext(); ) {
- IDocument[] docs = (IDocument[]) it.next();
+ for (Iterator<IDocument[]> it = fDocumentMap.iterator(); it.hasNext(); ) {
+ IDocument[] docs = it.next();
if (docs[0] == doc)
return docs[1];
}
@@ -814,13 +814,10 @@ public class LinkedModeModelTest extends TestCase {
public void resume(LinkedModeModel environment, int flags) {}
}
- public class PositionComparator implements Comparator {
+ public class PositionComparator implements Comparator<LinkedPosition> {
@Override
- public int compare(Object o1, Object o2) {
- LinkedPosition p1= (LinkedPosition) o1;
- LinkedPosition p2= (LinkedPosition) o2;
-
+ public int compare(LinkedPosition p1, LinkedPosition p2) {
IDocument d1= p1.getDocument();
IDocument d2= p2.getDocument();
@@ -832,8 +829,8 @@ public class LinkedModeModelTest extends TestCase {
private int getIndex(IDocument doc) {
int i= 0;
- for (Iterator it= fDocumentMap.iterator(); it.hasNext(); i++) {
- IDocument[] docs= (IDocument[]) it.next();
+ for (Iterator<IDocument[]> it= fDocumentMap.iterator(); it.hasNext(); i++) {
+ IDocument[] docs= it.next();
if (docs[0] == doc || docs[1] == doc)
return i;
}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java
index 7ded6114746..494e3f1c26a 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/templates/TemplateTranslatorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -15,15 +15,15 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.templates.TemplateBuffer;
import org.eclipse.jface.text.templates.TemplateException;
import org.eclipse.jface.text.templates.TemplateTranslator;
import org.eclipse.jface.text.templates.TemplateVariable;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
/**
* @since 3.3
*/
@@ -287,7 +287,7 @@ public class TemplateTranslatorTest extends TestCase {
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("type", vars[0].getType());
- List params= new ArrayList(2);
+ List<String> params= new ArrayList<>(2);
params.add("param1");
params.add("param2");
params.add("param3");
@@ -309,7 +309,7 @@ public class TemplateTranslatorTest extends TestCase {
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("qual.type", vars[0].getType());
- List params= new ArrayList(2);
+ List<String> params= new ArrayList<>(2);
params.add("qual.param1");
params.add("qual.param2");
assertEquals(params, vars[0].getVariableType().getParams());
@@ -330,7 +330,7 @@ public class TemplateTranslatorTest extends TestCase {
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("qual.type", vars[0].getType());
- List params= new ArrayList(3);
+ List<String> params= new ArrayList<>(3);
params.add("a parameter 1");
params.add("qual.param2");
params.add("a parameter '3");

Back to the top