Show: Delphi C++
Display Preferences

Code Insight (IDE Tutorial)

From RAD Studio
Jump to: navigation, search

Go Up to The Code Editor Index (IDE Tutorial)


Code Insight refers to a subset of features embedded in the Code Editor (such as Code Parameter Hints, Code Hints, Help Insight, Code Completion, Class Completion, Block Completion, and Code Browsing) that aid in the code writing process. These features help identify common statements you want to insert into your code, and assist you in the selection of properties and methods. Some of these features are described in more detail in the following subsections.

To enable and configure Code Insight features, choose Tools > Options > Editor Options and click Code Insight.

Code Completion — Ctrl+Space

To invoke Code Completion, press Ctrl+Space while using the Code Editor. A popup window displays a list of symbols that are valid at the cursor location. You can type characters to match those in the selection and press Return to insert the text in the code at the cursor location.

TutorialIDEFig2-23.png

Figure 2-23. Code Completion popup window showing the list of available options

Help Insight — Ctrl+Shift+H

Help Insight displays a hint containing information about the symbol, such as type, file, line number where declared, and any XML documentation associated with the symbol (if available).

Invoke Help Insight by hovering the mouse over an identifier in your code, while working in the Code Editor. You can also invoke Help Insight by pressing Ctrl+Shift+H.

Class Completion — Ctrl+Shift+C

Class Completion simplifies the process of defining and implementing new classes by generating skeleton code for the class members that you declare.

Position the cursor within a class declaration in the interface section of a unit and press Ctrl+Shift+C. Any unfinished property declarations are completed.

For any methods that require an implementation, empty methods are added to the implementation section.

Class Completion can also be achieved by choosing the option Complete class at cursor from the Code Editor context menu.

Block Completion — Enter key

When you press Enter in a block of code that was incorrectly closed (while working in the Code Editor), a closing block token is inserted at the first empty line following the cursor position.

For instance, if you are using the Code Editor with the Delphi language, and you type the token begin and then press ENTER, the Code Editor automatically completes the statement so that you have: begin end;.

Block Completion also works for the C++ language.

Code Parameter Hints — Ctrl+Shift+Space

Code Parameter Hints display a hint containing argument names and types for method calls. You can invoke Code Parameter Hints by pressing Ctrl+Shift+Space, after opening a left bracket of a function call.

TutorialIDEFig2-24.png

Figure 2-24. Using Code Parameter Hints to show the required types for the parameters

Code Hints

Code Hints display a hint containing information about the symbol such as type, file, and line number, where declared. You can display Code Hints by hovering the mouse over an identifier in your code, while working in the Code Editor.

TutorialIDEFig2-25.png

Figure 2-25. Displaying in-place Code Hints

Note: Code Hints only work for Delphi when you have disabled the Help Insight feature. To disable Help Insight, uncheck Tooltip help insight on the Tools > Options > Editor Options > Code Insight dialog box.

Error Insight

When you type an expression that generates compiler errors, the expression is underlined in red.

Also, the list of errors generated by the expression appears in the Errors pane of the Structure View.

TutorialIDEFig2-26.png

Figure 2-26. Automatic marking of errors in the code

Code Browsing — Ctrl+Click

While using the Code Editor you can hold down the Ctrl key while hovering the mouse over the name of any class, variable, property, method, or other identifier.

The mouse pointer turns into a hand, and the identifier appears highlighted and underlined. Click the identifier, and the Code Editor jumps to the declaration of the identifier, opening the source file, if necessary. You can do the same thing by right-clicking an identifier and choosing Find Declaration. Pressing Alt+Left Arrow returns you to where you browsed from.

Code browsing can find and open only units in the project Search path or Source path, or in the product Browsing path or Library path. Directories are searched in the following order:

  1. The project Search path (Delphi) or Include path (C++)
  2. The project Source path, defined as the directory in which the project was saved
  3. The global Browsing path
  4. The global Library path
  5. The Library path, which is searched only if there is no project open in the IDE

These paths can be modified by editing the corresponding values:

Next

Refactoring

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance