boolean skipCommentLines, boolean skipStrings) throws BadLocationException {
int deep = 0;
int i = offset;
if (forward) {
while (i < d.getLength()) {
ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, i, true);
if (region.getType() == RutaPartitions.RUTA_COMMENT && skipCommentLines) {
i = region.getOffset() + region.getLength();
continue;
}
if (region.getType() == RutaPartitions.RUTA_STRING && skipStrings) {
i = region.getOffset() + region.getLength();
continue;
}
char c = d.getChar(i);
if (c == opening)
deep++;
if (c == closing) {
if (deep == 0)
return i;
deep--;
}
i++;
if (i - offset > maxCharsAway)
return -1;
}
} else {
while (i >= 0) {
ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, i, true);
if (region.getType() == RutaPartitions.RUTA_COMMENT && skipCommentLines) {
i = region.getOffset() - 1;
continue;
}
if (region.getType() == RutaPartitions.RUTA_STRING && skipStrings) {
i = region.getOffset() - 1;
continue;
}
char c = d.getChar(i);
if (c == closing)
deep++;