Libraryless. Click here for Pure Java version (5239L/29K).
1 | static int linesOfCode_javaTok(S text) {
|
2 | LS tok = javaTok(text); |
3 | int lines = 0; |
4 | bool codeInCurrentLine; |
5 | for i over tok: {
|
6 | S t = tok.get(i); |
7 | if (odd(i)) {
|
8 | // code token |
9 | int lTok = l(t); |
10 | for j to lTok: {
|
11 | char c = t.charAt(j); |
12 | if (c == '\n') |
13 | codeInCurrentLine = false; |
14 | else if (!isSpaceEtc(c) && !codeInCurrentLine) {
|
15 | set codeInCurrentLine; |
16 | ++lines; |
17 | } |
18 | } |
19 | } else {
|
20 | // space token |
21 | if (codeInCurrentLine && containsNewLine(t)) codeInCurrentLine = false; |
22 | } |
23 | } |
24 | |
25 | ret lines; |
26 | } |
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: | 404 / 533 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |