X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java index bd39503..5d1989d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/util/CodeFormatterUtil.java @@ -10,11 +10,13 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.corext.util; -import java.util.Map; +//import java.util.Map; import net.sourceforge.phpdt.core.ToolFactory; import net.sourceforge.phpdt.core.formatter.DefaultCodeFormatterConstants; -import net.sourceforge.phpdt.internal.corext.Assert; +//incastrix +//import net.sourceforge.phpdt.internal.corext.Assert; +import org.eclipse.core.runtime.Assert; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.core.runtime.Preferences; @@ -23,10 +25,10 @@ import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultPositionUpdater; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.Position; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.text.edits.InsertEdit; -import org.eclipse.text.edits.MultiTextEdit; -import org.eclipse.text.edits.ReplaceEdit; +//import org.eclipse.text.edits.DeleteEdit; +//import org.eclipse.text.edits.InsertEdit; +//import org.eclipse.text.edits.MultiTextEdit; +//import org.eclipse.text.edits.ReplaceEdit; import org.eclipse.text.edits.TextEdit; public class CodeFormatterUtil { @@ -107,27 +109,27 @@ public class CodeFormatterUtil { // return getOldAPICompatibleResult(string, edit, indentationLevel, // positions, lineSeparator, options); // } - private static String getOldAPICompatibleResult(String string, - TextEdit edit, int indentationLevel, int[] positions, - String lineSeparator, Map options) { - Position[] p = null; - - if (positions != null) { - p = new Position[positions.length]; - for (int i = 0; i < positions.length; i++) { - p[i] = new Position(positions[i], 0); - } - } - String res = evaluateFormatterEdit(string, edit, p); - - if (positions != null) { - for (int i = 0; i < positions.length; i++) { - Position curr = p[i]; - positions[i] = curr.getOffset(); - } - } - return res; - } +// private static String getOldAPICompatibleResult(String string, +// TextEdit edit, int indentationLevel, int[] positions, +// String lineSeparator, Map options) { +// Position[] p = null; +// +// if (positions != null) { +// p = new Position[positions.length]; +// for (int i = 0; i < positions.length; i++) { +// p[i] = new Position(positions[i], 0); +// } +// } +// String res = evaluateFormatterEdit(string, edit, p); +// +// if (positions != null) { +// for (int i = 0; i < positions.length; i++) { +// Position curr = p[i]; +// positions[i] = curr.getOffset(); +// } +// } +// return res; +// } /** * Evaluates the edit on the given string. @@ -275,32 +277,32 @@ public class CodeFormatterUtil { // } // return edit; // } - private static TextEdit shifEdit(TextEdit oldEdit, int diff) { - TextEdit newEdit; - if (oldEdit instanceof ReplaceEdit) { - ReplaceEdit edit = (ReplaceEdit) oldEdit; - newEdit = new ReplaceEdit(edit.getOffset() - diff, - edit.getLength(), edit.getText()); - } else if (oldEdit instanceof InsertEdit) { - InsertEdit edit = (InsertEdit) oldEdit; - newEdit = new InsertEdit(edit.getOffset() - diff, edit.getText()); - } else if (oldEdit instanceof DeleteEdit) { - DeleteEdit edit = (DeleteEdit) oldEdit; - newEdit = new DeleteEdit(edit.getOffset() - diff, edit.getLength()); - } else if (oldEdit instanceof MultiTextEdit) { - newEdit = new MultiTextEdit(); - } else { - return null; // not supported - } - TextEdit[] children = oldEdit.getChildren(); - for (int i = 0; i < children.length; i++) { - TextEdit shifted = shifEdit(children[i], diff); - if (shifted != null) { - newEdit.addChild(shifted); - } - } - return newEdit; - } +// private static TextEdit shifEdit(TextEdit oldEdit, int diff) { +// TextEdit newEdit; +// if (oldEdit instanceof ReplaceEdit) { +// ReplaceEdit edit = (ReplaceEdit) oldEdit; +// newEdit = new ReplaceEdit(edit.getOffset() - diff, +// edit.getLength(), edit.getText()); +// } else if (oldEdit instanceof InsertEdit) { +// InsertEdit edit = (InsertEdit) oldEdit; +// newEdit = new InsertEdit(edit.getOffset() - diff, edit.getText()); +// } else if (oldEdit instanceof DeleteEdit) { +// DeleteEdit edit = (DeleteEdit) oldEdit; +// newEdit = new DeleteEdit(edit.getOffset() - diff, edit.getLength()); +// } else if (oldEdit instanceof MultiTextEdit) { +// newEdit = new MultiTextEdit(); +// } else { +// return null; // not supported +// } +// TextEdit[] children = oldEdit.getChildren(); +// for (int i = 0; i < children.length; i++) { +// TextEdit shifted = shifEdit(children[i], diff); +// if (shifted != null) { +// newEdit.addChild(shifted); +// } +// } +// return newEdit; +// } private static Document createDocument(String string, Position[] positions) throws IllegalArgumentException {