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

Integrate Java compiler with the problems API #27596

Closed
22 of 23 tasks
hegyibalint opened this issue Jan 5, 2024 · 2 comments
Closed
22 of 23 tasks

Integrate Java compiler with the problems API #27596

hegyibalint opened this issue Jan 5, 2024 · 2 comments
Assignees
Labels
a:epic @ide-experience Issues owned by the IDE Experience team
Milestone

Comments

@hegyibalint
Copy link
Member

hegyibalint commented Jan 5, 2024

Goal

The Java compiler outputs compilation problems directly to the standard output. The problem with that is that the information is buried in the build output, and users must scroll up in the build log to figure out what made the build fail. This is a subpar experience, which we could improve by integrating the compiler task with the Problems API. By using the API, we can create a comprehensive report at the end of the build.

In addition to the reporting capabilities, structured problems could help IDEs and tools establish what went wrong and where. This is already the case in some of the tools, but it relies on parsing the console output vs. receiving well-defined, structured information about what happened. As an example, build scans can render a separated, focused report about compilation problems, which doesn't rely on the console output.

Resources

Deliverables

  • Custom DiagnosticListener for the Java compiler task emitting Problem events and delegate to default rendering
    • Problem reports describing individual compiler warnings/errors/notes/etc.
    • Problem reports describing problems with the compilation process itself
      • compileJava tasks fails because there were warnings and -Werror is specified.
      • compileJava tasks fails because of invalid compiler argument problems: javac -source -1
  • Describe new feature in release notes (IDE Integration improvements section)

Acceptance criteria

  • Stakeholders are informed about the new features
  • Our team in 👍 on the data as it will be the input for the upcoming compilation build failure console rendering improvements.

Stakeholders

  • BT JVM team (as code-owners for the java compilation component)
  • Piotr
  • JetBrains
  • Google
  • Microsoft VSCode team

Communication plan

  • JVM team
    • get buy-in on planned feature
    • update them weekly on progress
  • JB/Google/Microsoft:
    • notify them about deliverables when something changes
    • keep them updated on regressions/etc

Associated tasks

Tasks and issues

  1. 30 min review @ide-experience build-script-change platform:bt_ge_build_cache platform:core_configuration platform:core_execution platform:core_runtime platform:ide platform:jvm platform:software
    hegyibalint
  2. a:feature in:problems
    hegyibalint
  3. a:feature in:java-plugins in:problems
    hegyibalint
  4. a:regression in:java-plugins in:problems
    hegyibalint
  5. a:feature in:problems
    hegyibalint
  6. stale
    hegyibalint
  7. a:bug closed:invalid in:execution-engine
    hegyibalint
  8. a:feature closed:not-fixed in:java-plugins in:problems
    hegyibalint
  9. a:feature in:java-plugins in:problems
    hegyibalint
  10. 1 min review in:java-plugins in:problems
    hegyibalint
  11. 20 min review a:feature in:java-plugins in:problems
    hegyibalint
  12. a:bug has:reproducer in:problems
    hegyibalint
  13. 1 min review in:java-plugins in:problems
    hegyibalint
  14. a:regression in:java-plugins in:problems
    hegyibalint
  15. 0 of 1
    a:bug in:java-plugins in:problems
    hegyibalint
  16. a:chore in:java-plugins in:problems
    hegyibalint
  17. in:problems
    hegyibalint
  18. a:investigation in:problems
    hegyibalint
  19. in:java-plugins in:problems
    hegyibalint
  20. a:documentation in:java-plugins in:problems
    hegyibalint
  21. a:bug in:java-plugins in:problems
  22. a:chore in:java-plugins in:problems
    hegyibalint
  23. a:bug in:test-kit
    hegyibalint
@hegyibalint hegyibalint self-assigned this Jan 5, 2024
@hegyibalint hegyibalint added @ide-experience Issues owned by the IDE Experience team and removed to-triage labels Jan 5, 2024
@hegyibalint hegyibalint added this to the 8.7 RC1 milestone Jan 5, 2024
@donat donat changed the title Use the Problems API to communicate Java compilation problems Improve Java compiler warnings on the console and in the IDE Jan 10, 2024
@donat donat changed the title Improve Java compiler warnings on the console and in the IDE Refine Java compiler warnings presentation on the CLI and in IDEs Jan 10, 2024
@donat donat changed the title Refine Java compiler warnings presentation on the CLI and in IDEs Refine Java compiler warning presentation on the CLI and in IDEs Jan 10, 2024
@donat donat changed the title Refine Java compiler warning presentation on the CLI and in IDEs Report Java compiler warnings and errors via Problems API Jan 11, 2024
@AndreasTu
Copy link

It would be great if that new API is also exposed to Gradle-Plugins not only Tooling API (like. IDEs).

Usecase:
I would like to implement a GradlePlugin which tracks the Java compile warnings and let the build fail if new warnings are added, but existing warnings are "accepted" for the time being. This would allow projects to gradually migrate to the -Werror without enforcing to fix all warnings at once. The Plugin would then update the accepted warnings during build, when old warnings are fixed. If the warning count drops to zero the -Werror flag will be enforced.

The API would allow me to implement such a thing, because it would be able to track the occurred warnings reliably.

@tbroyer
Copy link
Contributor

tbroyer commented Feb 7, 2024

Might be a moonshot but it could be a good idea to define a "standard" API for diagnostics to allow passing fix suggestions to the Problems API, so that IDEs could provide a "quick fix" action for example.

Error Prone for instance produces such suggestions, and having them surfaced somehow down to the Problems API through the compiler diagnostics could allow IDEs to propose them as "quick fixes" directly.
I made some research and a POC last year that was Error Prone specific but could likely be turned into some "standard" API: the idea was putting those fixes into an object passed as first argument to the diagnostic message; without a specific diagnostic listener, the object's toString() is called when the message is formatted and you get an standard message, but with a specific diagnostic listener it can cast the argument to that "standard" API and extract structured information out of it. The POC relied on the very few message-bundle keys used by Error Prone to detect when such a structured-information would be known to be available.
This would of course require tools like Error Prone to collaborate and use your "standard API" though.

The feature request for the Gradle GitHub Action to surface problems reported through the Problems API as comments on pull request (gradle/actions#30) could take advantage of such structured information to add GitHub suggestions to the comments as equivalent to IDE "quick fixes" too.

@hegyibalint hegyibalint linked a pull request Feb 8, 2024 that will close this issue
@hegyibalint hegyibalint removed this from the 8.7 RC1 milestone Feb 9, 2024
@donat donat changed the title Report Java compiler warnings and errors via Problems API Custom rendering for Java compiler problems Feb 15, 2024
@donat donat changed the title Custom rendering for Java compiler problems Improve Java compiler output rendering Feb 15, 2024
@donat donat removed a link to a pull request Feb 15, 2024
@donat donat changed the title Improve Java compiler output rendering Integrate Java compiler with the problems API May 23, 2024
@donat donat added this to the 8.9 RC1 milestone May 24, 2024
@hegyibalint hegyibalint modified the milestones: 8.9 RC1, 8.9 Jun 7, 2024
@donat donat closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:epic @ide-experience Issues owned by the IDE Experience team
Projects
None yet
Development

No branches or pull requests

4 participants