|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.jface.text.rules.FastPartitioner
public class FastPartitioner
A standard implementation of a document partitioner. It uses an
IPartitionTokenScanner to scan the document and to determine the
document's partitioning. The tokens returned by the scanner must return the
partition type as their data. The partitioner remembers the document's
partitions in the document itself rather than maintaining its own data
structure.
To reduce array creations in IDocument.getPositions(String), the
positions get cached. The cache is cleared after updating the positions in
documentChanged2(DocumentEvent). Subclasses need to call
clearPositionCache() after modifying the partitioner's positions.
The cached positions may be accessed through getPositions().
IPartitionTokenScanner| Field Summary | |
|---|---|
protected int |
fDeleteOffset
The offset at which a partition has been deleted |
protected IDocument |
fDocument
The partitioner's document |
protected int |
fEndOffset
The offset at which the last changed partition ends |
protected java.lang.String[] |
fLegalContentTypes
The legal content types of this partitioner |
protected DefaultPositionUpdater |
fPositionUpdater
The position updater used to for the default updating of partitions |
protected int |
fPreviousDocumentLength
The document length before a document change occurred |
protected IPartitionTokenScanner |
fScanner
The partitioner's scanner |
protected int |
fStartOffset
The offset at which the first changed partition starts |
| Constructor Summary | |
|---|---|
FastPartitioner(IPartitionTokenScanner scanner,
java.lang.String[] legalContentTypes)
Creates a new partitioner that uses the given scanner and may return partitions of the given legal content types. |
|
| Method Summary | |
|---|---|
protected void |
checkInitialization()
Calls initialize() if the receiver is not yet initialized. |
protected void |
clearPositionCache()
Clears the position cache. |
ITypedRegion[] |
computePartitioning(int offset,
int length)
Returns the partitioning of the given range of the connected document. |
ITypedRegion[] |
computePartitioning(int offset,
int length,
boolean includeZeroLengthPartitions)
Returns the partitioning of the given range of the connected document. May be replaced or extended by subclasses. |
void |
connect(IDocument document)
Connects the partitioner to a document. |
void |
connect(IDocument document,
boolean delayInitialization)
Connects this partitioner to a document. May be extended by subclasses. |
void |
disconnect()
Disconnects the partitioner from the document it is connected to. May be extended by subclasses. |
void |
documentAboutToBeChanged(DocumentEvent e)
Informs about a forthcoming document change. May be extended by subclasses. |
boolean |
documentChanged(DocumentEvent e)
The document has been changed. |
IRegion |
documentChanged2(DocumentEvent e)
The document has been changed. May be extended by subclasses. |
protected TypedPosition |
findClosestPosition(int offset)
Returns the position in the partitoner's position category which is close to the given offset. |
protected void |
flushRewriteSession()
Flushes the active rewrite session. |
DocumentRewriteSession |
getActiveRewriteSession()
Returns the active rewrite session of this document or null.
May be extended by subclasses. |
java.lang.String |
getContentType(int offset)
Returns the content type of the partition containing the given offset in the connected document. May be replaced or extended by subclasses. |
java.lang.String |
getContentType(int offset,
boolean preferOpenPartitions)
Returns the content type of the partition containing the given offset in the connected document. May be replaced or extended by subclasses. |
java.lang.String[] |
getLegalContentTypes()
Returns the set of all legal content types of this partitioner. May be replaced or extended by subclasses. |
java.lang.String[] |
getManagingPositionCategories()
Returns the position categories that this partitioners uses in order to manage the partitioning information of the documents. |
ITypedRegion |
getPartition(int offset)
Returns the partition containing the given offset of the connected document. May be replaced or extended by subclasses. |
ITypedRegion |
getPartition(int offset,
boolean preferOpenPartitions)
Returns the partition containing the given offset of the connected document. May be replaced or extended by subclasses. |
protected Position[] |
getPositions()
Returns the partitioners positions. |
protected java.lang.String |
getTokenContentType(IToken token)
Returns a content type encoded in the given token. |
protected void |
initialize()
Performs the initial partitioning of the partitioner's document. |
protected boolean |
isSupportedContentType(java.lang.String contentType)
Returns whether the given type is one of the legal content types. |
void |
startRewriteSession(DocumentRewriteSession session)
Tells the document partitioner that a rewrite session started. |
void |
stopRewriteSession(DocumentRewriteSession session)
Tells the document partitioner that the rewrite session has finished. May be extended by subclasses. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final IPartitionTokenScanner fScanner
protected final java.lang.String[] fLegalContentTypes
protected IDocument fDocument
protected int fPreviousDocumentLength
protected final DefaultPositionUpdater fPositionUpdater
protected int fStartOffset
protected int fEndOffset
protected int fDeleteOffset
| Constructor Detail |
|---|
public FastPartitioner(IPartitionTokenScanner scanner,
java.lang.String[] legalContentTypes)
scanner - the scanner this partitioner is supposed to uselegalContentTypes - the legal content types of this partitioner| Method Detail |
|---|
public java.lang.String[] getManagingPositionCategories()
IDocumentPartitionerExtension2null if
no position category is used.
getManagingPositionCategories in interface IDocumentPartitionerExtension2nullpublic final void connect(IDocument document)
IDocumentPartitionerThe caller of this method must ensure that this partitioner is also set as the document's document partitioner.
This method has been replaced with IDocumentPartitionerExtension3.connect(IDocument, boolean).
Implementers should default a call connect(document) to
connect(document, false) in order to sustain the same semantics.
connect in interface IDocumentPartitionerdocument - the document to be connected to
public void connect(IDocument document,
boolean delayInitialization)
The caller of this method must ensure that this partitioner is also set as the document's document partitioner.
delayInitialization indicates whether the partitioner is
allowed to delay it initial computation of the document's partitioning
until it has to answer the first query.
Replaces IDocumentPartitioner.connect(IDocument).
May be extended by subclasses.
connect in interface IDocumentPartitionerExtension3document - the document to be connected todelayInitialization - true if initialization can be delayed, false otherwiseprotected final void checkInitialization()
initialize() if the receiver is not yet initialized.
protected void initialize()
May be extended by subclasses.
public void disconnect()
The caller of this method should also must ensure that this partitioner is no longer the document's partitioner.
May be extended by subclasses.
disconnect in interface IDocumentPartitionerpublic void documentAboutToBeChanged(DocumentEvent e)
May be extended by subclasses.
documentAboutToBeChanged in interface IDocumentPartitionere - the event describing the forthcoming changepublic final boolean documentChanged(DocumentEvent e)
IDocumentPartitioner
This method has been replaced by IDocumentPartitionerExtension.documentChanged2(DocumentEvent).
documentChanged in interface IDocumentPartitionere - the event describing the document change
true if partitioning changedpublic IRegion documentChanged2(DocumentEvent e)
null if the partitioning did not change.
Will be called by the connected document and is not intended to be used by clients other than the connected document.
Replaces IDocumentPartitioner.documentChanged(DocumentEvent).
May be extended by subclasses.
documentChanged2 in interface IDocumentPartitionerExtensione - the event describing the document change
nullprotected TypedPosition findClosestPosition(int offset)
May be extended or replaced by subclasses.
offset - the offset for which to search the closest position
public java.lang.String getContentType(int offset)
Use IDocumentPartitionerExtension2.getContentType(int, boolean) when
zero-length partitions are supported. In that case this method is
equivalent:
IDocumentPartitionerExtension2 extension= (IDocumentPartitionerExtension2) partitioner;
return extension.getContentType(offset, false);
May be replaced or extended by subclasses.
getContentType in interface IDocumentPartitioneroffset - the offset in the connected document
public ITypedRegion getPartition(int offset)
Use IDocumentPartitionerExtension2.getPartition(int, boolean) when
zero-length partitions are supported. In that case this method is
equivalent:
IDocumentPartitionerExtension2 extension= (IDocumentPartitionerExtension2) partitioner;
return extension.getPartition(offset, false);
May be replaced or extended by subclasses.
getPartition in interface IDocumentPartitioneroffset - the offset for which to determine the partition
public final ITypedRegion[] computePartitioning(int offset,
int length)
IDocumentPartitioner
Use IDocumentPartitionerExtension2.computePartitioning(int, int, boolean) when
zero-length partitions are supported. In that case this method is
equivalent:
IDocumentPartitionerExtension2 extension= (IDocumentPartitionerExtension2) partitioner;
return extension.computePartitioning(offset, length, false);
computePartitioning in interface IDocumentPartitioneroffset - the offset of the range of interestlength - the length of the range of interest
public java.lang.String[] getLegalContentTypes()
May be replaced or extended by subclasses.
getLegalContentTypes in interface IDocumentPartitionerprotected boolean isSupportedContentType(java.lang.String contentType)
May be extended by subclasses.
contentType - the content type to check
true if the content type is a legal content typeprotected java.lang.String getTokenContentType(IToken token)
null and a string it is assumed that
it is the encoded content type.
May be replaced or extended by subclasses.
token - the token whose content type is to be determined
public java.lang.String getContentType(int offset,
boolean preferOpenPartitions)
If preferOpenPartitions is true,
precedence is given to an open partition ending at offset
over a delimited partition starting at offset.
This method replaces IDocumentPartitioner.getContentType(int)and
behaves like it when prepreferOpenPartitions is
false, i.e. precedence is always given to the partition
that does not end at offset.
May be replaced or extended by subclasses.
getContentType in interface IDocumentPartitionerExtension2offset - the offset in the connected documentpreferOpenPartitions - true if precedence should be
given to a open partition ending at offset over
a delimited partition starting at offset
public ITypedRegion getPartition(int offset,
boolean preferOpenPartitions)
If preferOpenPartitions is true,
precedence is given to an open partition ending at offset
over a delimited partition starting at offset.
This method replaces IDocumentPartitioner.getPartition(int)and
behaves like it when false
, i.e. precedence is always given to the partition that does not
end at offset.
May be replaced or extended by subclasses.
getPartition in interface IDocumentPartitionerExtension2offset - the offset for which to determine the partitionpreferOpenPartitions - true if precedence should be
given to a open partition ending at offset over
a delimited partition starting at offset
public ITypedRegion[] computePartitioning(int offset,
int length,
boolean includeZeroLengthPartitions)
If includeZeroLengthPartitions is true, a
zero-length partition of an open partition type (usually the default
partition) is included between two delimited partitions. If it is
false, no zero-length partitions are included.
This method replaces
IDocumentPartitioner.computePartitioning(int, int)and behaves
like it when includeZeroLengthPartitions is
false.
May be replaced or extended by subclasses.
computePartitioning in interface IDocumentPartitionerExtension2offset - the offset of the range of interestlength - the length of the range of interestincludeZeroLengthPartitions - true if zero-length
partitions should be returned as part of the computed
partitioning
public void startRewriteSession(DocumentRewriteSession session)
throws java.lang.IllegalStateException
IDocumentPartitionerExtension3
startRewriteSession in interface IDocumentPartitionerExtension3session - the rewrite session
java.lang.IllegalStateException - in case there is already an active rewrite sessionpublic void stopRewriteSession(DocumentRewriteSession session)
startRewriteSession has
been called before.
May be extended by subclasses.
stopRewriteSession in interface IDocumentPartitionerExtension3session - the rewrite sessionpublic DocumentRewriteSession getActiveRewriteSession()
null.
May be extended by subclasses.
getActiveRewriteSession in interface IDocumentPartitionerExtension3nullprotected final void flushRewriteSession()
protected final void clearPositionCache()
protected final Position[] getPositions()
throws BadPositionCategoryException
BadPositionCategoryException - if getting the positions from the
document fails
|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.