| Summary: | Quick Fix for Null Type Safety and Code Formatter | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Robert Kish <robert.kish> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | deepakazad, mateusz.matela, stephan.herrmann |
| Version: | 4.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | stalebug | ||
(In reply to comment #0) > @Deprecated > public @NonNull String getX() { > return x; > } Yeah, even I prefer this style (since the annotation really modifies the return type), but don't think Eclipse formatter does that... at least not by default. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. When using TYPE_USE annotations, the quick fix "Change return type of getX() to '@NonNull String'" already uses the correct position for insertion. If the annotation is placed after the visibility modifier, also the formatter get's it right. Just an annotation with no preceding modifier still causes an undesired line break. @Mateusz, is it possible for the formatter to detect TYPE_USE annotations, and always avoid a line break between annotation and type? (In reply to Stephan Herrmann from comment #3) So for a code like this? @Deprecated @NonNull String getX() { return x; } It's not possible to know if the annotations are associated with the whole method or just the return type. There's a simple workaround - add explicit "default" modifier. The original report was about a more obvious case, which is no longer a problem, so I would close as worksforme :) |
1. Should quick fix place the @NonNull annotation before a method's scope declaration so that code formatting places it one per line (by default) with other annotations on the method? @NonNull @Deprecated public String getX() { return x; } This is summarized as "Is Quick Fix wrong?" 2. Or should there be an option to (not) Insert new line after annotation on return values of methods. Current Eclipse formatting: @Deprecated public @NonNull String getX() { return x; } vs: Desired Eclipse formatting: @Deprecated public @NonNull String getX() { return x; } This is summarized as "Do we want more formatting options?" From all of the examples I've seen, I'm more included to believe we just want more formatting options.