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

Refactoring: Extract constant in function body to function parameter and adapt function uses

    XMLWordPrintable

Details

    • a6c8158484931c41e026b265297a1f2ae8a6e2c7

    Description

      The extract method refactoring is great, but often I realize that two sections of code are duplicated except for some constant. I'd like to highlight some constant value in a function and have qt creator create a function parameter and update all current uses of the function to call with that parameter. (or alternatively make the parameter default)

      example:

      bool searchFor(list foo) {
         for(auto it = foo.begin...)
            if(it == 7)  return true
          return false;
      }
      

      becomes

      bool searchFor(list foo, int NewParam) {
         for(auto it = foo.begin...)
            if(it == NewParam)  return true
          return false;
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jbornema Joerg Bornemann
              millerhenry@johndeere.com Henry Miller
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes