Menu

#96 PrettyPrinter2

open
nobody
Services (48)
5
2012-10-08
2011-12-04
Anonymous
No

The aim of below code is to change the visibility of a filed to package:
public void transform(){
super.transform();
VisibilityModifier visMod=fd.getVisibilityModifier();
if (visMod instanceof Private)
detach(visMod)
}

While the code changes visibility of fd to package. However, it also shifts field one line up. As an example see “firstName” in below example:

Input:
Public class Person{
//comment
private String firstName;
}

Output:
public class Person{
//comment String firstName;
}

It creates a compiler error if firstName is referenced in the program.

Discussion


Log in to post a comment.