List<LinkMatch> (CharSequence text) { final List<LinkMatch> result = new ArrayList<>(); try { for (IssueNavigationLink link : myLinks) { findIssueLinkMatches(text, link, result); } TextRange match; int lastOffset = 0; while ((match = URLUtil.findUrl(text, lastOffset, text.length())) != null) { addMatch(result, match, match.subSequence(text).toString()); lastOffset = match.getEndOffset(); } } catch (ProcessCanceledException e) { //skip too long processing completely } Collections.sort(result); return result; }