-
Notifications
You must be signed in to change notification settings - Fork 5k
Use diagnostic message as the display name of the Java compilation problem ids #32411
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
...ge-java/src/main/java/org/gradle/api/internal/tasks/compile/DiagnosticToProblemListener.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
83ff440
to
7125984
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
.../src/integTest/groovy/org/gradle/api/tasks/compile/JavaCompileProblemsIntegrationTest.groovy
Outdated
Show resolved
Hide resolved
private static void addDetails(ProblemSpec spec, Diagnostic<? extends JavaFileObject> diagnostic) { | ||
String message = diagnostic.getMessage(Locale.getDefault()); | ||
private static void addContextualLabel(ProblemSpec spec, Diagnostic<? extends JavaFileObject> diagnostic) { | ||
String message = diagnosticMessage(diagnostic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 If the message is null
, wouldn't it make more sense to not set the contextual label instead of using Unknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
|
||
private void addFormattedMessage(ProblemSpec spec, Diagnostic<? extends JavaFileObject> diagnostic) { | ||
private void addDetails(ProblemSpec spec, Diagnostic<? extends JavaFileObject> diagnostic) { | ||
String formatted = toFormattedMessage(diagnostic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 What is the difference between the formatted message and the message? Would it make sense to drop the first line of the formatted message to use it as details given that the first line is already part of the contextual label? While still printing out the full formatted message to the console?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That kind of makes sense, let me play around with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the message: is the short summary of the problem, eg ';' expected
the formatted message is the actual compiler-specific output you see on the console, eg
/Users/donat/Development/git/gradle/gradle-feature/platforms/jvm/language-java/build/tmp/teŝt files/JavaMultiCo.Test/ziu9r/project2/src/main/java/Project2.java:5: error: ';' expected
String s = "Hello, World!"
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so the first line of the formatted message seems to duplicate the severity, the location, and the message, right? Is that always the case or are there some corner cases when this does not happen? If it is always the case I'd drop the first line for the problems API details from the formatted message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that always the case or are there some corner cases when this does not happen?
We don't know exactly. The actual content of the formatted message is unknown, because it is an implementation detail of the Java compiler.
Also, there are some known cases, where we cannot even get the formatted message and we know we use the fallback. For example when Java 8 is used with annotation processing (see #31160).
Fixes #32915
Context
Reviewing cheatsheet
Before merging the PR, comments starting with