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
A specific single line rule which stipulates that the start
and end sequence occur within a single word, as defined by a word detector.
Originally since unknown version, but moved to org.eclipse.text in 3.14
- Since:
- 3.14
- See Also:
-
Field Summary
Fields inherited from class org.eclipse.jface.text.rules.PatternRule
fBreaksOnEOF, fBreaksOnEOL, fColumn, fEndSequence, fEscapeCharacter, fEscapeContinuesLine, fStartSequence, fToken, UNDEFINED
-
Constructor Summary
ConstructorDescriptionWordPatternRule
(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
Modifier and TypeMethodDescriptionprotected 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 Details
-
fDetector
The word detector used by this rule
-
-
Constructor Details
-
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 Details
-
endSequenceDetected
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
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
-