private List<IRegion> findAllMatches(String query, boolean isRegex, boolean caseSensitive) {
final IDocument document = viewer.getDocument();
if(query.isEmpty() || document == null) {
return Collections.emptyList();
}
final FindReplaceDocumentAdapter search = new FindReplaceDocumentAdapter(document);
final ArrayList<IRegion> results = new ArrayList<IRegion>();
int offset = 0;
while(true) {
if(offset >= document.getLength()) {
return results;
}
try {
IRegion match = search.find(offset, query, true, caseSensitive, false, isRegex);
if(match == null) {
return results;
}
results.add(match);
offset = match.getOffset() + match.getLength();