Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.TypedRegion


  @SuppressWarnings("unchecked")
  private List<Object> getProposalsForRegion(ITextViewer viewer,
      IRegion region) {
    List<Object> objects = new ArrayList<Object>();
    ITypedRegion r = new TypedRegion(region.getOffset(),
        region.getLength(), QVTPartitionScanner.MM_COMMENT);

    try {
      r = ((QVTDocument) viewer.getDocument()).getPartition(
          QVTDocument.QVT_PARTITIONING, region.getOffset(), false);
    } catch (Exception e) {
      UiPlugin.getDefault().getLogger().log(
          java.util.logging.Level.WARNING, "Unknown error", e);
    }
    if (r.getType() != QVTPartitionScanner.MM_COMMENT) {
      if (prefix.length() > 0) {
        // keywords
        String[] keyword = fr.tm.elibel.smartqvt.qvteditor.editors.scanner.QVTScanner.KEYWORDS;
        for (int i = 0; i < keyword.length; i++)
          objects.add(keyword[i]);
        // types
        objects.addAll(getOclQvtTypes());

        if (r.getType() != QVTPartitionScanner.MM_DECLARATION) {
          objects.add(createHelperProposal(region));
        }
      }
      if (r.getType() == QVTPartitionScanner.MM_DECLARATION) {
        objects.addAll(getProposalsForOperation(region, r));
      }
      objects.addAll(getProposalsForTransformation(r));
    }
    return objects;
View Full Code Here


      myLength++;
      c = document.getChar(region.getOffset() + myLength);
    }
    // adds two to get the last characters of the line ( '\n' and '\r' )
    myLength += 2;
    return new TypedRegion(region.getOffset(), myLength, region.getType());
  }
View Full Code Here

  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];
      try {
        if (s.equals("list")) { //$NON-NLS-1$
          directive = new ListDirective(itemSet);
          directive.load(new TypedRegion(offset, this.contents.length(), "list"), viewer, resource); //$NON-NLS-1$
        }
        else if (s.equals("if")) { //$NON-NLS-1$
          directive = new IfDirective(itemSet);
          directive.load(new TypedRegion(offset, this.contents.length(), "if"), viewer, resource); //$NON-NLS-1$
        }
      }
      catch (Exception e) {
        Plugin.log(e);
        directive = this;
View Full Code Here

    try {

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

      if (category == null || category.length == 0)
        return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);

      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) {
    }

    return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
  }
View Full Code Here

        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);
      }
    }
        return region;
  }
View Full Code Here

        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));
        }
      }

      if (list.isEmpty())
        list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));

    } catch (BadPositionCategoryException x) {
    }

    TypedRegion[] result= new TypedRegion[list.size()];
View Full Code Here

      endIndex = str.indexOf(postfix, startIndex);

      if (startIndex != -1 && endIndex != -1) {
        endIndex = endIndex + 3;
        if (isInRange(range, startIndex, endIndex)) {
          iTypedRegions.add(new TypedRegion(startIndex, endIndex - startIndex, GWTPartitions.JSNI_METHOD));
        }
        startIndex += prefix.length();
      }
    }
    return iTypedRegions.toArray(new ITypedRegion[iTypedRegions.size()]);
View Full Code Here

                }
                gap = new Position(gapOffset, current.getOffset() - gapOffset);
                if (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 (gap.getLength() > 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));
                }
            }
            if (list.isEmpty())
                list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));
        } catch (BadPositionCategoryException x) {
            x.printStackTrace();
        }
        TypedRegion[] result = new TypedRegion[list.size()];
        list.toArray(result);
View Full Code Here

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

    public boolean isReadOnly(int offset) {
        return false;
    }

    public ITypedRegion[] computePartitioning(int offset, int length) {
        return new TypedRegion[] { new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE) };
    }
View Full Code Here

TOP

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

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.