Class DefaultCharacterPairMatcher

java.lang.Object
org.eclipse.jface.text.source.DefaultCharacterPairMatcher
All Implemented Interfaces:
ICharacterPairMatcher, ICharacterPairMatcherExtension

public class DefaultCharacterPairMatcher extends Object implements ICharacterPairMatcher, ICharacterPairMatcherExtension
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.
Since:
3.3
  • Field Summary

    Fields inherited from interface org.eclipse.jface.text.source.ICharacterPairMatcher

    LEFT, RIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    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

    Modifier and Type
    Method
    Description
    void
    Clears this pair matcher.
    void
    Disposes this pair matcher.
    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
    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.
    match(IDocument doc, int offset)
    Starting at the given offset, the matcher chooses a character close to this offset.
    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 Details

    • DefaultCharacterPairMatcher

      public DefaultCharacterPairMatcher(char[] chars, String partitioning)
      Creates a new character pair matcher that matches the specified characters within the specified partitioning. The specified list of characters must have the form
      { start, end, start, end, ..., start, end }
      For instance:
       char[] chars = new char[] {'(', ')', '{', '}', '[', ']'};
       new DefaultCharacterPairMatcher(chars, ...);
       
      Parameters:
      chars - a list of characters
      partitioning - the partitioning to match within
    • DefaultCharacterPairMatcher

      public DefaultCharacterPairMatcher(char[] chars, String partitioning, boolean caretEitherSideOfBracket)
      Creates a new character pair matcher that matches the specified characters within the specified partitioning. The specified list of characters must have the form
      { start, end, start, end, ..., start, end }
      For instance:
       char[] chars = new char[] {'(', ')', '{', '}', '[', ']'};
       new DefaultCharacterPairMatcher(chars, ...);
       
      Parameters:
      chars - a list of characters
      partitioning - the partitioning to match within
      caretEitherSideOfBracket - 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.
      Since:
      3.8
    • DefaultCharacterPairMatcher

      public DefaultCharacterPairMatcher(char[] chars)
      Creates a new character pair matcher that matches characters within the default partitioning. The specified list of characters must have the form
      { start, end, start, end, ..., start, end }
      For instance:
       char[] chars= new char[] { '(', ')', '{', '}', '[', ']' };
       new DefaultCharacterPairMatcher(chars);
       
      Parameters:
      chars - a list of characters
  • Method Details