# Extract method errors

When you attempt to extract a method, you may get one or more of the following common errors:

- `Selected block references a local type declared outside the selection` A local type declaration is not part of the selection but is referenced by one of the statements selected for extraction. Either extend the selection that it includes the local type declaration or reduce the selection that no reference to the local type declaration is selected.
- `A local type declared in the selected block is referenced outside the selection` The selection covers a local type declaration but the type is also referenced outside the selected statements. Either extend the selection that is includes all references to the local type or reduce the selection that the local type declaration isn't selected.
- `Ambiguous return value: selected block contains more than one assignment to local variable` More than one assignment to a local variable was found inside the selected block. Either reduce the selection that only one assignment is selected or extend the selection that at least all reference except of one to the local variables are covered by the selection too.
- `Ambiguous return value: expression access to local and return statement selected` The selected statement generates more than one return value. This is for example the case if an expression is selected and an expression's argument is modified as well. To remedy this problem extend the selection to cover the read access of the modified argument as well.
- `Selection contains a break statement but the corresponding break target isn't selected` To remedy the problem either extend the selection to include the break / continue target or reduce the selection that the break / continue statement isn't covered by the selection.
- `Selection contains a continue statement but the corresponding continue target isn't selected` To remedy the problem either extend the selection to include the break / continue target or reduce the selection that the break / continue statement isn't covered by the selection.
- `Selection starts inside a comment` Parts of a comment cannot be extracted. Either extend the selection that it covers the whole comment or reduce the selection that the comment isn't covered at all.
- `Selection ends inside a comment` Parts of a comment can't be extracted. Either extend the selection that it covers the whole comment or reduce the selection that the comment isn't covered at all.
- `Cannot extract selection that ends in the middle of a statement` Adjust selection so that it fully covers a set of statements or expressions. The users can extend the selection to a valid range using the Expand Selection to in the Edit menu.

Java development tools (JDT)
Refactoring support

Source menu
Refactor Menu