INRIA / INRIA/spoon

SniperPrettyPrinter - Adding a new access modifier when there were none results in omitted whites spaces

Open
#4,217 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2k
Forks
392
Avg merge
11h 24m
Merged PRs (30d)
36

Description

When using SniperPrettyPrinter, for the below input the expected output is not generated. For some reason spoon is omitting the space after newly added access modifier.

Input :
`CtConstructorProcessorProtected(String arg1, int arg2) {
this.arg1 = arg1;
this.arg2 = arg2;
}`
Expected :
`protected CtConstructorProcessorProtected( java.lang.String arg1, int arg2, float arg3) {
this.arg1 = arg1;
this.arg2 = arg2;
}`
Actual :
`protectedCtConstructorProcessorProtected( java.lang.String arg1, int arg2, float arg3) {
this.arg1 = arg1;
this.arg2 = arg2;
}`

Code used for this transformation :
`@Override
public void process(CtConstructor element) {
final Set modifiedSet = new HashSet<>();
modifiedSet.add(ModifierKind.PROTECTED);

element.setModifiers(modifiedSet);
}`

Spoon print config :
`launcher.getEnvironment().setPrettyPrinterCreator(() -> new SniperJavaPrettyPrinter(launcher.getEnvironment()));`

Spoon version : 9.1.0-beta-10

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.