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

Implement compiler-supplied ids for java compilation #29425

Merged
merged 8 commits into from
Sep 17, 2024

Conversation

hegyibalint
Copy link
Member

@hegyibalint hegyibalint commented Jun 5, 2024

Our current approach to Java compilation diagnostic IDs and their respective label was a bit simple: we derived an ID and a message from the kind of diagnostic, which limited us to 5 categories overall.

The compiler provides us with separate keys for various problems, which we could use on our end to also create finer-grained reports.

Fixes #30514

@hegyibalint hegyibalint added a:feature A new functionality in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures in:problems problems api labels Jun 5, 2024
@hegyibalint hegyibalint self-assigned this Jun 5, 2024
@hegyibalint hegyibalint requested review from a team as code owners June 5, 2024 13:43
@hegyibalint hegyibalint requested a review from jvandort June 5, 2024 13:43
@hegyibalint hegyibalint marked this pull request as draft June 5, 2024 13:44
@cobexer cobexer removed the request for review from a team June 6, 2024 07:28
@hegyibalint hegyibalint added this to the 8.10 RC1 milestone Jun 11, 2024
@hegyibalint hegyibalint requested review from a team and donat June 11, 2024 07:54
assertProblem(it, "WARNING", true)
fqid == 'compilation:java:java-compilation-warning'
details == 'redundant cast to java.lang.String'
assertLocations(it, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was never a fan of boolean parameters for functions. Instead, It's not strictly related to this pr, but I'd recommend to introduce a new assertPreciseLocation method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not force it into this PR, but we could make an issue to review the structure there.

'compilation:java:java-compilation-failed' : 'Java compilation error',
'compilation:java:java-compilation-warning' : 'Java compilation warning',
'compilation:java:java-compilation-advice' : 'Java compilation note',
// Flexible category, as the category id's last component, and the message, will be supplied by the compiler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part, I'd prefer exact content listed here. At the same time, if the list becomes unmanageable (dozens of tests fail and the list of known IDs are unmanageable), then I'd switch to pattern matching. Is this the case here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a different approach here: I kept the literal message and only kept the end if IDs dynamic. I think this is a sweet spot for not making the list huge yet having confidence that the value incoming is a (probably) valid one.

details == 'redundant cast to java.lang.String'
assertLocations(it, true)
severity == Severity.WARNING
fqid == 'compilation:java:compiler-warn-redundant-cast'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Does it make sense to have the severity in the id? And would it make sense to kick out the compiler prefix? So we'd end up with something like compilation:java:redundant-cast.

Copy link
Member Author

@hegyibalint hegyibalint Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the ID is just an ID, and it's not an issue if it contains redundant information.
Even if I'm pretty certain that the prefix here is stable (e.g., list of JDK7 compiler codes vs. mainline compiler codes), I would still avoid making an assumption of the code format (apart from the dot separation).

Do you have something in mind where the shorter ID might be beneficial?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me. Will some humans end up reading the ID at some point?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Buildship we will soon have a UI for problems. Here's a screenshot from my wip pr.

@hegyibalint hegyibalint removed this from the 8.10 RC1 milestone Jul 22, 2024
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If you don't want the stale bot to close it, then set a milestone for it.

@github-actions github-actions bot added the stale label Aug 21, 2024
Copy link
Contributor

github-actions bot commented Sep 4, 2024

This pull request has been automatically closed due to inactivity.

@github-actions github-actions bot closed this Sep 4, 2024
@donat donat reopened this Sep 4, 2024
@github-actions github-actions bot removed the stale label Sep 4, 2024
@hegyibalint hegyibalint force-pushed the bhegyi/problems/java-compile/use-compiler-ids branch 3 times, most recently from 7a408b4 to 89c7618 Compare September 12, 2024 12:41
@hegyibalint hegyibalint force-pushed the bhegyi/problems/java-compile/use-compiler-ids branch from 89c7618 to e4ee553 Compare September 12, 2024 16:09
@hegyibalint hegyibalint force-pushed the bhegyi/problems/java-compile/use-compiler-ids branch from 3f61685 to a088116 Compare September 13, 2024 08:48
@hegyibalint hegyibalint marked this pull request as ready for review September 17, 2024 08:47
@hegyibalint hegyibalint requested a review from a team as a code owner September 17, 2024 08:47
@donat donat self-requested a review September 17, 2024 11:27
@hegyibalint hegyibalint added this pull request to the merge queue Sep 17, 2024
@bot-gradle bot-gradle added this to the 8.11 RC1 milestone Sep 17, 2024
@bot-gradle
Copy link
Collaborator

WARN: Based on labels, this pull request addresses notable issue but no changes to release note found.

@bot-gradle
Copy link
Collaborator

The merge queue build has failed. Click here to see all failures.

Merged via the queue into master with commit 6af9488 Sep 17, 2024
21 checks passed
@hegyibalint hegyibalint deleted the bhegyi/problems/java-compile/use-compiler-ids branch September 17, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:java-plugins java-library, java, java-base, java-platform, java-test-fixtures in:problems problems api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java compilation ids should be more refined in problems API reports
4 participants