-
Suggestion
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 2.7.0
-
None
-
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 |
| 54101,5 | CppEditor: Add quick fix for "Assign to Local Variable" | master | qt-creator/qt-creator | Status: MERGED | +2 | 0 |