From 268a8118587d2717dfdd3e70b110ac4971950edd Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 17 Jun 2015 19:28:14 +0300 Subject: [PATCH] toString(): add "..." at the end if something left out --- .../util/src/com/intellij/util/containers/JBIterable.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/util/containers/JBIterable.java b/platform/util/src/com/intellij/util/containers/JBIterable.java index 387b0ea117f4..69e3db0eef7b 100644 --- a/platform/util/src/com/intellij/util/containers/JBIterable.java +++ b/platform/util/src/com/intellij/util/containers/JBIterable.java @@ -145,12 +145,14 @@ public abstract class JBIterable implements Iterable { } /** - * Returns a string representation of this fluent iterable, with the format - * {@code [e1, e2, ..., en]}. + * Returns a string representation of this iterable up to 50 elements, with the format + * {@code (e1, e2, ..., en [, ...] )} for debugging purposes. */ @Override public String toString() { - return "(" + StringUtil.join(take(50), ", ") + ")"; + int max = 50; + List list = take(max + 1).toList(); + return "(" + StringUtil.join(list.subList(0, Math.min(list.size(), max)), ", ") + (list.size() > max ? ", ..." : "") + ")"; } /**