/*******************************************************************************
 * Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.formatting2.regionaccess.internal;

import org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess;

import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;

/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
public class TextSegment extends AbstractTextSegment {

	private final int length;
	private final int offset;
	private final ITextRegionAccess regionAccess;

	public TextSegment(ITextRegionAccess regionAccess, int offset, int length) {
		super();
		this.regionAccess = regionAccess;
		this.offset = offset;
		this.length = length;
	}

	@Override
	public int getLength() {
		return length;
	}

	@Override
	public int getOffset() {
		return offset;
	}

	@Override
	public ITextRegionAccess getTextRegionAccess() {
		return regionAccess;
	}

	@Override
	public String toString() {
		ToStringHelper helper = MoreObjects.toStringHelper(this).add("offset", offset).add("length", length);
		if (regionAccess != null)
			helper.add("text", getText());
		return helper.toString();
	}

}

@@ -604,93 +604,47 @@
 ss;%0A
-%0A
 import 
-com.google.common.base.MoreObjects;%0Aimport com.google.common.base.MoreObjects
+org.eclipse.xtext.xbase.lib.util
 .ToS
@@ -648,20 +648,21 @@
 ToString
-Help
+Build
 er;%0A%0A/**
@@ -1316,48 +1316,43 @@
 ring
-Helper helper = MoreObjects.t
+Builder builder = new T
 oString
-Help
+Build
 er(t
@@ -1356,16 +1356,29 @@
 r(this).
+singleLine().
 add(%22off
@@ -1445,20 +1445,21 @@
 ull)%0A%09%09%09
-help
+build
 er.add(%22
@@ -1490,12 +1490,13 @@
 urn 
-help
+build
 er.t

Use ToStringBuilder for toString