RAD Studio (Common)
ContentsIndex
PreviousUpNext
Code Completion

Code Completion is a Code Insight feature available in the Code Editor. Code Completion displays a resizable “hint” window that lists valid elements that you can select to add to your code. You can control the sorting of items in the Code Completion hint window by right-clicking the box and choosing Sort by Name or Sort by Scope.  

Different items appear in different colors in the list. For example, by default, procedures are teal, functions are dark blue, and abstract methods are shown in red. 

Automatic code completion is on by default. Options for enabling and disabling Code Completion are located on the Code Insight page of the ToolsOptionsEditor Options dialog box. 

Code completion and code navigation features (Ctrl-Click) work only when Symbol Reference info is set to Reference info. Set this option on the ProjectOptionsDelphi CompilerCompiling dialog box. 

Following are ways to use Code Completion in the IDE:

  • To display the properties, methods, and events available in a class, press Ctrl+Space after the name of a variable that represents either a class instance or a pointer to a class instance.
  • To invoke code completion for a pointer type, the pointer must first be dereferenced. For example, type:self.in Delphi, or this-> in C++.
  • Type an arrow for a pointer to an object.
  • You can also type the name of non-pointer types followed by a period (.) to see the list of inherited and virtual properties, methods, and events.
  • For example, in Delphi type: TRect test; test. In C++, type: var test: TRect; <br>: <br>: <br>begin test..
  • Type an assignment operator or the beginning of an assignment statement, and press Ctrl+Space to display a list of possible values for the variable.
  • Type a procedure, function, or method call and press Ctrl+Space to display a list of arguments that are valid for assignment to the variable entered. Select a list item followed by an ellipsis (…) to open a second list of related arguments compatible with the variable entered in the assignment statement.
  • Type a record (in Delphi) or a structure (in C++) to display a list of fields.
  • Type an array property (not a genuine array), and press Ctrl+Space to display an index expression.
  • In C++, you can also press Ctrl+Space on a blank statement line to display symbols from additional RTL units even if they are not used by the current unit.

When the Code Completion list is displayed, you can hold down Ctrl and click any identifier in the list to browse to its declaration.  

Also, if you hover the mouse pointer over the identifier in the Code Editor, a hint window tells where the identifier is declared. You can press Ctrl, point to the identifier in the code (it changes to blue underline, by default, and the insertion point changes to a hand pointing), and then click to move to its declaration.

Note: Code Insight works only in the compilation unit. Code Completion supports WM_xxx, CM_xxx, and CN_xxx message methods based on like named constants from all units in the uses clause.
Note: For C++, Code Completion features work best when you have already built your application and have created a precompiled header. Otherwise, you need to wait for the compiler to generate the required information. It is recommended that you check the Use pre-compiled headers
option on the Project->Options->Compiler dialog box.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!