Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Calling printTypes on SniperJavaPrettyPrinter always causes a NullPointerException #3675

Closed
slarse opened this issue Nov 3, 2020 · 0 comments · Fixed by #3676
Closed

Comments

@slarse
Copy link
Collaborator

slarse commented Nov 3, 2020

Hi,

The printTypes method is broken for SniperJavaPrettyPrinter, it always causes a NullPointerException. It's caused by the implementation of printTypes in DefaultJavaPrettyPrinter passing null for the CU to calculate

@Override
public String printTypes(CtType<?>... type) {
calculate(null, Arrays.asList(type));
return getResult();
}

and the SniperJavaPrettyPrinter assuming that the CU is not null

public void calculate(CtCompilationUnit compilationUnit, List<CtType<?>> types) {
sourceCompilationUnit = compilationUnit;
//use line separator of origin source file
setLineSeparator(detectLineSeparator(compilationUnit.getOriginalSourceCode()));

I don't think it's possible for the sniper printer to do its job without the CU. Working on a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant