Java 类org.eclipse.jface.text.TypedRegion 实例源码

项目:Pydev    文件:PyPartitioner.java   
@Override
public ITypedRegion getPartition(int offset, boolean preferOpenPartitions) {
    if (preferOpenPartitions) {
        if (offset <= 0) {
            return new TypedRegion(offset, 0, IDocument.DEFAULT_CONTENT_TYPE);
        }
        if (fDocument != null && offset == fDocument.getLength()) {
            // Fix issue where a wrong partition is being gotten when a comment is being typed
            // as the last thing in the document.
            // Fixes #PyDev-762: Code completion is active in comments.
            try {
                int lineOffset = fDocument.getLineOffset(fDocument.getLineOfOffset(offset));
                if (lineOffset != offset) { // A comment must start with a #, so, the char 0 of a line can't be a comment itself.
                    ITypedRegion region = getPartition(offset - 1);
                    if (IPythonPartitions.PY_COMMENT.equals(region.getType())
                            || IDocument.DEFAULT_CONTENT_TYPE.equals(region.getType())) {
                        return region;
                    }
                }
            } catch (BadLocationException e) {
                // ignore
            }
        }
    }
    return super.getPartition(offset, preferOpenPartitions);
}
项目:Tarski    文件:LoadReconcilingStrategy.java   
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
  if (this.document == null)
    return;
  final TypedRegion tr = (TypedRegion) subRegion;
  if (tr.getType().equals(MetaModelPartitionScanner.META_MODEL_LOADINSTANCE)
      || tr.getType().equals(MetaModelPartitionScanner.META_MODEL_LOADMODEL))
    this.reconcile(subRegion);

  return;
}
项目:Tarski    文件:SyntacticReconcilingStrategy.java   
@Override
public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) {
  if (this.document == null) {
    return;
  }
  if (((TypedRegion) subRegion).getType().equals(MetaModelPartitionScanner.META_MODEL_REASON)) {
    return;
  }
  this.reconcile(subRegion);
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexDocumentPartitioner.java   
@Override
public ITypedRegion getPartition(int arg0) {
    /*
     * Never gets called because this class implements IDocumentPartitioner
     * rather than IDocumentPartitionerExtension2 which is required for
     * IDocumentExtension3
     * Confused ?? Me too...
     */
    return new TypedRegion(0, fDocument.getLength(), IMPEX_HEADER);
}
项目:tlaplus    文件:TLAFastPartitioner.java   
/**
 * {@inheritDoc}
 * <p>
 * May be replaced or extended by subclasses.
 * </p>
 */
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);
        }
    }
    return region;
}
项目:tlaplus    文件:TagBasedTLCAnalyzer.java   
/**
 * @return
 */
public ITypedRegion getUserRegion()
{
    if (hasUserPartitions())
    {
        ITypedRegion region = PartitionToolkit.mergePartitions((ITypedRegion[]) userOutput
                .toArray(new TypedRegion[userOutput.size()]));
        // re-initialize the user partitions
        resetUserPartitions();
        return region;
    } else
    {
        return null;
    }
}
项目:bts    文件:DocumentPartitioner.java   
/**
 * {@inheritDoc}
 * <p>
 * May be replaced or extended by subclasses.
 * </p>
 * 
 * @since 2.2
 */
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);
        }
    }
    return region;
}
项目:che    文件:FastPartitioner.java   
/**
 * {@inheritDoc}
 *
 * <p>May be replaced or extended by subclasses.
 */
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);
    }
  }
  return region;
}
项目:APICloud-Studio    文件:CommonReconciler.java   
protected ITypedRegion[] computePartitioning(int offset, int length)
{
    ITypedRegion[] regions = null;
    try
    {
        regions = TextUtilities
                .computePartitioning(getDocument(), getDocumentPartitioning(), offset, length, false);
    }
    catch (BadLocationException x)
    {
        regions = new TypedRegion[0];
    }
    return regions;
}
项目:APICloud-Studio    文件:MultiRegionSpellingReconcileStrategy.java   
/**
 * Computes and returns the partitioning for the given region of the input document
 * of the reconciler's connected text viewer.
 *
 * @param offset the region offset
 * @param length the region length
 * @return the computed partitioning
 * @since 3.0
 */
