Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2017-01-06 10:57:50 +0000
committerAndrey Loskutov2017-01-09 17:31:08 +0000
commit9d16778daa14c3f2ccdcd395da0e60a672dad2e8 (patch)
tree9b2c927628a286d99bed1145edc8b6fd73fe2446
parent8bd133add6a5d20059d50a4304150a01cfb9d90f (diff)
downloadeclipse.platform.text-9d16778daa14c3f2ccdcd395da0e60a672dad2e8.tar.gz
eclipse.platform.text-9d16778daa14c3f2ccdcd395da0e60a672dad2e8.tar.xz
eclipse.platform.text-9d16778daa14c3f2ccdcd395da0e60a672dad2e8.zip
Bug 510030 - Add toString() to Line and TextSelectionI20170111-0200I20170110-2000I20170109-2000
Change-Id: Idc8d4bd0224d1a84932e02a9914bf1f59fe56580 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java25
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/Line.java5
2 files changed, 30 insertions, 0 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
index b29e1eae5eb..92e4fb0c896 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextSelection.java
@@ -123,6 +123,7 @@ public class TextSelection implements ITextSelection {
if (fDocument != null)
return fDocument.getLineOfOffset(fOffset);
} catch (BadLocationException x) {
+ // ignore
}
return -1;
@@ -138,6 +139,7 @@ public class TextSelection implements ITextSelection {
return fDocument.getLineOfOffset(endOffset);
}
} catch (BadLocationException x) {
+ // ignore
}
return -1;
@@ -149,6 +151,7 @@ public class TextSelection implements ITextSelection {
if (fDocument != null)
return fDocument.get(fOffset, fLength);
} catch (BadLocationException x) {
+ // ignore
}
return null;
@@ -176,6 +179,7 @@ public class TextSelection implements ITextSelection {
String content= fDocument.get(fOffset, fLength);
return sContent.equals(content);
} catch (BadLocationException x) {
+ // ignore
}
}
@@ -197,5 +201,26 @@ public class TextSelection implements ITextSelection {
protected IDocument getDocument() {
return fDocument;
}
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TextSelection [offset: ").append(fOffset); //$NON-NLS-1$
+ int startLine = getStartLine();
+ sb.append(", startLine: ").append(startLine); //$NON-NLS-1$
+ int endLine = getEndLine();
+ if (endLine != startLine) {
+ sb.append(", endLine: ").append(endLine); //$NON-NLS-1$
+ }
+ sb.append(", length: ").append(fLength); //$NON-NLS-1$
+ if (fLength != 0) {
+ sb.append(", text: ").append(getText()); //$NON-NLS-1$
+ }
+ if (fDocument != null) {
+ sb.append(", document: ").append(fDocument); //$NON-NLS-1$
+ }
+ sb.append("]"); //$NON-NLS-1$
+ return sb.toString();
+ }
}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/Line.java b/org.eclipse.text/src/org/eclipse/jface/text/Line.java
index 9e1dd7a4f0b..f219c0d720b 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/Line.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/Line.java
@@ -59,6 +59,11 @@ final class Line implements IRegion {
public int getLength() {
return length;
}
+
+ @Override
+ public String toString() {
+ return "Line [offset: " + offset + ", length: " + length + ", delimiter: '" + delimiter + "']"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
}

Back to the top