google / error-prone

Catch common Java mistakes as compile-time errors
https://errorprone.info
Apache License 2.0
6.83k stars 742 forks source link

Use text blocks for more Error Prone test outputs #4575

Closed copybara-service[bot] closed 2 weeks ago

copybara-service[bot] commented 2 weeks ago

Use text blocks for more Error Prone test outputs

I skipped reformatted these ones, because reformatting would cause some tests to fail, because of examples like

// BUG: Diagnostic contains
@Override void f() {}
// BUG: Diagnostic contains
@Override
void f() {} // <- the diagnostic is actually on this line
rickie commented 2 weeks ago

@cushon I'm curious how you did this 😄.

Did you write a check internally? Or did you by any chance use something from this PR https://github.com/PicnicSupermarket/error-prone-support/pull/198?

cushon commented 2 weeks ago

@cushon I'm curious how you did this 😄.

Did you write a check internally? Or did you by any chance use something from this PR PicnicSupermarket/error-prone-support#198?

@rickie I ended up creating a separate command-line tool that used javac's parser and heuristics to find APIs like this and migrate them for text blocks. The goal was to have something more general that could migrate other similar APIs, e.g. these ones in Bazel

I'd also like to have a way to keep these tests formatted, so your TestHelperSourceFormat seems like a good approach for that!

rickie commented 6 days ago

Thanks for the explanation @cushon .

I'd also like to have a way to keep these tests formatted, so your TestHelperSourceFormat seems like a good approach for that!

We aim to finish the improvements for the text blocks PR and thus the TestHelperSourceFormat in the coming weeks.

Would you be up for a PR here to upstream this check once we finished it?

One thing we would also like to fix (and probably put behind a flag) is to support this request from @msridhar https://github.com/PicnicSupermarket/error-prone-support/issues/474.

cushon commented 6 days ago

Would you be up for a PR here to upstream this check once we finished it?

That sounds great, I'd be happy to review a PR!