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

"Assign to local variable" quick fix option.

XMLWordPrintable

    • 7ae31f2ea9eebf9cf6ebf95fd7d4f745565cf873

      Let's have an ability to assign the return value of method under cursor to local variable. It just defines local variable of the same type as the method under cursor returns.

      Example:

      {
      ...
      doSomeJobAndReturnResult();
      ...
      }

      If we move cursor to somewhere on the method call and press Alt+Enter, we should get option like "Assign return value to local variable":

      {
      ...
      ReturnType returnType = doSomeJobAndReturnResult();
      ...
      }

      The name of the newly created variable should be respectful to its datatype. In case of variable name conflict, do some variations. Maybe adding the sequence at the end of name. I'm not sure about the details.

      In case of template types, the variable name should get a combination of template name and parameter(s) types.

      After all, the variable name will most likely be renamed by developer. Its major purpose is to have variable with defined type, because sometimes you have to recall the type returned by method. Why wasting time for that?

        For Gerrit Dashboard: QTCREATORBUG-9052
        # Subject Branch Project Status CR V

            erikv Erik Verbruggen
            vipe Vipe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes