use of org.eclipse.titan.common.parsers.Interval in project titan.EclipsePlug-ins by eclipse.
the class HeuristicalIntervalDetector method isWithinString.
/**
* The method determines if the given offset is within a string in the
* document.
*
* @param document
* the document being parsed
* @param offset
* the position where parsing starts from
* @param enclosingInterval
* an interval, which encloses the offset
* @return Whether offset is within a comment.
* @exception BadLocationException
* if the offset is invalid in this document
*/
// FIXME needs correction
@Override
public boolean isWithinString(final StringBuilder document, final int offset, final Interval enclosingInterval) throws BadLocationException {
Interval interval = enclosingInterval.getSmallestEnclosingInterval(offset);
if (interval_type.MULTILINE_COMMENT.equals(interval.getType()) || interval_type.SINGLELINE_COMMENT.equals(interval.getType())) {
return false;
}
int start = interval.getStartOffset();
int counter = 0;
while (start < offset) {
char curr = document.charAt(start);
if (curr == '"') {
counter++;
}
start++;
}
return counter % 2 != 0;
}
Aggregations