### 13.4 Code Fixing

GPS provides an interactive way to fix or improve your source code, based on messages (errors and warnings) generated by the GNAT compiler.

This capability is integrated with the Locations View (see The Locations View): when GPS can take advantage of a compiler message, an icon is added on the left side of the line.

For a simple fix, a wrench icon is displayed. If you click with the left button on this icon, the code will be fixed automatically, and you will see the change in the corresponding source editor. An example of a simple fix, is the addition of a missing semicolon.

You can also check what action will be performed by clicking on the right button which will display a contextual menu with a text explaining the action that will be performed. Similarly, if you display the contextual menu anywhere else on the message line, a sub menu called Code Fixing gives you access to the same information. In the previous example of a missing semicolon, the menu will contain an entry labeled Add expected string ";".

Once the code change has been performed, the tool icon is no longer displayed.

For more complex fixes, where more than one change is possible, a wrench icon with a blue plus sign is displayed. In this case, clicking on the icon will display the contextual menu directly, giving you access to the possible choices. For example, this will be the case when an ambiguity is reported by the compiler for resolving an entity.

Right clicking on a message with a fix will open a contextual menu with an entry "Auto Fix". Fixes that can be applied by clicking on the wrench are available through that menu as well. In addiditon, if exactly one of the fixes is considered to be safe by GPS, additional entries will be provided to apply fixes on multiple messages:

`Fix all similar errors`
  Will apply the same simple fix for all errors which are detected by the system as being the same kind. This is based on message parsing.
`Fix all simple style errors and warnings`
  This entry is offered only when the selected message is a warning and a style error. Will fix all other warnings and style errors for which a unique simple fix is available.
`Fix all simple errors`
  Will fix all errors messages for which a unique simple fix is available