You can use the Extract Variable refactoring even on incomplete statements. Just select the necessary block in the editor and press &shortcut:IntroduceVariable;.