commentStartPos static method
Implementation
static int commentStartPos(String source, int startPos) {
// Find the first occurrence of "//" in this line that
// is not within a string literal.
int commentStart = startPos - 2;
while (true) {
commentStart = source.indexOf("//", commentStart + 2);
if (commentStart < 0) break; // no comment found
if (!isInStringLiteral(commentStart, source, startPos)) {
break; // valid comment
}
}
return commentStart;
}