FindResult () { FindResult occurrence = getOccurrenceAtCaret(); if (occurrence != null) return occurrence; occurrence = getFirstOccurrenceInSelection(); if (occurrence != null) return occurrence; return firstOccurrenceAfterCaret(); }