protected boolean matchBracketsAt() {
        if (curPos == 0) {
            return false;
        }
        char prevChar, nextChar;
        int i;
        int bracketIndex1 = fgBrackets.length;
        int bracketIndex2 = fgBrackets.length;

        startPos = -1;
        endPos = -1;

        // Get the chars preceding and following the start position.
        try {
            IDocument doc = fText.getDocument();
            prevChar = doc.getChar(curPos - 1);
            nextChar = doc.getChar(curPos);

            // Is the char either an open or close bracket?
            for (i= 0; i < fgBrackets.length; i = i + 2) {
                if (prevChar == fgBrackets[i]) {
                    startPos = curPos - 1;
                    bracketIndex1 = i;
                }
            }
            for (i= 1; i < fgBrackets.length; i = i + 2) {
                if (nextChar == fgBrackets[i]) {
                    endPos = curPos;
                    bracketIndex2 = i;
                }
            }

            // If we found an open bracket, find the matching closing bracket.
            if (startPos > -1 && bracketIndex1 < bracketIndex2) {
                endPos = searchForClosingBracket(startPos, prevChar, fgBrackets[bracketIndex1 + 1], doc );
                if (endPos > -1)
                    return true;

                startPos = -1;
            }
            // Otherwise if we found a closing bracket, find the matching open bracket.
            else if (endPos > -1) {
                startPos = searchForOpenBracket(endPos, fgBrackets[bracketIndex2 - 1], nextChar, doc );
                if (startPos > -1)
                    return true;

                endPos = -1;
            }

        } catch (BadLocationException x) {
            log.debug(x);
        }

        return false;
    }
Attempts to find and match opening or closing brackets just ahead of the
double click location.  Sets fStartPos and fEndPos to the bracket locations
if found.

@return true if brackets found and matched, otherwise false
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/syntax/SQLDoubleClickStrategy.java