Book Image

IntelliJ IDEA Essentials

By : Jaroslaw Krochmalski
Book Image

IntelliJ IDEA Essentials

By: Jaroslaw Krochmalski

Overview of this book

Table of Contents (17 chapters)
IntelliJ IDEA Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Refactoring actions


There are many different refactoring actions available in IntelliJ IDEA. Let's cover the important ones first: Rename, Copy, Move, and Safe Delete.

Rename

This is probably the most commonly used refactoring. The target for the rename action can be any symbol in the source code: class, method, field, method parameter, or local variable.

To rename, just pick the target and press Shift + F6. This action will start the in-place prompt, as shown in the following screenshot:

If you use the Shift + F6 shortcut twice, the Rename dialog box will offer additional options such as searching within comments and text strings, as shown here:

IntelliJ IDEA handles renaming intelligently; it will offer to rename the getter and setter methods if any of them are found. If the target to be renamed is the name of a type, the IDE will offer to rename variables of that type, the inheritors, implementing classes, and corresponding tests.

Find and Replace Code Duplicates

According to the don't repeat...