Package org.eclipse.search.internal.ui.text

Examples of org.eclipse.search.internal.ui.text.LineElement


    int lineStart = 0;
    if (!fCachedMatches.isEmpty()) {
      // match on same line as last?
      FileMatch last = (FileMatch) fCachedMatches.get(fCachedMatches
          .size() - 1);
      LineElement lineElement = last.getLineElement();
      if (lineElement.contains(offset)) {
        return lineElement;
      }
      // start with the offset and line information from the last match
      lineStart = lineElement.getOffset() + lineElement.getLength();
      lineNumber = lineElement.getLine() + 1;
    }
    if (offset < lineStart) {
      return null; // offset before the last line
    }

    int i = lineStart;
    int contentLength = matchRequestor.getFileContentLength();
    while (i < contentLength) {
      char ch = matchRequestor.getFileContentChar(i++);
      if (ch == '\n' || ch == '\r') {
        if (ch == '\r' && i < contentLength
            && matchRequestor.getFileContentChar(i) == '\n') {
          i++;
        }
        if (offset < i) {
          String lineContent = getContents(matchRequestor, lineStart,
              i); // include line delimiter
          return new LineElement(matchRequestor.getFile(),
              lineNumber, lineStart, lineContent);
        }
        lineNumber++;
        lineStart = i;
      }
    }
    if (offset < i) {
      String lineContent = getContents(matchRequestor, lineStart, i); // until
      // end
      // of
      // file
      return new LineElement(matchRequestor.getFile(), lineNumber,
          lineStart, lineContent);
    }
    return null; // offset outside of range
  }
View Full Code Here

TOP

Related Classes of org.eclipse.search.internal.ui.text.LineElement

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.