Class DefaultCharacterPairMatcher

    • Constructor Summary

      Constructors 
      Constructor 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
    • Constructor Detail

      • 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