Package org.eclipse.jface.text.source
Interface ICharacterPairMatcherExtension
- All Known Implementing Classes:
DefaultCharacterPairMatcher
public interface ICharacterPairMatcherExtension
Extension interface for
ICharacterPairMatcher
.
Extends the character pair matcher with the concept of matching peer character and enclosing peer characters for a given selection.
- Since:
- 3.8
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfindEnclosingPeerCharacters
(IDocument document, int offset, int length) Starting at the given selection, the matcher searches for a pair of enclosing peer characters and if it finds one, returns the minimal region of the document that contains the pair.boolean
isMatchedChar
(char ch) Checks whether the character is one of the characters matched by the pair matcher.boolean
isMatchedChar
(char ch, IDocument document, int offset) Checks whether the character is one of the characters matched by the pair matcher.boolean
isRecomputationOfEnclosingPairRequired
(IDocument document, IRegion currentSelection, IRegion previousSelection) Computes whether a client needs to recompute the enclosing pair after a selection change in the document.Starting at the given offset (i.e. length 0) or the selected character, the matcher searches for the matching peer character and if it finds one, returns the minimal region of the document that contains both characters.
-
Method Details
-
match
Starting at the given offset (i.e. length 0) or the selected character, the matcher searches for the matching peer character and if it finds one, returns the minimal region of the document that contains both characters.- Parameters:
document
- the document to work onoffset
- the start offsetlength
- the selection length which can be negative indicating right-to-left selection- Returns:
- the minimal region containing the peer characters or
null
if there is no peer character
-
findEnclosingPeerCharacters
Starting at the given selection, the matcher searches for a pair of enclosing peer characters and if it finds one, returns the minimal region of the document that contains the pair.- Parameters:
document
- the document to work onoffset
- the start offsetlength
- the selection length which can be negative indicating right-to-left selection- Returns:
- the minimal region containing the peer characters or
null
if there is no enclosing pair
-
isMatchedChar
boolean isMatchedChar(char ch) Checks whether the character is one of the characters matched by the pair matcher.- Parameters:
ch
- the character- Returns:
true
if the the character is one of the characters matched by the pair matcher, andfalse
otherwise
-
isMatchedChar
Checks whether the character is one of the characters matched by the pair matcher.Clients can use this method to handle characters which may have special meaning in some situations. E.g. in Java, '<' is used as an angular bracket and as well as less-than operator.
- Parameters:
ch
- the characterdocument
- the documentoffset
- the offset in document- Returns:
true
if the the character is one of the characters matched by the pair matcher, andfalse
otherwise
-
isRecomputationOfEnclosingPairRequired
boolean isRecomputationOfEnclosingPairRequired(IDocument document, IRegion currentSelection, IRegion previousSelection) Computes whether a client needs to recompute the enclosing pair after a selection change in the document.This is intended to be a quick test to determine whether a re-computation of the enclosing pair is required, as the re-computation after each selection change via a
findEnclosingPeerCharacters(IDocument, int, int)
call can be expensive for some clients.- Parameters:
document
- the document to work oncurrentSelection
- the current selection in the documentpreviousSelection
- the previous selection in the document- Returns:
true
if the enclosing pair needs to be recomputed,false
otherwise
-