Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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