# Organizing R Breakpoints

R breakpoints in StatET are saved and loaded with the Eclipse workspace and are organized independently of running R consoles.

### Adding Breakpoints

To set a breakpoint to a line of an R script file, you have to open the file in the source editor. Only files in a project in the Eclipse workspace are supported.

#### Commands

| Name | Description | Availability
--- | --- | --- | ---

Toggle Breakpoint

If any breakpoint already exists at the line selected in the editor, that breakpoint is removed. Otherwise StatET tries to create a new breakpoint at the given line. StatET directly validates the position of the breakpoint and adapts it, if required. The type of the created breakpoint is chosen automatically dependent on the selected position.

- If the position is in a function header, it create a method breakpoint.
- Otherwise it creates a common line breakpoint.

When executing this command in the editor ruler using the mouse, the position of the mouse cursor and not the text selection in the editor is used.

The command is also executed when double-clicking on the editor ruler next to the source code line.

Main menu (Run)
Local command
`Ctrl+Shift+B`
Editor ruler

| Toggle Line Breakpoint | This command removes or creates line breakpoints only. If a line breakpoint already exists at the line selected in the editor, that breakpoint is removed. Otherwise StatET tries to create a new line breakpoint at the given line. StatET directly validates the position of the breakpoint and adapts it, if required. | Main menu (Run) Local command
| Toggle Method Breakpoint | This command removes or creates method breakpoints only. If a method breakpoint already exists for the function surrounding text selection in the editor, that breakpoint is removed. Otherwise StatET tries to create a new method breakpoint for that function. | Main menu (Run) Local command

If a new breakpoint is created, its icon appears in the editor ruler and in the Breakpoint view.

For all open R console running in debug mode in the Eclipse workbench, StatET also tries to install the newly created breakpoints in R.

### Removing Breakpoints

Since the ways to create a method breakpoint described above are toggle operation, you can also use them again to remove the method breakpoint. Beside that, the Breakpoint view offers additional actions to remove the selected or all breakpoints.

If the Eclipse workbench has open R console running in debug mode, StatET also tries to uninstall the removed breakpoints from R. In any case, the breakpoint is also directly disabled, so it will no longer suspend any thread.

## Installed Breakpoints

For R consoles running in debug mode in the current Eclipse workbench, StatET tries to install the breakpoints in R. A breakpoint can only be installed when the R code the breakpoint belongs to is loaded in R, e.g. the function or S4 method is assigned to an environment in the 'search' path in R. Additionally it is required, that the function in R must be created with source references (see Important Notes). If a breakpoint is successfully installed, its icon shows an checkmark overlay (). Note that this indicator in the icon can be wrong at a later time in the R console session, e.g. when the R element is removed or untrace manually by the user.

Breakpoints are installed automatically by StatET when:

- The user starts a new R console or reconnects to a running R console; StatET tries to update the installation of all breakpoints.
- The user submits R code containing breakpoints; StatET tries to install the breakpoints relevant for that code.
- A package is loaded to the R workspace. If this package exists in the Eclipse workspace, StatET tries to install all breakpoints in this project.