-
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).
This comment has been minimized.
This comment has been minimized.
7125984
to
6bd7ff1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6bd7ff1
to
d3136e0
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
19bf8f9
to
3829303
Compare
8b06157
to
60cce51
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The following builds have passed: |
37f107b
to
04ce32d
Compare
3829303
to
4436936
Compare
@bot-gradle test this |
This comment has been minimized.
This comment has been minimized.
04ce32d
to
0664c2f
Compare
4436936
to
adffc16
Compare
The following builds have failed: |
0664c2f
to
832838f
Compare
adffc16
to
ac4852b
Compare
WARN: The milestone of this PR is 9.0, but the base branch version is 8.14 |
Fixes #32915
Context
Reviewing cheatsheet
Before merging the PR, comments starting with