-
Notifications
You must be signed in to change notification settings - Fork 41
Adding support for generating eclipse markers through m2e injuected buildContext #34
Conversation
Thanks for the PR. Could you fix the indentation of your contributions (4 spaces)? |
added new commit with corrected indent. |
private void processDiagnostics(final List<Diagnostic<? extends JavaFileObject>> diagnostics) { | ||
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) { | ||
if (diagnostic != null) { | ||
final JavaFileObject javaFileObject = diagnostic.getSource(); |
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.
Consider removing the final usage inside this method's body.
finals are removed. |
*/ | ||
private void processDiagnostics(final List<Diagnostic<? extends JavaFileObject>> diagnostics) { | ||
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) { | ||
if (diagnostic != null) { |
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.
Diagnostic
s are not supposed to be null, so you can rely on that fact.
This null check is not necessary.
I also added a few comments, Nevermind, I hadn't seen that the commit also reordered the cases for the switch block. |
thanks for review, added commit with changes to consider your comments |
Finally, the only thing I am still speculating is the following. There is a fine distinction between a message that has a source (which you check) and if it has a valid position in said source (which you don't check). I think checking for I call it speculation, since we don't yet have a test case that validates the expected behavior, so it only theoretically improves safety. @timowest @sketelsen What do you think? |
@Shredder121 Would the rendering of notifications without valid positions have negative side effects? |
That's exactly what I am unsure about. It was just a hunch, @sketelsen can you build the apt-maven-plugin and see if you can run your processor with the results you expected? |
@Shredder121 I prefer the null check instead of assume some indirect behavior (with a valid position there will be a source) because i run into the NPE by myself. From the viewpoint of the annotation processor developer the element is just an optional parameter when using the Eclipse renders a marker with a valid destination file and an invalid line/column (-1) as a marker on the first line. I tested this with luna 4.4.1 and mars 4.5M4. As long as the line number will not exceed the file length there will be a marker within the java editor view. After solving/rebuild all markers will be deleted, no matter of valid or invalid position. The only poor behavior followed from |
I see, thanks for giving us some insight. Then all my doubts are settled, I think it's good to merge. |
One more thing. For a private static class: Making it public: I think resolving this in a separate pull request is in order? |
@Shredder121 Maybe these could be handled via a separate PR. Shall we merge this? |
Yes, we can merge this. |
Adding support for generating eclipse markers through m2e injuected buildContext
Thank you @sketelsen for the addition! |
I wrote an annotation processor which does some checks and creates diagnostic errors messages. On cli builds those error messages are printed to the console and informs about errors within sources (e.g. wrong use of parameters, exceptions on processing).
In eclipse those messages are not shown directly. I added support for generating eclipse warning/error markers through the injected m2e buildContext on the annotated elements which contains the problems.