Tux
Communication
Mailing lists
Documentation
User Manual
Target board info.
Target chip info.
Support
Linux support
Bugzilla
Downloads
STLinux
Updates
Search
Google


The web
stlinux.com
Using STWorkbench with STLinux
Advanced STWorkbench editor features
ST Logo
Previous   Contents   Next

One of the most powerful parts of the STWorkbench integrated development environment is the built-in editor. This code editing tool has the following extra features useful in code development.

Refactoring

This allows you to change the names of variables or functions throughout your projects in one simple operation. To carry out a refactoring operation:

  1. Highlight or select the word you want to change in your source code.

  2. Open the refactoring wizard using one of the following:

    • from the main menus select Refactor > Rename,
    • or from the popup menu, right-click the highlighted word then select Refactor > Rename,
    • or use the key combination Alt + Shift + R.

    Note: Some languages such as Java provide several refactoring operations.

  3. Fill in the fields for the new name of your symbol, the scope of the renaming operation (current project, all projects, related projects or your working set) and which statements to change (source code, comments or macro definitions). Click Preview to continue or Cancel to stop.

  4. Refactor Dialog 1

  5. The parts of the source code that will be changed are then listed. The top section lists the files which will be changed, with subsections listing each occurrence. Use the tick boxes to unselect any occurrences you don't want to change.

  6. Select the files or occurrences to see a simple difference view between the original text and the new text in the bottom section of the dialogue box. Click OK to make the changes or Cancel to stop the operation.

  7. There is a single level of refactoring undo or redo which can be launched from the main or popup menus, or the key combination CTRL + Z.

    Refactor Dialog 2

    Local History

    STWorkbench records the changes made on all files each time they are saved. You can see what changes have been made on an individual file or roll back to an earlier version.

    To see the changes to a file, in the Editor, Project or Navigator views, right-click the file and select Compare With > Local History. A list appears showing all the file save points by date and time in the top section and shows a difference view between the current version and the selected local history version.

    Local History Compare

    To compare two files, in the Projects or Navigator views, right-click two files (they do not need to be in the same project) and select Compare With > Each Other. A window appears in the Editor view showing a line-by-line comparison.

    Compare with Each Other

    To roll back and replace a file with an earlier version, in the Projects or Navigator views, right-click the file and select Replace With > Previous from Local History. This replaces the current version of the file with the previous saved version. If you select this again it swaps back to the current saved version, allowing a fast toggle between the two last saved versions.

    To check your current version against the saved versions, compare the differences and then choose whether to do a replace or not, select Replace With > Local History.

    Note: To configure the amount of data storage used for the local history facility, select Windows > Preferences, then select General > Workspace > Local History. This shows settings for the maximum number of days to keep files, the maximum number of entries per file, and the maximum file size.

    Content Assist

    Content Assist provides symbol completion, and a set of templates to speed up the process of code creation.

    Symbol completions allow auto-completion of function and variable names from your code, and the templates include most of the common C/C++ code constructs such as for loops, if and switch statements, and structure and class definitions.

    The templates are completely configurable by the user and new ones can be easily added. They contain a range of variables which are either filled in by the user (such as the counter variable in a for loop) or can be completed automatically by the system, such as the date or the current user ID.

    To edit templates and insert them into code:

    1. List the currently available templates. Select Windows > Preferences, then select C/C++ > Editor > Templates.

    2. Select one of the templates in the list and a preview appears. Click the Edit button to edit it.

      You can import and export template files, stored as .xml files, to allow team members and groups to share templates.

    3. To launch the content assist feature, type the first few characters of a symbol name or template keyword. The names of the templates are also the keywords required to insert the template.

    4. Code Assist 1

    5. Press CTRL + SPACE to see the available templates or symbol completions for that keyword.
      The integrated editor is rich in keyboard shortcuts .

    6. Code Assist 2

    7. Select the appropriate template and press Enter or double-click the template to insert it into your code.

      In this statement the var and max are variables in the template. If you fill in the variable name var straight away, when it is highlighted, the system automatically updates the other references to var.

    8. Code Assist 3

    Previous   Contents   Next
Valid HTML 4.01! Last updated: 16th March, 2007
© Copyright STMicroelectronics Limited, 2005
Printer