Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-01-24 07:28:41 -0500
committerPaul Pazderski2019-03-21 03:47:24 -0400
commitc8bdcaea824cc6e3a7a2018377f783ad1cef9f8a (patch)
tree32637e5b602914077cd5b3f4bdc7d6921b4425b1
parent3bd4ffcd132a3cb98537a048278926356fbf5943 (diff)
downloadeclipse.platform.swt-c8bdcaea824cc6e3a7a2018377f783ad1cef9f8a.tar.gz
eclipse.platform.swt-c8bdcaea824cc6e3a7a2018377f783ad1cef9f8a.tar.xz
eclipse.platform.swt-c8bdcaea824cc6e3a7a2018377f783ad1cef9f8a.zip
Bug 545528 - JavaDoc for StyledTextContent#getLineAtOffset(int) is
contradictory JavaDoc defines getLineAtOffset(getLength()) should return number of lines. This contradicts the example in same JavaDoc which claims getLineAtOffset(4) == 2 (and the examples length is 4) but getLineCount returns 3. Changed JavaDoc to define getLineAtOffset(getLength()) as index of last line since this matches implementation of DefaultContent and most (or all?) other implementations. Change-Id: I9cdd96177ad8c47f30fe248ba1813c3be5a48417 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
index e738edd544..72a12b0ac2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 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
@@ -53,6 +53,18 @@ public int getCharCount();
* delimiters of preceding lines. Index 0 is the first line of the
* content.
* @return the line text without delimiters
+ * For example, if text = "\r\n\r\n", and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getLine(0) == ""
+ * <li>getLine(1) == ""
+ * <li>getLine(2) == ""
+ * </ul>
+ * or if text = "A\nBC\nD", and delimiter = "\n", then:
+ * <ul>
+ * <li>getLine(0) == "A"
+ * <li>getLine(1) == "BC"
+ * <li>getLine(2) == "D"
+ * </ul>
*/
public String getLine(int lineIndex);
@@ -61,8 +73,8 @@ public String getLine(int lineIndex);
* <p>
*
* @param offset offset of the line to return. The first character of the
- * document is at offset 0. An offset of getLength() is valid and should
- * answer the number of lines.
+ * document is at offset 0. An offset of {@link #getCharCount()} is valid
+ * and should answer the line index of the last line.
* @return the line index. The first line is at index 0. If the character
* at offset is a delimiter character, answer the line index of the line
* that is delimited.
@@ -74,6 +86,16 @@ public String getLine(int lineIndex);
* <li>getLineAtOffset(3) == 1
* <li>getLineAtOffset(4) == 2
* </ul>
+ * or if text = "A\nBC\nD", and delimiter = "\n", then:
+ * <ul>
+ * <li>getLineAtOffset(0) == 0
+ * <li>getLineAtOffset(1) == 0
+ * <li>getLineAtOffset(2) == 1
+ * <li>getLineAtOffset(3) == 1
+ * <li>getLineAtOffset(4) == 1
+ * <li>getLineAtOffset(5) == 2
+ * <li>getLineAtOffset(6) == 2
+ * </ul>
*/
public int getLineAtOffset(int offset);

Back to the top