private ITypedRegion[] computePartitioning(int offset, int length)
{
    ITypedRegion[] regions = null;
    try
    {
        regions = TextUtilities.computePartitioning(getDocument(), getDocumentPartitioning(), offset, length, false);
    } catch (BadLocationException x)
    {
        regions = new TypedRegion[0];
    }
    return regions;
}
项目:WP3    文件:LoadReconcilingStrategy.java   
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
  if (this.document == null)
    return;
  final TypedRegion tr = (TypedRegion) subRegion;
  if (tr.getType().equals(MetaModelPartitionScanner.META_MODEL_LOADINSTANCE)
      || tr.getType().equals(MetaModelPartitionScanner.META_MODEL_LOADMODEL))
    this.reconcile(subRegion);

  return;
}
项目:WP3    文件:SyntacticReconcilingStrategy.java   
@Override
public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) {
  if (this.document == null) {
    return;
  }
  if (((TypedRegion) subRegion).getType().equals(MetaModelPartitionScanner.META_MODEL_REASON)) {
    return;
  }
  this.reconcile(subRegion);
}
项目:hybris-commerce-eclipse-plugin    文件:ImpexDocumentPartitioner.java   
@Override
public ITypedRegion[] computePartitioning(int offset, int length) {
    /*
     * Never gets called because this class implements IDocumentPartitioner
     * rather than IDocumentPartitionerExtension2 which is required for
     * IDocumentExtension3
     * Confused ?? Me too...
     */
    List<TypedRegion> list = new ArrayList<TypedRegion>();
    try {
        int start;
        int nextOffset;
        boolean isHeader = true;
        int docLength = fDocument.getLength();

        if (offset == 0) {
            nextOffset = getLineEndOffset(1, fDocument);
            list.add(new TypedRegion(0, nextOffset + 1, IMPEX_HEADER));

            int i = 1;
            while (nextOffset + 1 < docLength) {
                start = nextOffset+ 1;
                if (Character.isDigit(fDocument.getChar(start))) {
                    isHeader = true;
                }
                else {
                    isHeader = false;
                }

                nextOffset = getLineEndOffset(i + 1, fDocument);
                if (isHeader) {
                    list.add(new TypedRegion(start, nextOffset - start + 1, IMPEX_INSTRUCTION));
                }
                else {
                    list.add(new TypedRegion(start, nextOffset - start + 1, IMPEX_DATA));
                }
                i = i + 1;
            }
        }
        else {
            if (Character.isDigit(fDocument.getChar(offset))) {
                isHeader = true;
            }
            else {
                isHeader = false;
            }

            if (isHeader) {
                list.add(new TypedRegion(offset, length, IMPEX_HEADER));
            }
            else {
                list.add(new TypedRegion(offset, length, IMPEX_DATA));
            }
        }

    }
    catch (BadLocationException ble) {
        Activator.logError("BadLocationException", ble);
    }

    if (list.isEmpty()) {
        list.add(new TypedRegion(offset, length, null));
    }

    TypedRegion[] result = new TypedRegion[list.size()];
    list.toArray(result);
    return result;
}
项目:tlaplus    文件:ParsingToolkitTest.java   
/**
 * Test method for {@link org.lamport.tla.toolbox.tool.tlc.output.ParsingTLCOutputSink#mergePartitions(org.eclipse.jface.text.ITypedRegion[])}.
 */
public void testMergePartitions()
{
    assertEquals(new TypedRegion(0, 100, "type"), PartitionToolkit.mergePartitions(new ITypedRegion[] {
            new TypedRegion(0, 10, "type"), new TypedRegion(10, 80, "type"), new TypedRegion(90, 10, "type") }));
}
项目:tlaplus    文件:ParsingToolkitTest.java   
public void testMergePartitions2()
{
    assertEquals(new TypedRegion(0, 100, "type"), PartitionToolkit
            .mergePartitions(new ITypedRegion[] { new TypedRegion(0, 100, "type") }));
}
项目:Pydev    文件:ScriptConsolePartitioner.java   
@Override
public ITypedRegion[] computePartitioning(int offset, int length) {
    return new TypedRegion[] { new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE) };
}
项目:Pydev    文件:ScriptConsolePartitioner.java   
@Override
public ITypedRegion getPartition(int offset) {
    return new TypedRegion(offset, 1, IDocument.DEFAULT_CONTENT_TYPE);
}