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 notnull
then this scanner will first try the rules that match the given content type.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description protected String
fContentType
The content type of the partition in which to resume scanning.protected int
fPartitionOffset
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
Constructors Constructor Description RuleBasedPartitionScanner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IToken
nextToken()
Returns 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
setRange(IDocument document, int offset, int length)
Configures the scanner by providing access to the document range that should be scanned.void
setRules(IRule[] rules)
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 Detail
-
fContentType
protected String fContentType
The content type of the partition in which to resume scanning.
-
fPartitionOffset
protected int fPartitionOffset
The offset of the partition inside which to resume.
-
-
Method Detail
-
setRules
public void setRules(IRule[] rules)
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
public void setPredicateRules(IPredicateRule[] rules)
-
setRange
public void setRange(IDocument document, int offset, int length)
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
public IToken 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
-
-