static int linesOfCode_javaTok(S text) { LS tok = javaTok(text); int lines = 0; bool codeInCurrentLine; for i over tok: { S t = tok.get(i); if (odd(i)) { // code token int lTok = l(t); for j to lTok: { char c = t.charAt(j); if (c == '\n') codeInCurrentLine = false; else if (!isSpaceEtc(c) && !codeInCurrentLine) { set codeInCurrentLine; ++lines; } } } else { // space token if (codeInCurrentLine && containsNewLine(t)) codeInCurrentLine = false; } } ret lines; }