Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.DefaultLineTracker


   *   null</code>
   *         if the input string can't be converted in an array of lines.
   */
  public static String[] convertIntoLines(String input) {
    try {
      ILineTracker tracker = new DefaultLineTracker();
      tracker.set(input);
      int size = tracker.getNumberOfLines();
      String result[] = new String[size];
      for (int i = 0; i < size; i++) {
        IRegion region = tracker.getLineInformation(i);
        int offset = region.getOffset();
        result[i] = input
            .substring(offset, offset + region.getLength());
      }
      return result;
View Full Code Here


  // }

  public static String trimIndentation(String source, int tabWidth,
      int indentWidth, boolean considerFirstLine) {
    try {
      ILineTracker tracker = new DefaultLineTracker();
      tracker.set(source);
      int size = tracker.getNumberOfLines();
      if (size == 1)
        return source;
      String lines[] = new String[size];
      for (int i = 0; i < size; i++) {
        IRegion region = tracker.getLineInformation(i);
        int offset = region.getOffset();
        lines[i] = source
            .substring(offset, offset + region.getLength());
      }
      Strings.trimIndentation(lines, tabWidth, indentWidth,
          considerFirstLine);
      StringBuffer result = new StringBuffer();
      int last = size - 1;
      for (int i = 0; i < size; i++) {
        result.append(lines[i]);
        if (i < last)
          result.append(tracker.getLineDelimiter(i));
      }
      return result.toString();
    } catch (BadLocationException e) {
      Assert.isTrue(false, "Can not happend"); //$NON-NLS-1$
      return null;
View Full Code Here

        || lineDelim == null) {
      throw new IllegalArgumentException();
    }

    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
View Full Code Here

      throw new IllegalArgumentException();
    }

    ArrayList result = new ArrayList();
    try {
      ILineTracker tracker = new DefaultLineTracker();
      tracker.set(source);
      int nLines = tracker.getNumberOfLines();
      if (nLines == 1)
        return (ReplaceEdit[]) result.toArray(new ReplaceEdit[result
            .size()]);
      for (int i = 1; i < nLines; i++) {
        IRegion region = tracker.getLineInformation(i);
        int offset = region.getOffset();
        String line = source.substring(offset, offset
            + region.getLength());
        int length = indexOfIndent(line, indentUnitsToRemove, tabWidth,
            indentWidth);
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.DefaultLineTracker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.