public class DocumentPartitioner
extends java.lang.Object
implements org.eclipse.jface.text.IDocumentPartitioner, org.eclipse.jface.text.IDocumentPartitionerExtension, org.eclipse.jface.text.IDocumentPartitionerExtension2, org.eclipse.jface.text.IDocumentPartitionerExtension3
FastPartitioner
in order to be able to fix
documentChanged2(DocumentEvent)
Modifier and Type | Field and Description |
---|---|
protected static boolean |
CHECK_CACHE_CONSISTENCY
Debug option for cache consistency checking.
|
protected static java.lang.String |
CONTENT_TYPES_CATEGORY
The position category this partitioner uses to store the document's partitioning information.
|
protected org.eclipse.jface.text.DocumentRewriteSession |
fActiveRewriteSession
The active document rewrite session.
|
protected org.eclipse.jface.text.Position[] |
fCachedPositions
The cached positions from our document, so we don't create a new array every time someone requests partition
information.
|
protected int |
fDeleteOffset
The offset at which a partition has been deleted
|
protected org.eclipse.jface.text.IDocument |
fDocument
The partitioner's document
|
protected int |
fEndOffset
The offset at which the last changed partition ends
|
protected boolean |
fIsInitialized
Flag indicating whether this partitioner has been initialized.
|
protected java.lang.String[] |
fLegalContentTypes
The legal content types of this partitioner
|
protected java.lang.String |
fPositionCategory
The position category this partitioner uses to store the document's partitioning information.
|
protected org.eclipse.jface.text.DefaultPositionUpdater |
fPositionUpdater
The position updater used to for the default updating of partitions
|
protected org.eclipse.jface.text.rules.IPartitionTokenScanner |
fScanner
The partitioner's scanner
|
protected int |
fStartOffset
The offset at which the first changed partition starts
|
Constructor and Description |
---|
DocumentPartitioner(org.eclipse.jface.text.rules.IPartitionTokenScanner scanner,
ITokenTypeToPartitionTypeMapper mapper) |
DocumentPartitioner(org.eclipse.jface.text.rules.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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkInitialization()
Calls
initialize() if the receiver is not yet initialized. |
protected void |
clearPositionCache()
Clears the position cache.
|
org.eclipse.jface.text.ITypedRegion[] |
computePartitioning(int offset,
int length) |
org.eclipse.jface.text.ITypedRegion[] |
computePartitioning(int offset,
int length,
boolean includeZeroLengthPartitions)
May be replaced or extended by subclasses.
|
void |
connect(org.eclipse.jface.text.IDocument document) |
void |
connect(org.eclipse.jface.text.IDocument document,
boolean delayInitialization)
May be extended by subclasses.
|
void |
disconnect()
May be extended by subclasses.
|
void |
documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent e)
May be extended by subclasses.
|
boolean |
documentChanged(org.eclipse.jface.text.DocumentEvent e) |
org.eclipse.jface.text.IRegion |
documentChanged2(org.eclipse.jface.text.DocumentEvent e)
May be extended by subclasses.
|
protected org.eclipse.jface.text.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.
|
org.eclipse.jface.text.DocumentRewriteSession |
getActiveRewriteSession()
May be extended by subclasses.
|
java.lang.String |
getContentType(int offset)
May be replaced or extended by subclasses.
|
java.lang.String |
getContentType(int offset,
boolean preferOpenPartitions)
May be replaced or extended by subclasses.
|
java.lang.String[] |
getLegalContentTypes()
May be replaced or extended by subclasses.
|
java.lang.String[] |
getManagingPositionCategories() |
org.eclipse.jface.text.ITypedRegion |
getPartition(int offset)
May be replaced or extended by subclasses.
|
org.eclipse.jface.text.ITypedRegion |
getPartition(int offset,
boolean preferOpenPartitions)
May be replaced or extended by subclasses.
|
protected org.eclipse.jface.text.Position[] |
getPositions()
Returns the partitioners positions.
|
protected java.lang.String |
getTokenContentType(org.eclipse.jface.text.rules.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(org.eclipse.jface.text.DocumentRewriteSession session) |
void |
stopRewriteSession(org.eclipse.jface.text.DocumentRewriteSession session)
May be extended by subclasses.
|
protected static final java.lang.String CONTENT_TYPES_CATEGORY
protected final org.eclipse.jface.text.rules.IPartitionTokenScanner fScanner
protected final java.lang.String[] fLegalContentTypes
protected org.eclipse.jface.text.IDocument fDocument
protected final org.eclipse.jface.text.DefaultPositionUpdater fPositionUpdater
protected int fStartOffset
protected int fEndOffset
protected int fDeleteOffset
protected final java.lang.String fPositionCategory
protected org.eclipse.jface.text.DocumentRewriteSession fActiveRewriteSession
protected boolean fIsInitialized
protected org.eclipse.jface.text.Position[] fCachedPositions
protected static final boolean CHECK_CACHE_CONSISTENCY
public DocumentPartitioner(org.eclipse.jface.text.rules.IPartitionTokenScanner scanner, java.lang.String[] legalContentTypes)
scanner
- the scanner this partitioner is supposed to uselegalContentTypes
- the legal content types of this partitioner@Inject public DocumentPartitioner(org.eclipse.jface.text.rules.IPartitionTokenScanner scanner, ITokenTypeToPartitionTypeMapper mapper)
public java.lang.String[] getManagingPositionCategories()
getManagingPositionCategories
in interface org.eclipse.jface.text.IDocumentPartitionerExtension2
public final void connect(org.eclipse.jface.text.IDocument document)
connect
in interface org.eclipse.jface.text.IDocumentPartitioner
public void connect(org.eclipse.jface.text.IDocument document, boolean delayInitialization)
May be extended by subclasses.
connect
in interface org.eclipse.jface.text.IDocumentPartitionerExtension3
protected final void checkInitialization()
initialize()
if the receiver is not yet initialized.protected void initialize()
May be extended by subclasses.
public void disconnect()
May be extended by subclasses.
disconnect
in interface org.eclipse.jface.text.IDocumentPartitioner
public void documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent e)
May be extended by subclasses.
documentAboutToBeChanged
in interface org.eclipse.jface.text.IDocumentPartitioner
public final boolean documentChanged(org.eclipse.jface.text.DocumentEvent e)
documentChanged
in interface org.eclipse.jface.text.IDocumentPartitioner
public org.eclipse.jface.text.IRegion documentChanged2(org.eclipse.jface.text.DocumentEvent e)
May be extended by subclasses.
documentChanged2
in interface org.eclipse.jface.text.IDocumentPartitionerExtension
protected org.eclipse.jface.text.TypedPosition findClosestPosition(int offset)
May be extended or replaced by subclasses.
offset
- the offset for which to search the closest positionpublic java.lang.String getContentType(int offset)
May be replaced or extended by subclasses.
getContentType
in interface org.eclipse.jface.text.IDocumentPartitioner
public org.eclipse.jface.text.ITypedRegion getPartition(int offset)
May be replaced or extended by subclasses.
getPartition
in interface org.eclipse.jface.text.IDocumentPartitioner
public final org.eclipse.jface.text.ITypedRegion[] computePartitioning(int offset, int length)
computePartitioning
in interface org.eclipse.jface.text.IDocumentPartitioner
public java.lang.String[] getLegalContentTypes()
May be replaced or extended by subclasses.
getLegalContentTypes
in interface org.eclipse.jface.text.IDocumentPartitioner
protected boolean isSupportedContentType(java.lang.String contentType)
May be extended by subclasses.
contentType
- the content type to checktrue
if the content type is a legal content typeprotected java.lang.String getTokenContentType(org.eclipse.jface.text.rules.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 determinedpublic java.lang.String getContentType(int offset, boolean preferOpenPartitions)
May be replaced or extended by subclasses.
getContentType
in interface org.eclipse.jface.text.IDocumentPartitionerExtension2
public org.eclipse.jface.text.ITypedRegion getPartition(int offset, boolean preferOpenPartitions)
May be replaced or extended by subclasses.
getPartition
in interface org.eclipse.jface.text.IDocumentPartitionerExtension2
public org.eclipse.jface.text.ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions)
May be replaced or extended by subclasses.
computePartitioning
in interface org.eclipse.jface.text.IDocumentPartitionerExtension2
public void startRewriteSession(org.eclipse.jface.text.DocumentRewriteSession session) throws java.lang.IllegalStateException
startRewriteSession
in interface org.eclipse.jface.text.IDocumentPartitionerExtension3
java.lang.IllegalStateException
public void stopRewriteSession(org.eclipse.jface.text.DocumentRewriteSession session)
May be extended by subclasses.
stopRewriteSession
in interface org.eclipse.jface.text.IDocumentPartitionerExtension3
public org.eclipse.jface.text.DocumentRewriteSession getActiveRewriteSession()
May be extended by subclasses.
getActiveRewriteSession
in interface org.eclipse.jface.text.IDocumentPartitionerExtension3
protected final void flushRewriteSession()
protected final void clearPositionCache()
protected final org.eclipse.jface.text.Position[] getPositions() throws org.eclipse.jface.text.BadPositionCategoryException
org.eclipse.jface.text.BadPositionCategoryException
- if getting the positions from the document fails