PyCharm Edu 2018.2 Help

Inline

PyCharm Edu provides the following inline refactorings:

  • Inline Variable refactoring replaces redundant variable usage with its initializer. This refactoring is opposite to Extract Variable.
  • Inline Constant refactoring. This refactoring is opposite to the Extract Constant refactoring and it results in replacing variables with constants.
  • Inline Field refactoring is opposite to the Extract Field refactoring and it results in replacing the selected field with the corresponding expression.
  • Inline Parameter refactoring is opposite to the Extract Parameter refactoring and it results in replacing the selected parameter with the expression or local variable declaration.
  • Inline Method refactoring results in placing method's body into the body of its callers. This refactoring is opposite to the Extract method refactoring.
  • Inline Superclass refactoring results in pushing superclass' methods into the class where they are used, and removing the superclass. This refactoring is opposite to the Extract Superclass refactoring.

Inline Variable Example

BeforeAfter
import math class Solver: def demo(self): a = 3 b = 25 c = 46 #This variable will be inlined return_type_of_sqrt = math.sqrt(b ** 2 - 4 * a * c) root1 = (-b + return_type_of_sqrt) / (2*a) root2 = (-b - return_type_of_sqrt) / (2*a) print(root1,root2) Solver().demo()
import math class Solver: def demo(self): a = 3 b = 25 c = 46 root1 = (-b + math.sqrt(b**2 - 4*a*c)) / (2*a) root2 = (-b - math.sqrt(b**2 - 4*a*c)) / (2*a) print(root1,root2) Solver().demo()

Perform inline refactoring

  1. Place the caret in the editor at the desired symbol to be inlined.
  2. Do one of the following:
    • On on the context menu, choose Refactor | Inline.
    • Press Ctrl+Alt+N.
  3. In the Inline dialog box that corresponds to the selected symbol, confirm the inline refactoring.
Last modified: 9 August 2018

See Also