|
Eclipse Platform Release 4.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.jface.text.source.DefaultCharacterPairMatcher
public class DefaultCharacterPairMatcher
A character pair matcher that matches a specified set of character pairs against each other. Only characters that occur in the same partitioning are matched.
| Field Summary |
|---|
| Fields inherited from interface org.eclipse.jface.text.source.ICharacterPairMatcher |
|---|
LEFT, RIGHT |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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 within
public 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 characters| Method Detail |
|---|
public 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 offset
null if there is no
peer character.
public IRegion match(IDocument document,
int offset,
int length)
ICharacterPairMatcherExtension
match in interface ICharacterPairMatcherExtensiondocument - the document to work onoffset - the start offsetlength - the selection length which can be negative indicating right-to-left selection
null if there is no
peer characterICharacterPairMatcherExtension.match(org.eclipse.jface.text.IDocument,
int, int)
public IRegion findEnclosingPeerCharacters(IDocument document,
int offset,
int length)
ICharacterPairMatcherExtension
findEnclosingPeerCharacters in interface ICharacterPairMatcherExtensiondocument - the document to work onoffset - the start offsetlength - the selection length which can be negative indicating right-to-left selection
null if there is no
enclosing pairICharacterPairMatcherExtension.findEnclosingPeerCharacters(org.eclipse.jface.text.IDocument,
int, int)public boolean isMatchedChar(char ch)
ICharacterPairMatcherExtension
isMatchedChar in interface ICharacterPairMatcherExtensionch - the character
true 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 document
true 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 document
true 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()
ICharacterPairMatcher
getAnchor in interface ICharacterPairMatcherRIGHT or LEFTpublic void dispose()
ICharacterPairMatcher
dispose in interface ICharacterPairMatcherpublic void clear()
ICharacterPairMatchermatch
method.
clear in interface ICharacterPairMatcher
|
Eclipse Platform Release 4.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2012. All rights reserved.