Package org.eclipse.jface.text.rules
Class WordPatternRule
- java.lang.Object
-
- org.eclipse.jface.text.rules.PatternRule
-
- org.eclipse.jface.text.rules.SingleLineRule
-
- org.eclipse.jface.text.rules.WordPatternRule
-
- All Implemented Interfaces:
IPredicateRule
,IRule
public class WordPatternRule extends SingleLineRule
A specific single line rule which stipulates that the start and end sequence occur within a single word, as defined by a word detector.- See Also:
IWordDetector
-
-
Field Summary
Fields Modifier and Type Field Description protected IWordDetector
fDetector
The word detector used by this rule-
Fields inherited from class org.eclipse.jface.text.rules.PatternRule
fBreaksOnEOF, fBreaksOnEOL, fColumn, fEndSequence, fEscapeCharacter, fEscapeContinuesLine, fStartSequence, fToken, UNDEFINED
-
-
Constructor Summary
Constructors Constructor Description WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token)
Creates a rule for the given starting and ending word pattern which, if detected, will return the specified token.WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token, char escapeCharacter)
/** Creates a rule for the given starting and ending word pattern which, if detected, will return the specified token.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
endSequenceDetected(ICharacterScanner scanner)
Returns whether the end sequence was detected.protected void
unreadBuffer(ICharacterScanner scanner)
Returns the characters in the buffer to the scanner.-
Methods inherited from class org.eclipse.jface.text.rules.PatternRule
doEvaluate, doEvaluate, evaluate, evaluate, getSuccessToken, sequenceDetected, setColumnConstraint
-
-
-
-
Field Detail
-
fDetector
protected IWordDetector fDetector
The word detector used by this rule
-
-
Constructor Detail
-
WordPatternRule
public WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token)
Creates a rule for the given starting and ending word pattern which, if detected, will return the specified token. A word detector is used to identify words.- Parameters:
detector
- the word detector to be usedstartSequence
- the start sequence of the word patternendSequence
- the end sequence of the word patterntoken
- the token to be returned on success
-
WordPatternRule
public WordPatternRule(IWordDetector detector, String startSequence, String endSequence, IToken token, char escapeCharacter)
/** Creates a rule for the given starting and ending word pattern which, if detected, will return the specified token. A word detector is used to identify words. Any character which follows the given escapeCharacter will be ignored.- Parameters:
detector
- the word detector to be usedstartSequence
- the start sequence of the word patternendSequence
- the end sequence of the word patterntoken
- the token to be returned on successescapeCharacter
- the escape character
-
-
Method Detail
-
endSequenceDetected
protected boolean endSequenceDetected(ICharacterScanner scanner)
Returns whether the end sequence was detected. The rule acquires the rest of the word, using the provided word detector, and tests to determine if it ends with the end sequence.- Overrides:
endSequenceDetected
in classPatternRule
- Parameters:
scanner
- the scanner to be used- Returns:
true
if the word ends on the given end sequence
-
unreadBuffer
protected void unreadBuffer(ICharacterScanner scanner)
Returns the characters in the buffer to the scanner. Note that the rule must also return the characters read in as part of the start sequence expect the first one.- Parameters:
scanner
- the scanner to be used
-
-