This documentation relates to previous versions of Titanium Studio.

To see the latest documentation, visit docs.appcelerator.com.

Skip to end of metadata
Go to start of metadata

Well, let's see how refactoring works... and let's make it by example (smile)

As our 'base', we will use the example below:

Features:

  • Keybinding: Alt+Shift+R
  • Supports preview
  • Integrated in the editor (but not in the package explorer, so, it can rename a module, but only through an import to that module)
  • Supports undo/redo in the workspace
  • Rename class
  • Rename method
  • Rename attribute
  • Rename imports
  • Rename local variable

Let's say we want to rename our 'newVar', and call it 'renamedVar'. To do that, mark it and press Alt+Shift+R and set the name to 'renamedVar'


That would give us the following result:

Extracting a method: Let's mark the '100+500' and press Alt+Shift+M (alternatively, you could use a context menu: press the right button and select: refactoring > Extract Method). And set the name of the new method to 'newMethod'.


That would give us the following result:

Inlining a variable: Let's say that we are still not satisfied with that, we wouldn't like that 'var' variable, so, we want to remove the reference to it and call the method directly. To do that, mark the 'var' and press Alt+Shift+I.


That would give us the following result:

Extracting a variable: Ok, it just wasn't what we wanted, so, let's make the opposite refactoring, let's extract a variable from the self.newMethod() call. Mark it and press Alt+Shift+L and set the name to 'newVar'


That would give us the following result:


And that's it for the refactoring... hope you enjoy it.

Labels
  • None