eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
36 stars 87 forks source link

Bug 513423 - Quick Fix provides incorrect placement of @Nullable #1462

Closed stephan-herrmann closed 3 months ago

stephan-herrmann commented 3 months ago

From https://bugs.eclipse.org/513423

Given the class:

@NonNullByDefault
public class UncheckedException extends RuntimeException {
   public void printStackTrace(
      // Illegal redefinition of parameter s, inherited method from Throwable
      // does not constrain this parameter
      java.io.PrintStream s)
   {
      synchronized (s) {
         s.print(getClass().getName() + ": ");
         s.print(stackTrace);
      }
   }
}

According to: http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_null_annotations.htm

Type annotation should be: java.io.@Nullable PrintWriter s

But Quick Fix provides it as: @Nullable java.io.PrintWriter s

I am also not provided a "Move type annotation" fix as suggested by 4.7-M5: https://www.eclipse.org/eclipse/news/4.7/M5/

jjohnstn commented 3 months ago

FWIW: the Move type annotation quick fix is now offered after the @Nullable annotation is added and the line marked in error.