Examples of ILineTracker


Examples of org.eclipse.jface.text.ILineTracker

    if (tabWidth < 0 || indentWidth < 0 || code == null || indentUnitsToRemove < 0 || newIndentString == null || 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 formatted string)
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

      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);
        if (length >= 0) {
          result.add(new ReplaceEdit(offset, length, newIndentString));
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

    fMasterDocument.addPositionUpdater(fFragmentsUpdater);

    fMapping= new ProjectionMapping(masterDocument, fFragmentsCategory, this, fSegmentsCategory);

    ITextStore s= new ProjectionTextStore(masterDocument, fMapping);
    ILineTracker tracker= new DefaultLineTracker();

    setTextStore(s);
    setLineTracker(tracker);

    completeInitialization();

    initializeProjection();
    tracker.set(s.get(0, s.getLength()));
  }
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

    if (tabWidth < 0 || indentWidth < 0 || code == null || indentUnitsToRemove < 0 || newIndentString == null || 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 formatted string)
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

      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);
        if (length >= 0) {
          result.add(new ReplaceEdit(offset, length, newIndentString));
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

      }
    }
 
    // 4 - add the content prefix (@see JavaDocRegion#postprocessCodeSnippet)
    this.codeSnippetBuffer.setLength(0);
    ILineTracker tracker = new DefaultLineTracker();
    this.column = 1;
    printIndentationIfNecessary(this.codeSnippetBuffer); // append indentation
    this.codeSnippetBuffer.append(BLOCK_LINE_PREFIX);
    String linePrefix = this.codeSnippetBuffer.toString();
    this.codeSnippetBuffer.setLength(0);
    String replacement = formattedSnippet;
    tracker.set(formattedSnippet);
    int numberOfLines = tracker.getNumberOfLines();
    if (numberOfLines > 1) {
      int lastLineOffset = -1;
      for (int i=0; i<numberOfLines-1; i++) {
        if (i>0) this.codeSnippetBuffer.append(linePrefix);
        try {
          lastLineOffset = tracker.getLineOffset(i+1);
          this.codeSnippetBuffer.append(formattedSnippet.substring(tracker.getLineOffset(i), lastLineOffset));
        } catch (BadLocationException e) {
          // should not happen
          CommentFormatterUtil.log(e);
          return;
        }
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

    return buffer;
  }

  private static String changeLineDelimiter(String code, 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++) {
        if (i != 0) {
          buf.append(lineDelim);
        }
        IRegion region = tracker.getLineInformation(i);
        String line = code.substring(region.getOffset(), region
            .getOffset()
            + region.getLength());
        buf.append(line);
      }
View Full Code Here

Examples of org.eclipse.jface.text.ILineTracker

   *   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

Examples of org.eclipse.jface.text.ILineTracker

  // }

  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

Examples of org.eclipse.jface.text.ILineTracker

        || 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
TOP
Copyright © 2018 www.massapi.com. 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.