Interface ICharacterPairMatcherExtension

    • Method Summary

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

      • match

        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.
        Parameters:
        document - the document to work on
        offset - the start offset
        length - 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

        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.
        Parameters:
        document - the document to work on
        offset - the start offset
        length - 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, and false otherwise
      • isMatchedChar

        boolean isMatchedChar​(char ch,
                              IDocument document,
                              int offset)
        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 character
        document - the document
        offset - the offset in document
        Returns:
        true if the the character is one of the characters matched by the pair matcher, and false 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 on
        currentSelection - the current selection in the document
        previousSelection - the previous selection in the document
        Returns:
        true if the enclosing pair needs to be recomputed, false otherwise