Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion


    DocumentEvent event,
    boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
      try {

        IRegion info =
          fDocument.getLineInformationOfOffset(event.getOffset());
        int start = Math.max(partition.getOffset(), info.getOffset());

        int end =
          event.getOffset()
            + (event.getText() == null
              ? event.getLength()
              : event.getText().length());

        if (info.getOffset() <= end
          && end <= info.getOffset() + info.getLength()) {
          // optimize the case of the same line
          end = info.getOffset() + info.getLength();
        } else
          end = endOfLineOf(end);

        end =
          Math.min(
View Full Code Here


            parent.setBorder(BORDER_UPPER);

            if (postfix > offset) {

              text= parent.getText(range.getOffset(), range.getLength());
              final IRegion region= trimLine(text, content);

              range.move(region.getOffset());
              range.setLength(region.getLength());
            }
          }
        }
      }
    } else if (line == lines - 1) {

      offset= text.indexOf(content);
      if (offset >= 0 && text.substring(0, offset).trim().length() != 0)
        offset= -1;
      postfix= text.lastIndexOf(end);
      if (postfix >= 0 && text.substring(postfix + end.length()).trim().length() != 0)
        postfix= -1;
     
      if (offset >= 0 && offset == postfix)
        // no content on line, only the comment postfix
        range.setLength(0);
      else {
        if (offset >= 0)
          // omit the content prefix
          range.trimBegin(offset + content.length());
       
        if (postfix >= 0)
          // omit the comment postfix
          range.trimEnd(-end.length());
       
        text= parent.getText(range.getOffset(), range.getLength());
        final IRegion region= trimLine(text, content);
        if (region.getOffset() != 0 || region.getLength() != text.length()) {

          range.move(region.getOffset());
          range.setLength(region.getLength());

          parent.setBorder(BORDER_UPPER);
          parent.setBorder(BORDER_LOWER);
        }
      }
View Full Code Here

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

      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));
        } else {
          length= measureIndentUnits(line, tabWidth, indentWidth);
View Full Code Here

   */
  public int getStartPosition() {
    if (this.group.isEmpty()) {
      return this.node.getStartPosition();
    }
    IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
    if (coverage == null) {
      return this.node.getStartPosition();
    }
    return coverage.getOffset();
  }
View Full Code Here

   */
  public int getLength() {
    if (this.group.isEmpty()) {
      return this.node.getLength();
    }
    IRegion coverage= TextEdit.getCoverage(this.group.getTextEdits());
    if (coverage == null) {
      return this.node.getLength();
    }
    return coverage.getLength();
  }
View Full Code Here

          stringsToInsert.add(str);
        }
       
        for (int k= 0; k < nImports; k++) {
          ImportDeclEntry currDecl= pack.getImportAt(k);
          IRegion region= currDecl.getSourceRange();
         
          if (region == null) { // new entry
            if (!doStarImport || currDecl.isOnDemand() || (onDemandConflicts != null && onDemandConflicts.contains(currDecl.getSimpleName()))) {
              String str= getNewImportString(currDecl.getElementName(), isStatic, lineDelim);
              stringsToInsert.add(str);
            }
          } else {
            if (!doStarImport || currDecl.isOnDemand() || onDemandConflicts == null || onDemandConflicts.contains(currDecl.getSimpleName())) {
              int offset= region.getOffset();
              removeAndInsertNew(buffer, currPos, offset, stringsToInsert, resEdit);
              stringsToInsert.clear();
              currPos= offset + region.getLength();
            }
          }
        }
      }
     
View Full Code Here

    this.scribe = formatter.scribe;

    final ILineTracker tracker= new DefaultLineTracker();

    IRegion range= null;
    CommentLine line= null;

    tracker.set(getText(0, getLength()));
    final int lines= tracker.getNumberOfLines();

    fSingleLine= lines == 1;

    try {

      for (int index= 0; index < lines; index++) {

        range= tracker.getLineInformation(index);
        line= createLine();
        line.append(new CommentRange(range.getOffset(), range.getLength()));

        fLines.add(line);
      }

    } catch (BadLocationException exception) {
View Full Code Here

        if (lineNum >= lineCount) {
            lastRegion = null;
            return null;
        }

        IRegion lineInfo = document.getLineInformation(lineNum);
        char[] chars = document.get(lineInfo.getOffset(), lineInfo.getLength()).toCharArray();

        if (continued) {
            int length = lastRegion.getLength();
            length += document.getLineDelimiter(lineNum - 1).length();
            length += lineInfo.getLength();
            lastRegion = new Region(lastRegion.getOffset(), length);
        } else {
            lastRegion = lineInfo;
        }
View Full Code Here

        if (lineNum >= lineCount) {
            lastRegion = null;
            return null;
        }

        IRegion lineInfo = document.getLineInformation(lineNum);
        char[] chars = document.get(lineInfo.getOffset(), lineInfo.getLength()).toCharArray();

        if (continued) {
            int length = lastRegion.getLength();
            length += document.getLineDelimiter(lineNum - 1).length();
            length += lineInfo.getLength();
            lastRegion = new Region(lastRegion.getOffset(), length);
        } else {
            lastRegion = lineInfo;
        }
View Full Code Here

TOP

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

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.