Class RuleBasedPartitioner
- java.lang.Object
-
- org.eclipse.jface.text.rules.RuleBasedPartitioner
-
- All Implemented Interfaces:
IDocumentPartitioner
,IDocumentPartitionerExtension
,IDocumentPartitionerExtension2
@Deprecated public class RuleBasedPartitioner extends Object implements IDocumentPartitioner, IDocumentPartitionerExtension, IDocumentPartitionerExtension2
Deprecated.useFastPartitioner
insteadA standard implementation of a syntax driven document partitioner. It uses a rule based scanner to scan the document and to determine the document's partitioning. The tokens returned by the rules the scanner is configured with are supposed to 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.- See Also:
IRule
,RuleBasedScanner
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONTENT_TYPES_CATEGORY
Deprecated.As of 3.0, usegetManagingPositionCategories()
.protected int
fDeleteOffset
Deprecated.The offset at which a partition has been deletedprotected IDocument
fDocument
Deprecated.The partitioner's documentprotected int
fEndOffset
Deprecated.The offset at which the last changed partition endsprotected String[]
fLegalContentTypes
Deprecated.The legal content types of this partitionerprotected DefaultPositionUpdater
fPositionUpdater
Deprecated.The position updater used to for the default updating of partitionsprotected int
fPreviousDocumentLength
Deprecated.The document length before a document change occurredprotected RuleBasedScanner
fScanner
Deprecated.The partitioner's scannerprotected int
fStartOffset
Deprecated.The offset at which the first changed partition starts
-
Constructor Summary
Constructors Constructor Description RuleBasedPartitioner(RuleBasedScanner scanner, String[] legalContentTypes)
Deprecated.Creates a new partitioner that uses the given scanner and may return partitions of the given legal content types.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ITypedRegion[]
computePartitioning(int offset, int length)
Deprecated.Returns the partitioning of the given range of the connected document.ITypedRegion[]
computePartitioning(int offset, int length, boolean includeZeroLengthPartitions)
Deprecated.Returns the partitioning of the given range of the connected document.void
connect(IDocument document)
Deprecated.Connects the partitioner to a document.void
disconnect()
Deprecated.Disconnects the partitioner from the document it is connected to.void
documentAboutToBeChanged(DocumentEvent e)
Deprecated.Informs about a forthcoming document change.boolean
documentChanged(DocumentEvent e)
Deprecated.The document has been changed.IRegion
documentChanged2(DocumentEvent e)
Deprecated.The document has been changed.protected TypedPosition
findClosestPosition(int offset)
Deprecated.Returns the position in the partitoner's position category which is close to the given offset.String
getContentType(int offset)
Deprecated.Returns the content type of the partition containing the given offset in the connected document.String
getContentType(int offset, boolean preferOpenPartitions)
Deprecated.Returns the content type of the partition containing the given offset in the connected document.String[]
getLegalContentTypes()
Deprecated.Returns the set of all legal content types of this partitioner.String[]
getManagingPositionCategories()
Deprecated.Returns the position categories that this partitioners uses in order to manage the partitioning information of the documents.ITypedRegion
getPartition(int offset)
Deprecated.Returns the partition containing the given offset of the connected document.ITypedRegion
getPartition(int offset, boolean preferOpenPartitions)
Deprecated.Returns the partition containing the given offset of the connected document.protected String
getTokenContentType(IToken token)
Deprecated.Returns a content type encoded in the given token.protected void
initialize()
Deprecated.Performs the initial partitioning of the partitioner's document.protected boolean
isSupportedContentType(String contentType)
Deprecated.Returns whether the given type is one of the legal content types.
-
-
-
Field Detail
-
CONTENT_TYPES_CATEGORY
@Deprecated public static final String CONTENT_TYPES_CATEGORY
Deprecated.As of 3.0, usegetManagingPositionCategories()
.The position category this partitioner uses to store the document's partitioning information- See Also:
- Constant Field Values
-
fScanner
protected RuleBasedScanner fScanner
Deprecated.The partitioner's scanner
-
fLegalContentTypes
protected String[] fLegalContentTypes
Deprecated.The legal content types of this partitioner
-
fDocument
protected IDocument fDocument
Deprecated.The partitioner's document
-
fPreviousDocumentLength
protected int fPreviousDocumentLength
Deprecated.The document length before a document change occurred
-
fPositionUpdater
protected DefaultPositionUpdater fPositionUpdater
Deprecated.The position updater used to for the default updating of partitions
-
fStartOffset
protected int fStartOffset
Deprecated.The offset at which the first changed partition starts
-
fEndOffset
protected int fEndOffset
Deprecated.The offset at which the last changed partition ends
-
fDeleteOffset
protected int fDeleteOffset
Deprecated.The offset at which a partition has been deleted
-
-
Constructor Detail
-
RuleBasedPartitioner
public RuleBasedPartitioner(RuleBasedScanner scanner, String[] legalContentTypes)
Deprecated.Creates a new partitioner that uses the given scanner and may return partitions of the given legal content types.- Parameters:
scanner
- the scanner this partitioner is supposed to uselegalContentTypes
- the legal content types of this partitioner
-
-
Method Detail
-
getManagingPositionCategories
public String[] getManagingPositionCategories()
Deprecated.Description copied from interface:IDocumentPartitionerExtension2
Returns the position categories that this partitioners uses in order to manage the partitioning information of the documents. Returnsnull
if no position category is used.- Specified by:
getManagingPositionCategories
in interfaceIDocumentPartitionerExtension2
- Returns:
- the position categories used to manage partitioning information or
null
-
connect
public void connect(IDocument document)
Deprecated.Description copied from interface:IDocumentPartitioner
Connects the partitioner to a document. Connect indicates the begin of the usage of the receiver as partitioner of the given document. Thus, resources the partitioner needs to be operational for this document should be allocated.The 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 callconnect(document)
toconnect(document, false)
in order to sustain the same semantics.- Specified by:
connect
in interfaceIDocumentPartitioner
- Parameters:
document
- the document to be connected to
-
initialize
protected void initialize()
Deprecated.Performs the initial partitioning of the partitioner's document.
-
disconnect
public void disconnect()
Deprecated.Description copied from interface:IDocumentPartitioner
Disconnects the partitioner from the document it is connected to. Disconnect indicates the end of the usage of the receiver as partitioner of the connected document. Thus, resources the partitioner needed to be operation for its connected document should be deallocated.The caller of this method should also must ensure that this partitioner is no longer the document's partitioner.
- Specified by:
disconnect
in interfaceIDocumentPartitioner
-
documentAboutToBeChanged
public void documentAboutToBeChanged(DocumentEvent e)
Deprecated.Description copied from interface:IDocumentPartitioner
Informs about a forthcoming document change. Will be called by the connected document and is not intended to be used by clients other than the connected document.- Specified by:
documentAboutToBeChanged
in interfaceIDocumentPartitioner
- Parameters:
e
- the event describing the forthcoming change
-
documentChanged
public boolean documentChanged(DocumentEvent e)
Deprecated.Description copied from interface:IDocumentPartitioner
The document has been changed. The partitioner updates the document's partitioning and returns whether the structure of the document partitioning has been changed, i.e. whether partitions have been added or removed. Will be called by the connected document and is not intended to be used by clients other than the connected document.This method has been replaced by
IDocumentPartitionerExtension.documentChanged2(DocumentEvent)
.- Specified by:
documentChanged
in interfaceIDocumentPartitioner
- Parameters:
e
- the event describing the document change- Returns:
true
if partitioning changed
-
documentChanged2
public IRegion documentChanged2(DocumentEvent e)
Deprecated.Description copied from interface:IDocumentPartitionerExtension
The document has been changed. The partitioner updates the document's partitioning and returns the minimal region that comprises all partition changes caused in response to the given document event. This method returnsnull
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)
.- Specified by:
documentChanged2
in interfaceIDocumentPartitionerExtension
- Parameters:
e
- the event describing the document change- Returns:
- the region of the document in which the partition type changed or
null
-
findClosestPosition
protected TypedPosition findClosestPosition(int offset)
Deprecated.Returns the position in the partitoner's position category which is close to the given offset. This is, the position has either an offset which is the same as the given offset or an offset which is smaller than the given offset. This method profits from the knowledge that a partitioning is a ordered set of disjoint position.- Parameters:
offset
- the offset for which to search the closest position- Returns:
- the closest position in the partitioner's category
-
getContentType
public String getContentType(int offset)
Deprecated.Description copied from interface:IDocumentPartitioner
Returns the content type of the partition containing the given offset in the connected document. There must be a document connected to this partitioner.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);
- Specified by:
getContentType
in interfaceIDocumentPartitioner
- Parameters:
offset
- the offset in the connected document- Returns:
- the content type of the offset's partition
-
getPartition
public ITypedRegion getPartition(int offset)
Deprecated.Description copied from interface:IDocumentPartitioner
Returns the partition containing the given offset of the connected document. There must be a document connected to this partitioner.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);
- Specified by:
getPartition
in interfaceIDocumentPartitioner
- Parameters:
offset
- the offset for which to determine the partition- Returns:
- the partition containing the offset
-
computePartitioning
public ITypedRegion[] computePartitioning(int offset, int length)
Deprecated.Description copied from interface:IDocumentPartitioner
Returns the partitioning of the given range of the connected document. There must be a document connected to this partitioner.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);
- Specified by:
computePartitioning
in interfaceIDocumentPartitioner
- Parameters:
offset
- the offset of the range of interestlength
- the length of the range of interest- Returns:
- the partitioning of the range
-
getLegalContentTypes
public String[] getLegalContentTypes()
Deprecated.Description copied from interface:IDocumentPartitioner
Returns the set of all legal content types of this partitioner. I.e. any result delivered by this partitioner may not contain a content type which would not be included in this method's result.- Specified by:
getLegalContentTypes
in interfaceIDocumentPartitioner
- Returns:
- the set of legal content types
-
isSupportedContentType
protected boolean isSupportedContentType(String contentType)
Deprecated.Returns whether the given type is one of the legal content types.- Parameters:
contentType
- the content type to check- Returns:
true
if the content type is a legal content type
-
getTokenContentType
protected String getTokenContentType(IToken token)
Deprecated.Returns a content type encoded in the given token. If the token's data is notnull
and a string it is assumed that it is the encoded content type.- Parameters:
token
- the token whose content type is to be determined- Returns:
- the token's content type
-
getContentType
public String getContentType(int offset, boolean preferOpenPartitions)
Deprecated.Description copied from interface:IDocumentPartitionerExtension2
Returns the content type of the partition containing the given offset in the connected document. There must be a document connected to this partitioner.If
preferOpenPartitions
istrue
, precedence is given to an open partition ending atoffset
over a delimited partition starting atoffset
.This method replaces
IDocumentPartitioner.getContentType(int)
and behaves like it whenprepreferOpenPartitions
isfalse
, i.e. precedence is always given to the partition that does not end atoffset
.- Specified by:
getContentType
in interfaceIDocumentPartitionerExtension2
- Parameters:
offset
- the offset in the connected documentpreferOpenPartitions
-true
if precedence should be given to a open partition ending atoffset
over a delimited partition starting atoffset
- Returns:
- the content type of the offset's partition
-
getPartition
public ITypedRegion getPartition(int offset, boolean preferOpenPartitions)
Deprecated.Description copied from interface:IDocumentPartitionerExtension2
Returns the partition containing the given offset of the connected document. There must be a document connected to this partitioner.If
preferOpenPartitions
istrue
, precedence is given to an open partition ending atoffset
over a delimited partition starting atoffset
.This method replaces
IDocumentPartitioner.getPartition(int)
and behaves like it whenpreferOpenPartitions
isfalse
, i.e. precedence is always given to the partition that does not end atoffset
.- Specified by:
getPartition
in interfaceIDocumentPartitionerExtension2
- Parameters:
offset
- the offset for which to determine the partitionpreferOpenPartitions
-true
if precedence should be given to a open partition ending atoffset
over a delimited partition starting atoffset
- Returns:
- the partition containing the offset
-
computePartitioning
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions)
Deprecated.Description copied from interface:IDocumentPartitionerExtension2
Returns the partitioning of the given range of the connected document. There must be a document connected to this partitioner.If
includeZeroLengthPartitions
istrue
, a zero-length partition of an open partition type (usually the default partition) is included between two delimited partitions. If it isfalse
, no zero-length partitions are included.This method replaces
IDocumentPartitioner.computePartitioning(int, int)
and behaves like it whenincludeZeroLengthPartitions
isfalse
.- Specified by:
computePartitioning
in interfaceIDocumentPartitionerExtension2
- Parameters:
offset
- 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- Returns:
- the partitioning of the range
-
-