Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-11-30 14:23:22 -0500
committerMarkus Keller2015-12-01 07:59:16 -0500
commit96da92a20589d62dad534245c5d9c4d45618ee95 (patch)
treedb7f27dc0839db136db463ad28a7e763a6a07a91 /org.eclipse.jface.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.jface.text.tests')
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java24
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java12
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java10
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java51
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java12
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java12
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java4
7 files changed, 55 insertions, 70 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java
index 6108c2240..0a6a828a6 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/AbstractPairMatcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 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
@@ -13,8 +13,6 @@ package org.eclipse.jface.text.tests;
import java.util.ArrayList;
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;
@@ -31,6 +29,8 @@ import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
import org.eclipse.jface.text.source.ICharacterPairMatcherExtension;
+import junit.framework.TestCase;
+
/**
* Generic test of simple character pair matchers
*
@@ -74,7 +74,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Very simple checks.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testSimpleMatchSameMatcher() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -106,7 +106,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Very simple checks.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testSimpleMatchDifferentMatchers() throws BadLocationException {
performMatch("()[]{}", "#( )%");
@@ -124,7 +124,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Close matches.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testCloseMatches() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -151,7 +151,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Checks of simple situations where no matches should be found.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testIncompleteMatch() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -164,7 +164,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Test that it doesn't match across different partitions.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testPartitioned() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -201,7 +201,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Test that it works properly next to partition boundaries.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testTightPartitioned() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -255,7 +255,7 @@ public abstract class AbstractPairMatcherTest extends TestCase {
/**
* Test a few boundary conditions.
*
- * * @throws BadLocationException
+ * * @throws BadLocationException test failure
*/
public void testBoundaries() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -519,11 +519,11 @@ public abstract class AbstractPairMatcherTest extends TestCase {
private static IDocumentPartitioner createPartitioner() {
final RuleBasedPartitionScanner scan= new RuleBasedPartitionScanner();
- final List/*<IPredicateRule>*/ rules= new ArrayList/*<IPredicateRule>*/();
+ final List<SingleLineRule> rules= new ArrayList<>();
rules.add(new SingleLineRule("|a", "a|", new Token("a")));
rules.add(new SingleLineRule("|b", "b|", new Token("b")));
rules.add(new SingleLineRule("|c", "c|", new Token("c")));
- scan.setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
+ scan.setPredicateRules(rules.toArray(new IPredicateRule[rules.size()]));
scan.setDefaultReturnToken(new Token(DEFAULT_PARTITION));
return new FastPartitioner(scan, new String[] { DEFAULT_PARTITION, "a", "b", "c" });
}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java
index bac928e01..cd53ca47e 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 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
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.jface.text.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* Tests for the default pair matcher.
@@ -42,7 +42,7 @@ public class DefaultPairMatcherTest extends AbstractPairMatcherTest {
/**
* Close matches.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testCloseMatches1() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
@@ -55,7 +55,7 @@ public class DefaultPairMatcherTest extends AbstractPairMatcherTest {
/**
* Checks of simple situations where no matches should be found.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testIncompleteMatch1() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java
index 56f3d985c..30f6a16cc 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultPairMatcherTest2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012, 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
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.jface.text.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
/**
* Tests for the default pair matcher.
@@ -42,7 +42,7 @@ public class DefaultPairMatcherTest2 extends AbstractPairMatcherTest {
/**
* Very simple checks.
*
- * @throws BadLocationException
+ * @throws BadLocationException test failure
*/
public void testSimpleMatchSameMatcher1() throws BadLocationException {
final ICharacterPairMatcher matcher= createMatcher("()[]{}");
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
index 2c9fc3da7..60f8e0dbc 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
@@ -16,14 +16,9 @@ import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-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.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
@@ -31,6 +26,10 @@ import org.eclipse.jface.internal.text.html.HTML2TextReader;
import org.eclipse.jface.text.TextPresentation;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class HTML2TextReaderTest extends TestCase {
@@ -47,10 +46,10 @@ public class HTML2TextReaderTest extends TestCase {
}
/**
- * @param input
- * @param expectedOutput
- * @param styleRangeCount
- * @throws IOException
+ * @param input input
+ * @param expectedOutput expected output
+ * @param styleRangeCount count
+ * @throws IOException test failure
* @deprecated pass actual style ranges
*/
@Deprecated
@@ -63,26 +62,19 @@ public class HTML2TextReaderTest extends TestCase {
System.out.println("<" + result + "/>");
assertEquals(expectedOutput, result);
- Iterator styleRangeIterator= textPresentation.getAllStyleRangeIterator();
- List ranges= new ArrayList();
+ Iterator<StyleRange> styleRangeIterator= textPresentation.getAllStyleRangeIterator();
+ List<StyleRange> ranges= new ArrayList<>();
while (styleRangeIterator.hasNext()) {
ranges.add(styleRangeIterator.next());
}
assertEquals("Incorrect number of style ranges", styleRangeCount, ranges.size());
- Collections.sort(ranges, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- StyleRange range1= (StyleRange)o1;
- StyleRange range2= (StyleRange)o2;
- return range1.start - range2.start;
- }
- });
+ Collections.sort(ranges, (r1, r2) -> r1.start - r2.start);
for (int i= 0; i < ranges.size() - 1; i++) {
- StyleRange range1= (StyleRange)ranges.get(i);
- StyleRange range2= (StyleRange)ranges.get(i + 1);
+ StyleRange range1= ranges.get(i);
+ StyleRange range2= ranges.get(i + 1);
if (range1.start + range1.length > range2.start) {
assertTrue("StyleRanges overlap", false);
@@ -100,26 +92,19 @@ public class HTML2TextReaderTest extends TestCase {
System.out.println("<" + result + "/>");
assertEquals(expectedOutput, result);
- Iterator styleRangeIterator= textPresentation.getAllStyleRangeIterator();
- List ranges= new ArrayList();
+ Iterator<StyleRange> styleRangeIterator= textPresentation.getAllStyleRangeIterator();
+ List<StyleRange> ranges= new ArrayList<>();
while (styleRangeIterator.hasNext()) {
ranges.add(styleRangeIterator.next());
}
- Collections.sort(ranges, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- StyleRange range1= (StyleRange)o1;
- StyleRange range2= (StyleRange)o2;
- return range1.start - range2.start;
- }
- });
+ Collections.sort(ranges, (r1, r2) -> r1.start - r2.start);
assertEquals(Arrays.asList(styleRanges), ranges);
for (int i= 0; i < ranges.size() - 1; i++) {
- StyleRange range1= (StyleRange)ranges.get(i);
- StyleRange range2= (StyleRange)ranges.get(i + 1);
+ StyleRange range1= ranges.get(i);
+ StyleRange range2= ranges.get(i + 1);
if (range1.start + range1.length > range2.start) {
assertTrue("StyleRanges overlap", false);
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
index 7a1bc8022..7e4bfb6b3 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
@@ -51,8 +51,8 @@ public class TestTextViewer implements ISourceViewer, IDocumentListener {
protected IDocument fDocument;
- protected List fInputListeners= new ArrayList();
- protected List fTextListeners= new ArrayList();
+ protected List<ITextInputListener> fInputListeners= new ArrayList<>();
+ protected List<ITextListener> fTextListeners= new ArrayList<>();
protected TextPresentation fTextPresentation;
protected Point fSelection= new Point(-1, -1);
protected String fDeletion;
@@ -112,9 +112,9 @@ public class TestTextViewer implements ISourceViewer, IDocumentListener {
}
protected void fireTextInputChanged(IDocument oldDoc, IDocument newDoc, boolean about) {
- Iterator e= new ArrayList(fInputListeners).iterator();
+ Iterator<ITextInputListener> e= new ArrayList<>(fInputListeners).iterator();
while (e.hasNext()) {
- ITextInputListener l= (ITextInputListener) e.next();
+ ITextInputListener l= e.next();
if (about)
l.inputDocumentAboutToBeChanged(oldDoc, newDoc);
else
@@ -377,9 +377,9 @@ public class TestTextViewer implements ISourceViewer, IDocumentListener {
}
protected void fireTextChanged(TextEvent event) {
- Iterator e= new ArrayList(fTextListeners).iterator();
+ Iterator<ITextListener> e= new ArrayList<>(fTextListeners).iterator();
while (e.hasNext()) {
- ITextListener l= (ITextListener) e.next();
+ ITextListener l= e.next();
l.textChanged(event);
}
}
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 665b53abc..3572129f1 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
@@ -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
@@ -12,10 +12,6 @@ package org.eclipse.jface.text.tests;
import java.util.Iterator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
@@ -24,6 +20,10 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextPresentation;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class TextPresentationTest extends TestCase {
private static final int NORMAL= SWT.NORMAL;
@@ -98,7 +98,7 @@ public class TextPresentationTest extends TestCase {
}
private void checkRegions(StyleRange[] expectedAllRanges, StyleRange[] expectedNonDefaultRanges) {
- Iterator e= fTextPresentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> e= fTextPresentation.getAllStyleRangeIterator();
for (int i= 0; i < expectedAllRanges.length; i++) {
assertTrue(e.hasNext());
assertEquals(expectedAllRanges[i], e.next());
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java
index ee4fddf83..1a7471580 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/reconciler/AbstractReconcilerTest.java
@@ -127,7 +127,7 @@ public class AbstractReconcilerTest extends TestCase {
private Accessor fAccessor;
private Barrier fBarrier;
- private List fCallLog;
+ private List<String> fCallLog;
private ITextViewer fViewer;
protected AbstractReconciler fReconciler;
private Document fDocument;
@@ -138,7 +138,7 @@ public class AbstractReconcilerTest extends TestCase {
@Override
protected void setUp() {
fBarrier= new Barrier();
- fCallLog= Collections.synchronizedList(new ArrayList());
+ fCallLog= Collections.synchronizedList(new ArrayList<String>());
fReconciler= new AbstractReconciler() {
@Override
protected void initialProcess() {

Back to the top