*******************************************************************************/
package net.sourceforge.phpdt.internal.corext.util;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
+//import org.eclipse.jface.text.BadLocationException;
+//import org.eclipse.jface.text.DefaultLineTracker;
+//import org.eclipse.jface.text.ILineTracker;
+//import org.eclipse.jface.text.IRegion;
/**
* Helper class to provide String manipulation functions not available in
* doesn't contain any leading tabs or spaces then the string itself is
* returned.
*/
- public static String trimLeadingTabsAndSpaces(String line) {
- int size = line.length();
- int start = size;
- for (int i = 0; i < size; i++) {
- char c = line.charAt(i);
- if (!isIndentChar(c)) {
- start = i;
- break;
- }
- }
- if (start == 0)
- return line;
- else if (start == size)
- return ""; //$NON-NLS-1$
- else
- return line.substring(start);
- }
+// public static String trimLeadingTabsAndSpaces(String line) {
+// int size = line.length();
+// int start = size;
+// for (int i = 0; i < size; i++) {
+// char c = line.charAt(i);
+// if (!isIndentChar(c)) {
+// start = i;
+// break;
+// }
+// }
+// if (start == 0)
+// return line;
+// else if (start == size)
+// return ""; //$NON-NLS-1$
+// else
+// return line.substring(start);
+// }
// public static String trimTrailingTabsAndSpaces(String line) {
// int size = line.length();
* changed. (It is considered to have no indent as it might start in the
* middle of a line)
*/
- public static String changeIndent(String code, int codeIndentLevel,
- int tabWidth, String newIndent, String lineDelim) {
- try {
- ILineTracker tracker = new DefaultLineTracker();
- tracker.set(code);
- int nLines = tracker.getNumberOfLines();
- if (nLines == 1) {
- return code;
- }
-
- StringBuffer buf = new StringBuffer();
-
- for (int i = 0; i < nLines; i++) {
- IRegion region = tracker.getLineInformation(i);
- int start = region.getOffset();
- int end = start + region.getLength();
- String line = code.substring(start, end);
-
- if (i == 0) { // no indent for first line (contained in the
- // formatted string)
- buf.append(line);
- } else { // no new line after last line
- buf.append(lineDelim);
- buf.append(newIndent);
- buf.append(trimIndent(line, codeIndentLevel, tabWidth));
- }
- }
- return buf.toString();
- } catch (BadLocationException e) {
- // can not happen
- return code;
- }
- }
+// public static String changeIndent(String code, int codeIndentLevel,
+// int tabWidth, String newIndent, String lineDelim) {
+// try {
+// ILineTracker tracker = new DefaultLineTracker();
+// tracker.set(code);
+// int nLines = tracker.getNumberOfLines();
+// if (nLines == 1) {
+// return code;
+// }
+//
+// StringBuffer buf = new StringBuffer();
+//
+// for (int i = 0; i < nLines; i++) {
+// IRegion region = tracker.getLineInformation(i);
+// int start = region.getOffset();
+// int end = start + region.getLength();
+// String line = code.substring(start, end);
+//
+// if (i == 0) { // no indent for first line (contained in the
+// // formatted string)
+// buf.append(line);
+// } else { // no new line after last line
+// buf.append(lineDelim);
+// buf.append(newIndent);
+// buf.append(trimIndent(line, codeIndentLevel, tabWidth));
+// }
+// }
+// return buf.toString();
+// } catch (BadLocationException e) {
+// // can not happen
+// return code;
+// }
+// }
/**
* Concatenate the given strings into one strings using the passed line