Aqua 2024.3 Help

Safe delete

Aqua lets you use the Safe Delete refactoring to remove files and symbols from the source code safely. Before Aqua deletes a file or a symbol, it searches for usages and if they are found, Aqua lets you check them to make necessary adjustments.

Safe delete

  1. Select an item you want to delete.

  2. Select Refactor | Safe Delete from the main or context menu or press Alt+Delete.

  3. In the dialog that opens, select necessary options and click OK.

    The available options are:

    • Search in comments and strings :If this checkbox is selected, Aqua will look for occurrences within comments and string literals in your source code files.

    • Search for text occurrences :If this checkbox is selected, Aqua will look for occurrences in files that don't contain source code. These may be the text files, properties files, HTML files, documentation files, and so on.

  4. If Aqua encountered potential problems, it displays the Usages Detected dialog. Proceed with the appropriate action.

Examples

Safe delete a parameter

Safe delete a parameter for a call hierarchy (here performed on the parameter i within baz(int i)).

If a parameter is passed only through a call hierarchy, the Safe Delete action will delete the parameter through the whole hierarchy. Aqua displays the appropriate dialog where you can select the caller methods in which the parameter should be deleted.

class CallHierarchySample { private void foo(int i) { bar(i);} private void bar(int i) { baz(i);} private void baz(int i) { } }
class CallHierarchySample { private void foo() { bar();} private void bar() { baz();} private void baz() { } }

Safe delete a method

Safe delete a method in a call hierarchy (here performed on the foo(int i) method).

Aqua analyzes the corresponding call hierarchy and displays the appropriate dialog, suggesting you delete all unused methods in that call hierarchy.

class CallHierarchySample { private void foo(int i) { bar(i);} private void bar(int i) { baz(i);} private void baz(int i) { } }
class CallHierarchySample { }

Safe delete the unused class field

Safe delete the unused class field (here performed on myProperty).

When you remove an unused class field that is injected via constructor, Aqua removes the associated constructor parameter as well. Aqua opens the appropriate dialog where you can check and confirm your code deletion.

public class MyClass{ private final MyProperty myProperty; public MyClass(MyProperty myProperty){ this.myProperty = myProperty; } }
public class MyClass { public MyClass(){ } }
Last modified: 31 October 2024