CLion 2018.2 Help

Unwrapping and Removing Statements

For C++, this refactoring safely unwraps if...else, for, while, do...while and try...catch control statements, or accurately removes enclosing parts of the nested statements.

Besides C++, the Unwrap/Remove action is available for:

To unwrap or remove a statement

  1. Place the caret on the expression you want to unwrap or remove.
  2. Choose Code | Unwrap/Remove on the main menu or press Ctrl+Shift+Delete. CLion shows a pop-up window with all the actions that are available in the current context. Statements to be kept after unwrapping are displayed on the blue background, statements to be removed are displayed on the grey background.
  3. Click the desired action or select it using the up and down arrow keys and press Enter.

Examples in different languages showing statements unwrapping:

BeforeAfter
int x; std::cin >> x; // the ternary operator will be unwrapped int half_x = ( x != 0 ? x / 2 : 0 );
int x; std::cin >> x; int half_x = (x / 2);
BeforeAfter
@implementation SСlass - (int)sqrV { if (v != 0) return v * v; else // this 'else' statement will be removed return 0; } @end
@implementation SСlass - (int)sqrV { if (v != 0) return v * v; } @end
BeforeAfter
count = 0 # This 'while' statement will be unwrapped while True: print(count) count += 1 if count >= 5: break
count = 0 print(count) count += 1 if count >= 5: break
BeforeAfter
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var i = 0; // This 'while' statement will be unwrapped while (i != document.cookie.length) { var j = i + document.cookie.length; i++; } }
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var i = 0; var j = i + document.cookie.length; i++; }

Last modified: 18 July 2018