Libraryless. Click here for Pure Java version (3505L/21K).
1 | // new Type var; => Type var = new Type; |
2 | // new Type<...> var; => Type var = new Type; |
3 | svoid tok_quicknew(LS tok) { |
4 | int i = -1; |
5 | while ((i = jfind(tok, i+1, "new <id>")) >= 0) { |
6 | int j = tok_findEndOfType(tok, i+2); |
7 | if (isIdentifier(get(tok, j)) && eqGetOneOf(tok, j+2, ";", ",")) { |
8 | LS vars = ll(get(tok, j)); |
9 | int k = j; |
10 | while (eqGet(tok, k+2, ",") && isIdentifier(get(tok, k+4))) { |
11 | k += 4; |
12 | vars.add(tok.get(k)); |
13 | } |
14 | S type = joinSubList(tok, i+2, j-1); |
15 | if (!contains(type, ".")) type = tok.get(i+2); |
16 | clearTokens(tok, i, i+2); |
17 | for iVar over vars: |
18 | tokAppend(tok, j+iVar*4, " = new " + type + "()"); |
19 | reTok(tok, i, k+3); |
20 | } |
21 | } |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1025749 |
Snippet name: | tok_quicknew - new implementation of quickNew |
Eternal ID of this version: | #1025749/14 |
Text MD5: | b12f7f86d056d434621a78af61c00441 |
Transpilation MD5: | d21bce3ea738263b6df3d3bf4e2a2be4 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-18 20:51:44 |
Source code size: | 736 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 276 / 448 |
Version history: | 13 change(s) |
Referenced in: | [show references] |