Package org.eclipse.jface.text.rules
Class RuleBasedPartitionScanner
java.lang.Object
org.eclipse.jface.text.rules.RuleBasedScanner
org.eclipse.jface.text.rules.BufferedRuleBasedScanner
org.eclipse.jface.text.rules.RuleBasedPartitionScanner
- All Implemented Interfaces:
ICharacterScanner
,IPartitionTokenScanner
,ITokenScanner
public class RuleBasedPartitionScanner
extends BufferedRuleBasedScanner
implements IPartitionTokenScanner
Scanner that exclusively uses predicate rules.
If a partial range is set (see setPartialRange(IDocument, int, int, String, int)
with
content type that is not null
then this scanner will first try the rules that match
the given content type.
- Since:
- 3.14
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The content type of the partition in which to resume scanning.protected int
The offset of the partition inside which to resume.Fields inherited from class org.eclipse.jface.text.rules.RuleBasedScanner
fColumn, fDefaultReturnToken, fDelimiters, fDocument, fOffset, fRangeEnd, fRules, fTokenOffset, UNDEFINED
Fields inherited from interface org.eclipse.jface.text.rules.ICharacterScanner
EOF
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the next token in the document.void
setPartialRange
(IDocument document, int offset, int length, String contentType, int partitionOffset) Configures the scanner by providing access to the document range that should be scanned.void
setPredicateRules
(IPredicateRule[] rules) void
Configures the scanner by providing access to the document range that should be scanned.void
Disallow setting the rules since this scanner exclusively uses predicate rules.Methods inherited from class org.eclipse.jface.text.rules.BufferedRuleBasedScanner
read, setBufferSize, unread
Methods inherited from class org.eclipse.jface.text.rules.RuleBasedScanner
getColumn, getLegalLineDelimiters, getTokenLength, getTokenOffset, setDefaultReturnToken
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jface.text.rules.ITokenScanner
getTokenLength, getTokenOffset
-
Field Details
-
fContentType
The content type of the partition in which to resume scanning. -
fPartitionOffset
protected int fPartitionOffsetThe offset of the partition inside which to resume.
-
-
Constructor Details
-
RuleBasedPartitionScanner
public RuleBasedPartitionScanner()
-
-
Method Details
-
setRules
Disallow setting the rules since this scanner exclusively uses predicate rules.- Overrides:
setRules
in classRuleBasedScanner
- Parameters:
rules
- the sequence of rules controlling this scanner
-
setPredicateRules
-
setRange
Description copied from interface:ITokenScanner
Configures the scanner by providing access to the document range that should be scanned.- Specified by:
setRange
in interfaceITokenScanner
- Overrides:
setRange
in classBufferedRuleBasedScanner
- Parameters:
document
- the document to scanoffset
- the offset of the document range to scanlength
- the length of the document range to scan
-
setPartialRange
public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) Configures the scanner by providing access to the document range that should be scanned. The range may not only contain complete partitions but starts at the beginning of a line in the middle of a partition of the given content type. This requires that a partition delimiter can not contain a line delimiter.If the given content type is not
null
then this scanner will first try the rules that match the given content type.- Specified by:
setPartialRange
in interfaceIPartitionTokenScanner
- Parameters:
document
- the document to scanoffset
- the offset of the document range to scanlength
- the length of the document range to scancontentType
- the content type at the given offsetpartitionOffset
- the offset at which the partition of the given offset starts
-
nextToken
Description copied from interface:ITokenScanner
Returns the next token in the document.- Specified by:
nextToken
in interfaceITokenScanner
- Overrides:
nextToken
in classRuleBasedScanner
- Returns:
- the next token in the document
-