From 30e62ab83a5418bf5982147f3bd6f3f0a7ec5f52 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Fri, 5 Nov 2004 23:23:08 +0000 Subject: [PATCH] Change to CodeFormat interface --- .../cdt/internal/corext/util/CodeFormatterUtil.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java index a19d903850e..f2b173b49af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java @@ -20,7 +20,6 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultPositionUpdater; import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.Position; import org.eclipse.text.edits.DeleteEdit; import org.eclipse.text.edits.InsertEdit; @@ -58,19 +57,19 @@ public class CodeFormatterUtil { * @throws IllegalArgumentException If the offset and length are not inside the string, a * IllegalArgumentException is thrown. */ - public static TextEdit format(int kind, IDocument document, int offset, int length, int indentationLevel, String lineSeparator, Map options) { - if (offset < 0 || length < 0 || offset + length > document.getLength()) { - throw new IllegalArgumentException("offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + document.getLength()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + public static TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator, Map options) { + if (offset < 0 || length < 0 || offset + length > source.length()) { + throw new IllegalArgumentException("offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + source.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } CodeFormatter formatter = ToolFactory.createCodeFormatter(options); if (formatter != null) { - return formatter.format(kind, document, offset, length, indentationLevel, lineSeparator); + return formatter.format(kind, source, offset, length, indentationLevel, lineSeparator); } return null; } - public static TextEdit format(int kind, IDocument document, int indentationLevel, String lineSeparator, Map options) { - return format(kind, document, 0, document.getLength(), indentationLevel, lineSeparator, options); + public static TextEdit format(int kind, String source, int indentationLevel, String lineSeparator, Map options) { + return format(kind, source, 0, source.length(), indentationLevel, lineSeparator, options); }