Libraryless. Click here for Pure Java version (5239L/29K).
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; }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1034197 | 
| Snippet name: | linesOfCode_javaTok - lines of code without empty lines and comments (not rigorously tested but seems to work) | 
| Eternal ID of this version: | #1034197/3 | 
| Text MD5: | f349517f08f059a6da0b876536abaf5d | 
| Transpilation MD5: | 9722fd496fec14f3e655dafd66d73efa | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2022-01-28 21:04:42 | 
| Source code size: | 617 bytes / 26 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 403 / 532 | 
| Version history: | 2 change(s) | 
| Referenced in: | [show references] |