Libraryless. Click here for Pure Java version (4759L/28K).
// adds default constructor to classes with "persistable" modifier // also allows "persistent" svoid tok_persistableClasses(LS tok) { int i; while((i = jfind_any(tok, tokCondition { for (int j = i+1; isIdentifier(_get(tok, j)); j += 2) if (eqGet(tok, j, "class")) true; false; }, "persistable", "persistent")) >= 0) { int iClass = indexOf(tok, "class", i); S className = get(tok, iClass+2); int idx = indexOf(tok, iClass, "{"); int j = findEndOfBracketPart(tok, idx); L<S> contents = subList(tok, idx+1, j); bool hasDefaultConstructor = tok_hasDefaultConstructor(contents, className); printVars_str("tok_persistableClasses: ", +hasDefaultConstructor, +className); if (!hasDefaultConstructor) tokAppend_reTok(tok, idx, "\n *() {}"); clearTokens_reTok(tok, i, i+2); // drop persistable keyword } }
Began life as a copy of #1012742
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: | #1028735 |
| Snippet name: | tok_persistableClasses |
| Eternal ID of this version: | #1028735/8 |
| Text MD5: | 6d75c21f76b30360ef19cf6d96109f35 |
| Transpilation MD5: | 1258d21a9018e207bf8f65904acd0f57 |
| Author: | stefan |
| Category: | javax / parsing |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-09-30 04:32:48 |
| Source code size: | 893 bytes / 23 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 491 / 657 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |