Libraryless. Click here for Pure Java version (7636L/46K).
1 | // e.g.: |
2 | // sclass Bla extends Stages & Var<S> { |
3 | |
4 | svoid tok_andVarMixIn(LS tok) { |
5 | for (i : jfindAll_reversed_any(tok, |
6 | "& Var<<id>> {", |
7 | "& Var<<id><<id>>> {")) { |
8 | int iOpening = indexOf(tok, i, "{"); |
9 | S valueType = tok_scanTypeArgWithoutBrackets(tok, indexOf(tok, i, "<")); |
10 | |
11 | int iClosing = tok_endOfBracketPart(tok, iOpening)-1; |
12 | |
13 | // get Var include |
14 | LS tokVar = javaTok(cacheGet(#1032845)); |
15 | jreplace(tokVar, "A", valueType); |
16 | |
17 | // find code that is to be executed before get() returns a result |
18 | int iGet = jfind_upTo(tok, iOpening, iClosing, "get :: before {"); |
19 | if (iGet >= 0) { |
20 | int iOpening2 = indexOf(tok, iGet, "{"); |
21 | int iClosing2 = tok_endOfBracketPart(tok, iOpening2)-1; |
22 | S code = joinSubList(tok, iOpening2+1, iClosing2); |
23 | jreplace1(tokVar, "get() {", "get() {" + code); |
24 | clearTokens_reTok(tok, iGet, iClosing2+1); |
25 | } |
26 | |
27 | tokReplace_reTok(tok, iOpening+1, "\n" |
28 | + join(tokVar) + "\n"); |
29 | tokReplace_reTok(tok, i, i+3, "implements IVar"); |
30 | } |
31 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032846 |
Snippet name: | tok_andVarMixIn |
Eternal ID of this version: | #1032846/20 |
Text MD5: | 52835a56d52f33676253f8293b6b96d9 |
Transpilation MD5: | 791e16d302ba65617714121e4ed9a144 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-06 22:01:30 |
Source code size: | 1073 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 212 / 367 |
Version history: | 19 change(s) |
Referenced in: | [show references] |