public class DefaultCharacterPairMatcher extends Object implements ICharacterPairMatcher, ICharacterPairMatcherExtension
LEFT, RIGHT| Constructor and Description |
|---|
DefaultCharacterPairMatcher(char[] chars)
Creates a new character pair matcher that matches characters within the default partitioning.
|
DefaultCharacterPairMatcher(char[] chars,
String partitioning)
Creates a new character pair matcher that matches the specified characters within the
specified partitioning.
|
DefaultCharacterPairMatcher(char[] chars,
String partitioning,
boolean caretEitherSideOfBracket)
Creates a new character pair matcher that matches the specified characters within the
specified partitioning.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears this pair matcher.
|
void |
dispose()
Disposes this pair matcher.
|
IRegion |
findEnclosingPeerCharacters(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.
|
int |
getAnchor()
Returns the anchor for the region of the matching peer characters.
|
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.
|
IRegion |
match(IDocument doc,
int offset)
Starting at the given offset, the matcher chooses a character close to this offset.
|
IRegion |
match(IDocument document,
int offset,
int length)
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.
|
public DefaultCharacterPairMatcher(char[] chars,
String partitioning)
{ start, end, start, end, ..., start, end }For instance:
char[] chars = new char[] {'(', ')', '{', '}', '[', ']'};
new DefaultCharacterPairMatcher(chars, ...);
chars - a list of characterspartitioning - the partitioning to match withinpublic DefaultCharacterPairMatcher(char[] chars,
String partitioning,
boolean caretEitherSideOfBracket)
{ start, end, start, end, ..., start, end }For instance:
char[] chars = new char[] {'(', ')', '{', '}', '[', ']'};
new DefaultCharacterPairMatcher(chars, ...);
chars - a list of characterspartitioning - the partitioning to match withincaretEitherSideOfBracket - controls the matching behavior. When true, the
matching peer will be found when the caret is placed either before or after a
character. When false, the matching peer will be found only when the
caret is placed after a character.public DefaultCharacterPairMatcher(char[] chars)
{ start, end, start, end, ..., start, end }For instance:
char[] chars= new char[] { '(', ')', '{', '}', '[', ']' };
new DefaultCharacterPairMatcher(chars);
chars - a list of characterspublic IRegion match(IDocument doc, int offset)
ICharacterPairMatcher
Since version 3.8 the recommended way for finding matching peers is to use
ICharacterPairMatcherExtension.match(IDocument, int, int)
.
match in interface ICharacterPairMatcherdoc - the document to work onoffset - the start offsetnull if there is no
peer character.public IRegion match(IDocument document, int offset, int length)
ICharacterPairMatcherExtensionmatch in interface ICharacterPairMatcherExtensiondocument - the document to work onoffset - the start offsetlength - the selection length which can be negative indicating right-to-left selectionnull if there is no
peer characterICharacterPairMatcherExtension.match(org.eclipse.jface.text.IDocument,
int, int)public IRegion findEnclosingPeerCharacters(IDocument document, int offset, int length)
ICharacterPairMatcherExtensionfindEnclosingPeerCharacters in interface ICharacterPairMatcherExtensiondocument - the document to work onoffset - the start offsetlength - the selection length which can be negative indicating right-to-left selectionnull if there is no
enclosing pairICharacterPairMatcherExtension.findEnclosingPeerCharacters(org.eclipse.jface.text.IDocument,
int, int)public boolean isMatchedChar(char ch)
ICharacterPairMatcherExtensionisMatchedChar in interface ICharacterPairMatcherExtensionch - the charactertrue if the the character is one of the characters matched by the pair
matcher, and false otherwiseICharacterPairMatcherExtension.isMatchedChar(char)public boolean isMatchedChar(char ch,
IDocument document,
int offset)
ICharacterPairMatcherExtensionClients 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.
isMatchedChar in interface ICharacterPairMatcherExtensionch - the characterdocument - the documentoffset - the offset in documenttrue if the the character is one of the characters matched by the pair
matcher, and false otherwiseICharacterPairMatcherExtension.isMatchedChar(char,
org.eclipse.jface.text.IDocument, int)public boolean isRecomputationOfEnclosingPairRequired(IDocument document, IRegion currentSelection, IRegion previousSelection)
ICharacterPairMatcherExtension
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
ICharacterPairMatcherExtension.findEnclosingPeerCharacters(IDocument, int, int) call can be expensive for some
clients.
isRecomputationOfEnclosingPairRequired in interface ICharacterPairMatcherExtensiondocument - the document to work oncurrentSelection - the current selection in the documentpreviousSelection - the previous selection in the documenttrue if the enclosing pair needs to be recomputed, false
otherwiseICharacterPairMatcherExtension.isRecomputationOfEnclosingPairRequired(org.eclipse.jface.text.IDocument,
org.eclipse.jface.text.IRegion, org.eclipse.jface.text.IRegion)public int getAnchor()
ICharacterPairMatchergetAnchor in interface ICharacterPairMatcherRIGHT or LEFTpublic void dispose()
ICharacterPairMatcherdispose in interface ICharacterPairMatcherpublic void clear()
ICharacterPairMatchermatch
method.clear in interface ICharacterPairMatcher
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.