Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.TypedPosition


      int endOffset= offset + length;

      Position[] category= getPositions();

      TypedPosition previous= null, current= null;
      int start, end, gapOffset;
      Position gap= new Position(0);

      int startIndex= getFirstIndexEndingAfterOffset(category, offset);
      int endIndex= getFirstIndexStartingAfterOffset(category, endOffset);
      for (int i= startIndex; i < endIndex; i++) {

        current= (TypedPosition) category[i];

        gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
        gap.setOffset(gapOffset);
        gap.setLength(current.getOffset() - gapOffset);
        if ((includeZeroLengthPartitions && overlapsOrTouches(gap, offset, length)) ||
            (gap.getLength() > 0 && gap.overlapsWith(offset, length))) {
          start= Math.max(offset, gapOffset);
          end= Math.min(endOffset, gap.getOffset() + gap.getLength());
          list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
        }

        if (current.overlapsWith(offset, length)) {
          start= Math.max(offset, current.getOffset());
          end= Math.min(endOffset, current.getOffset() + current.getLength());
          list.add(new TypedRegion(start, end - start, current.getType()));
        }

        previous= current;
      }

      if (previous != null) {
        gapOffset= previous.getOffset() + previous.getLength();
        gap.setOffset(gapOffset);
        gap.setLength(fDocument.getLength() - gapOffset);
        if ((includeZeroLengthPartitions && overlapsOrTouches(gap, offset, length)) ||
            (gap.getLength() > 0 && gap.overlapsWith(offset, length))) {
          start= Math.max(offset, gapOffset);
View Full Code Here


      while (!token.isEOF()) {

        String contentType= getTokenContentType(token);

        if (isSupportedContentType(contentType)) {
          TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType);
          fDocument.addPosition(fPositionCategory, p);
        }

        token= fScanner.nextToken();
      }
View Full Code Here

        lastScannedPosition= start + length - 1;

        // remove all affected positions
        while (first < category.length) {
          TypedPosition p= (TypedPosition) category[first];
          if (lastScannedPosition >= p.offset + p.length ||
              (p.overlapsWith(start, length) &&
                 (!d.containsPosition(fPositionCategory, start, length) ||
                  !contentType.equals(p.getType())))) {

            rememberRegion(p.offset, p.length);
            d.removePosition(fPositionCategory, p);
            ++ first;

          } else
            break;
        }

        // if position already exists we are done
        if (d.containsPosition(fPositionCategory, start, length))
          return createRegion();

        // insert the new type position
        try {
          d.addPosition(fPositionCategory, new TypedPosition(start, length, contentType));
          rememberRegion(start, length);
        } catch (BadPositionCategoryException x) {
        } catch (BadLocationException x) {
        }

        token= fScanner.nextToken();
      }


      // remove all positions behind lastScannedPosition since there aren't any further types
      if (lastScannedPosition != reparseStart) {
        // if this condition is not met, nothing has been scanned because of a delete
        ++ lastScannedPosition;
      }
      first= d.computeIndexInCategory(fPositionCategory, lastScannedPosition);

      TypedPosition p;
      while (first < category.length) {
        p= (TypedPosition) category[first++];
        d.removePosition(fPositionCategory, p);
        rememberRegion(p.offset, p.length);
      }
View Full Code Here

  /*
   * @see IDocumentPartitioner#getContentType
   */
  public String getContentType(int offset) {

    TypedPosition p= findClosestPosition(offset);
    if (p != null && p.includes(offset))
      return p.getType();

    return IDocument.DEFAULT_CONTENT_TYPE;
  }
View Full Code Here

      int index= fDocument.computeIndexInCategory(fPositionCategory, offset);

      if (index < category.length) {

        TypedPosition next= (TypedPosition) category[index];

        if (offset == next.offset)
          return new TypedRegion(next.getOffset(), next.getLength(), next.getType());

        if (index == 0)
          return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);

        TypedPosition previous= (TypedPosition) category[index - 1];
        if (previous.includes(offset))
          return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());

        int endOffset= previous.getOffset() + previous.getLength();
        return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
      }

      TypedPosition previous= (TypedPosition) category[category.length - 1];
      if (previous.includes(offset))
        return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());

      int endOffset= previous.getOffset() + previous.getLength();
      return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);

    } catch (BadPositionCategoryException x) {
    } catch (BadLocationException x) {
    }
View Full Code Here

      int endOffset= offset + length;

      Position[] category= fDocument.getPositions(fPositionCategory);

      TypedPosition previous= null, current= null;
      int start, end, gapOffset;
      Position gap= null;

      for (int i= 0; i < category.length; i++) {

        current= (TypedPosition) category[i];

        gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
        gap= new Position(gapOffset, current.getOffset() - gapOffset);
        if ((includeZeroLengthPartitions || gap.getLength() > 0) && gap.overlapsWith(offset, length)) {
          start= Math.max(offset, gapOffset);
          end= Math.min(endOffset, gap.getOffset() + gap.getLength());
          list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
        }

        if (current.overlapsWith(offset, length)) {
          start= Math.max(offset, current.getOffset());
          end= Math.min(endOffset, current.getOffset() + current.getLength());
          list.add(new TypedRegion(start, end - start, current.getType()));
        }

        previous= current;
      }

      if (previous != null) {
        gapOffset= previous.getOffset() + previous.getLength();
        gap= new Position(gapOffset, fDocument.getLength() - gapOffset);
        if ((includeZeroLengthPartitions || gap.getLength() > 0) && ((includeZeroLengthPartitions && offset + length == gapOffset && gap.length == 0) || gap.overlapsWith(offset, length))) {
          start= Math.max(offset, gapOffset);
          end= Math.min(endOffset, fDocument.getLength());
          list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
View Full Code Here

      // Do nothing
    }

    if (fMaster != null) {

      context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length, fType));

      fMaster.formatterStarts(context);
      fMaster.format();
      fMaster.formatterStops();
    }
View Full Code Here

  protected void formatSlave(final IFormattingContext context, final IDocument document, final int offset, final int length, final String type) {

    final IFormattingStrategyExtension strategy= (IFormattingStrategyExtension)fSlaves.get(type);
    if (strategy != null) {

      context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length, type));

      strategy.formatterStarts(context);
      strategy.format();
      strategy.formatterStops();
    }
View Full Code Here

      fDocumentChanging= true;
      if (fCachedRedrawState) {
        try {
          int offset= e.getOffset() + e.getLength();
          ITypedRegion region= getPartition(e.getDocument(), offset);
          fRememberedPosition= new TypedPosition(region);
          e.getDocument().addPosition(fPositionCategory, fRememberedPosition);
        } catch (BadLocationException x) {
          // can not happen
        } catch (BadPositionCategoryException x) {
          // should not happen on input elements
View Full Code Here

  private void formatRegion(IRegion region) {

    IFormattingStrategy strategy= getFormattingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
    if (strategy != null) {
      strategy.formatterStarts(getIndentation(region.getOffset()));
      format(strategy, new TypedPosition(region.getOffset(), region.getLength(), IDocument.DEFAULT_CONTENT_TYPE));
      strategy.formatterStops();
    }
  }
View Full Code Here

TOP

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

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.