Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-03-19 21:36:41 +0000
committerPaul Pazderski2019-03-20 07:24:33 +0000
commit8c56c63ef93e93d8ed5d40f07ea107a4e7a02196 (patch)
tree9f9def010387c7fccb80a59dfa363cc8ce29203b
parenta2bd5dd03d3f147f3577f01d5dcc4af083289a4a (diff)
downloadeclipse.platform.text-8c56c63ef93e93d8ed5d40f07ea107a4e7a02196.tar.gz
eclipse.platform.text-8c56c63ef93e93d8ed5d40f07ea107a4e7a02196.tar.xz
eclipse.platform.text-8c56c63ef93e93d8ed5d40f07ea107a4e7a02196.zip
Bug 545565 - ListLineTracker returns wrong results after content set toI20190321-1800I20190321-0435I20190321-0245I20190320-1800
null If tracked text is set to null the tracked content length was not updated. Change-Id: I26ed7b21879ff77a1e3b7828a4e4a4d969608cb8 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--org.eclipse.text.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.text.tests/pom.xml2
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java61
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/ListLineTracker.java4
4 files changed, 65 insertions, 4 deletions
diff --git a/org.eclipse.text.tests/META-INF/MANIFEST.MF b/org.eclipse.text.tests/META-INF/MANIFEST.MF
index 90484921d0d..ae8dbd8173f 100644
--- a/org.eclipse.text.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.text.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.text.tests
-Bundle-Version: 3.12.100.qualifier
+Bundle-Version: 3.12.200.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
diff --git a/org.eclipse.text.tests/pom.xml b/org.eclipse.text.tests/pom.xml
index 4c70468ceb5..bbfd947e687 100644
--- a/org.eclipse.text.tests/pom.xml
+++ b/org.eclipse.text.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.text</groupId>
<artifactId>org.eclipse.text.tests</artifactId>
- <version>3.12.100-SNAPSHOT</version>
+ <version>3.12.200-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java
index aabd126d336..17d388f266b 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -544,4 +544,63 @@ public class LineTrackerTest3 extends AbstractLineTrackerTest {
} catch (BadLocationException e) {
}
}
+
+ /**
+ * Test for Bug 545565. Some ListLineTracker methods yield wrong results after tracker content
+ * was set to <code>null</code>.
+ *
+ * @throws BadLocationException if test failed
+ */
+ @Test
+ public void testBug545565_setNull() throws BadLocationException {
+ int initialContentLength= fText.getLength();
+ set(null);
+ assertEquals("Tracker not empty.", 1, fTracker.getNumberOfLines());
+ assertEquals("Tracker not empty.", 0, fTracker.getLineLength(0));
+ try {
+ fTracker.getLineInformationOfOffset(5);
+ fail("No exception for bad location.");
+ } catch (BadLocationException e) {
+ // expected
+ }
+ try {
+ fTracker.getLineInformationOfOffset(initialContentLength);
+ fail("No exception for bad location.");
+ } catch (BadLocationException e) {
+ // expected
+ }
+ try {
+ fTracker.getLineNumberOfOffset(5);
+ fail("No exception for bad location.");
+ } catch (BadLocationException e) {
+ // expected
+ }
+ try {
+ fTracker.getLineNumberOfOffset(initialContentLength);
+ fail("No exception for bad location.");
+ } catch (BadLocationException e) {
+ // expected
+ }
+ try {
+ fTracker.getNumberOfLines(5, 3);
+ fail("No exception for bad location.");
+ } catch (BadLocationException e) {
+ // expected
+ }
+ }
+
+ /**
+ * Check if ListLineTracker and TreeLineTracker return same result for same input in context of
+ * Bug 545565.
+ *
+ * @throws BadLocationException if test fails
+ */
+ @Test
+ public void testBug545565_compareTrackerResult() throws BadLocationException {
+ set(null);
+ int lineFromListTracker= fTracker.getLineNumberOfOffset(0);
+ replace(0, 0, null);
+ int lineFromTreeTracker= fTracker.getLineNumberOfOffset(0);
+ assertEquals("Trackers returned different lines for same offset.", lineFromTreeTracker, lineFromListTracker);
+ }
}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ListLineTracker.java b/org.eclipse.text/src/org/eclipse/jface/text/ListLineTracker.java
index a82c20b43d8..56c7edee972 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/ListLineTracker.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/ListLineTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -330,6 +330,8 @@ abstract class ListLineTracker implements ILineTracker {
if (text != null) {
fTextLength= text.length();
createLines(text, 0, 0);
+ } else {
+ fTextLength= 0;
}
}

Back to the top