Download Jar. Uses 2039K of libraries. Click here for Pure Java version (4663L/30K).
!759 import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.EnumDeclaration; import com.github.javaparser.ast.stmt.LocalClassDeclarationStmt; import com.github.javaparser.ast.Modifier; import com.github.javaparser.printer.*; p-center { S src = getServerTranspiled2(/*#1011235*/#1001649); CompilationUnit cu = javaParseCompilationUnit(src); printJavaParserTree(cu); new PrettyPrinterConfiguration ppconf; ppconf.setIndent(" "); S pp = cu.toString(ppconf); new PublicationVisitor().visit(cu, null); print(); swingDiff(pp, cu.toString(ppconf)); } static class PublicationVisitor extends VoidVisitorAdapter { void makePublic(Set<Modifier> modifiers) { modifiers.remove(Modifier.PRIVATE); modifiers.remove(Modifier.PROTECTED); modifiers.add(Modifier.PUBLIC); } public void visit(ClassOrInterfaceDeclaration n, O arg) { Node parent = n.getParentNode().get(); print("Class " + n.getName() + " parent: " + className(parent)); if (!parent instanceof LocalClassDeclarationStmt) makePublic(n.getModifiers()); super.visit(n, arg); } public void visit(FieldDeclaration n, O arg) { makePublic(n.getModifiers()); super.visit(n, arg); } public void visit(ConstructorDeclaration n, O arg) { Node parent = n.getParentNode().get(); print("Constructor parent: " + className(parent)); if (!parent instanceof EnumDeclaration) makePublic(n.getModifiers()); super.visit(n, arg); } public void visit(MethodDeclaration n, O arg) { EnumSet<Modifier> m = n.getModifiers(); //print("Method found: " + n.getName() + " with modifiers: " + m + ", position: " + n.getRange()->begin); if (m.contains(Modifier.PRIVATE)) m.add(Modifier.FINAL); makePublic(m); super.visit(n, arg); } }
Began life as a copy of #1011229
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011232 |
Snippet name: | Test making all fields, methods & classes public in Java source [OK] |
Eternal ID of this version: | #1011232/27 |
Text MD5: | 99d0f4feec12e989d0b84606df4db6cd |
Transpilation MD5: | 54ba4ea517a279c0248e9bcb6569fffa |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-19 23:00:02 |
Source code size: | 1890 bytes / 58 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 610 / 1257 |
Version history: | 26 change(s) |
Referenced in: | #1011234 - javaParser_makeAllPublic (OLD) - also pretty-prints whole source |