Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-31931

Lightbulb "Apply Changes to definition / declaration" breaks lines for "Switch with Previous/Next Parameter"

XMLWordPrintable

    • Windows
    • 07da22270 (master)

      I really like the lightbulb feature, that helps renaming parameter names in functions/methods.

      What I do not like is, that it breaks formatting of the parameter listing of the function declaration or definition (depending on what to adapt to).

      Starting point:

      #include <QDebug>
      
      // declaration
      void foo(
            int i,
            float f
            );
      
      // definition
      void foo(
            int i,
            float f   // put the cursor on 'f'
            )
         {
         qDebug() << i << f;
         }
      
      int main()
         {
         foo(1, 2.);
         }
       

      Now put the cursor on 'f' and choose Context-Menu => Refactor => Switch with Previous Parameter". The result is ok.
      Now click on the lightbulb to "Apply Changes to declaration".

      This refactoring leaves the declaration in an ugly shape.

      #include <QDebug>
      
      // declaration
      void foo(
            float f
            ,
            int i);
      
      // definition
      void foo(
            float f,
            int i
            )
         {
         qDebug() << i << f;
         }
      
      int main()
         {
         foo(1, 2.);
         }

      So, in the declaration I would have expected to just see the lines switched:

      // declaration
      void foo(
            float f,
            int i
            ); 

      As the declaration is typically in another file you would have to switch to the file and fix the formatting.

        1. ParameterRafactoring.zip
          0.8 kB
          Michael Möllney
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kandeler Christian Kandeler
            moellney Michael Möllney
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes