Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.ITypedRegion


  private AbstractDirective directive = this;

  public CompletionDirective (ItemSet itemSet, int offset, int length, ISourceViewer viewer, IResource resource) throws BadLocationException {
    super(itemSet);
    this.contents = viewer.getDocument().get(offset, length);
    ITypedRegion region = new TypedRegion(offset, this.contents.length(), "default"); //$NON-NLS-1$
    this.offset = offset;
    this.length = length;
    String[] arr = splitContents();
    if (null != arr && arr.length > 0) {
      String s = arr[0];
View Full Code Here


  public Map<Integer, Item> getDirectiveRegions() {
    return directiveRegions;
  }

  public Item getSelectedItem (int offset) {
    ITypedRegion region = getRegion(offset);
    if (null == region) return null;
    else return directiveRegions.get(Integer.valueOf(region.getOffset()));
  }
View Full Code Here

    return null == directiveRegions ? null : directiveRegions.get(region);
  }

  public Item getItem (int offset) {
    for (Item directive : directives) {
      ITypedRegion region = directive.getRegion();
      if (region.getOffset() <= offset && region.getOffset() + region.getLength() >= offset) {
        return directive;
      }
    }
    return null;
  }
View Full Code Here

  /*
   * @see org.eclipse.jface.text.IDocumentPartitionerExtension2#getPartition(int)
   * @since 3.0
   */
  public ITypedRegion getPartition(int offset, boolean preferOpenPartitions) {
    ITypedRegion region= getPartition(offset);
    if (preferOpenPartitions) {
      if (region.getOffset() == offset && !region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE)) {
        if (offset > 0) {
          region= getPartition(offset - 1);
          if (region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE))
            return region;
        }
        return new TypedRegion(offset, 0, IDocument.DEFAULT_CONTENT_TYPE);
      }
    }
View Full Code Here

    if (null != items && items.length > 0) {
      for (int i = 0; i < items.length; i++) {
        if (getDocument().getLength() >= items[i].getRegion()
            .getOffset() + items[i].getRegion().getLength()
            && !items[i].equals(selectedItem)) {
          ITypedRegion region = items[i].getRegion();
          getSourceViewer().getTextWidget().setStyleRange(
              new StyleRange(region.getOffset(), region
                  .getLength(), null, Preferences
                  .getInstance().getColor(
                      PreferenceKey.COLOR_RELATED_ITEM)));
        }
      }
View Full Code Here

          return null;
        }
        if (monitor != null) {
          monitor.worked(index);
        }
        ITypedRegion region = doc.getPartition(index);
        PartitionType partitionType = PartitionType.fastValueOf(region
            .getType());
        if (partitionType != null) {
          ITokenScanner scanner = itemParsers.get(partitionType);
          if (scanner != null) {
            if (newMode != this.syntaxMode
                && scanner instanceof SyntaxModeListener) {
              ((SyntaxModeListener) scanner)
                  .syntaxModeChanged(newMode);
            }
            scanner.setRange(doc, region.getOffset(),
                region.getLength());
            for (IToken token = scanner.nextToken(); !token.isEOF(); token = scanner
                .nextToken()) {
              if (canceled()) {
                return null;
              }
              if (monitor != null) {
                monitor.worked(index);
              }
              Object itemType = token.getData();
              if (!token.isUndefined() && !token.isWhitespace()
                  && itemType instanceof String) {
                TypedRegion itemRegion = new TypedRegion(
                    scanner.getTokenOffset(),
                    scanner.getTokenLength(),
                    (String) itemType);
                regions.add(itemRegion);
              }
            }
          } else {
            regions.add(region);
          }
        }
        index = region.getOffset() + region.getLength() + 1;
      }
    } catch (BadLocationException ignored) {
    } finally {
      this.syntaxMode = newMode;
      if (monitor != null) {
View Full Code Here

   * @return
   * @throws BadLocationException
   */
  private String getRegionType(IDocument d, int offset) throws BadLocationException {
    int p = ((offset == d.getLength()) ? offset - 1 : offset);
    ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, p, true);
    return region.getType();
  }
View Full Code Here

          boolean skipCommentLines, boolean skipStrings) throws BadLocationException {
    int deep = 0;
    int i = offset;
    if (forward) {
      while (i < d.getLength()) {
        ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, i, true);
        if (region.getType() == RutaPartitions.RUTA_COMMENT && skipCommentLines) {
          i = region.getOffset() + region.getLength();
          continue;
        }
        if (region.getType() == RutaPartitions.RUTA_STRING && skipStrings) {
          i = region.getOffset() + region.getLength();
          continue;
        }
        char c = d.getChar(i);
        if (c == opening)
          deep++;
        if (c == closing) {
          if (deep == 0)
            return i;
          deep--;
        }
        i++;
        if (i - offset > maxCharsAway)
          return -1;
      }
    } else {
      while (i >= 0) {
        ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, i, true);
        if (region.getType() == RutaPartitions.RUTA_COMMENT && skipCommentLines) {
          i = region.getOffset() - 1;
          continue;
        }
        if (region.getType() == RutaPartitions.RUTA_STRING && skipStrings) {
          i = region.getOffset() - 1;
          continue;
        }
        char c = d.getChar(i);
        if (c == closing)
          deep++;
View Full Code Here

      // This is the first non-empty line, use zero indent.
      return "";
    }

    // first check, if we not inside string, if yes, jump to start
    ITypedRegion region = TextUtilities.getPartition(d, fPartitioning,
            d.getLineOffset(lastNonEmptyLine), true);
    if (region.getType() == RutaPartitions.RUTA_STRING) {
      lastNonEmptyLine = d.getLineOfOffset(region.getOffset());
    }

    // If the previous line is inside parenthesis, use the indent of the
    // starting line.
    int plnumstart;
View Full Code Here

      TextPresentation presentation= new TextPresentation(damage, 1000);

      ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false);
      for (int i= 0; i < partitioning.length; i++) {
        ITypedRegion r= partitioning[i];
        IPresentationRepairer repairer= getRepairer(r.getType());
        if (repairer != null)
          repairer.createPresentation(presentation, r);
      }

      return presentation;
View Full Code Here

TOP

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

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.