I try to add new FieldDeclarations
to my Main
Class in CompilationUnit
before all other existing FieldDeclarations
.
mainClassInCompilationUnitDeclaration.addPrivateField("Type", "fieldName");
Where mainClassInCompilationUnitDeclaration
is a ClassOrInterfaceDeclaration
representing the first declared Class in the CompilationUnit
.
Unfortunately, all added Declarations get serialized on the end of the class. This is logical as the elements are added at the end of the tree.
How can I change where they get added?
Is there any "insertBefore" in Javaparser
?