RAD Studio (Common)
|
The Code Editor occupies the center pane of the IDE window. The Code Editor is a full-featured, customizable, UTF8 editor that provides syntax highlighting, multiple undo capability, and context-sensitive Help for language elements.
As you design the user interface for your application, RAD Studio generates the underlying code. When you modify object properties, your changes are automatically reflected in the source files.
Because all of your programs share common characteristics, RAD Studio auto-generates code to get you started. You can think of the auto-generated code as an outline that you can examine to create your program.
The Code Editor provides the following features to help you write code:
The left margin of the Code Editor displays a green change bar to indicate lines that have not been changed in the current editing session. A yellow change bar indicates that changes have been made since the last File->Save operation.
You can, however, customize the change bars to display in colors other than the default green and yellow.
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 wish 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 sub-sections below.
To invoke Code Insight, press CTRL+SPACE while using the Code Editor. A pop-up window displays a list of symbols that are valid at the cursor location.
To enable and configure Code Insight features, choose ToolsOptionsEditor Options and click Code Insight.
When you're using the Delphi Language, the pop-up window filters out all interface method declarations that are referred to by property read or write clauses. The window displays only properties and stand-alone methods declared in the interface type. Code insight supports WM_xxx, CM_xxx, and CN_xxx message methods based on like named constants from all units in the uses clause.
Displays a hint containing argument names and types for method calls. Available between the parenthesis of a call i.e. ShowMessage ( | );
You can invoke Code Parameter Hints by pressing CTRL+SHIFT+SPACE.
Display a hint containing information about the symbol such as type, file and line # declared at.
You can display Code Hints by hovering the mouse over an identifier in your code, while working in the Code Editor.
Help Insight displays a hint containing information about the symbol such as type, file, line # declared at, 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.
The Code Completion feature displays a drop-down list of available symbols at the current cursor location. You invoke Code Completion for your specific language in the following way:
Delphi — CTRL + SPACE + .
C++ — CTRL + SPACE + —>
Class completion simplifies the process of defining and implementing new classes by generating skeleton code for the class members that you declare. By positioning the cursor within a class declaration in the interface section of a unit and pressing CTRL+SHIFT+C, any unfinished property declarations are completed. For any methods that require an implementation, empty methods are added to the implementation section. They are also on the editor context menu.
When you press ENTER while working in the Code Editor and there is a block of code that is incorrectly closed, the Code Editor enters the closing block token at the next available empty line after the current 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 now have: begin end; . This feature also works for the C++ language.
While using the Code Editor to edit an application such as a VCL Forms application, you can use CTRL-click to automatically "jump to" the code that defines an identifier. To browse code, hold down the CTRL key while passing the mouse over the name of any class, variable, property, method, or other identifier. After the mouse pointer turns into a hand and the identifier is highlighted and underlined, click on the highlighted 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 from the context menu.
Code browsing can find and open only the units that exist in the project Search path or in the global Browsing path. Directories are searched in the following order:
The sections below describe features that you can use to navigate through your code while you are using the Code Editor.
You can navigate between methods using a series of editor hotkeys. You can also lock the hopping to occur only within the methods of the current class. For example, if class lock is enabled and you are in a method of TComponent, then hopping is only available within the methods of TComponent.
The keyboard shortcuts for Method Hopping are as follows:
Allows you to find classes. Use the SearchFind Class command to see a list of available classes that you can select. After you choose one, the IDE navigates to its declaration.
Depending on which language you are programming in, you can use a refactoring feature to locate namespaces or units. If you are using the Delphi language, you can use the Find Unit command to locate and add units to your code file. The Find Type window allows regular expressions.
Live Templates allow you to have a dictionary of pre-written code that can be inserted into your programs while you're working with the Code Editor. This reduces the amount of typing that you must do.
Use the links at the end of this topic to learn more about creating and using Live Templates.
Code folding lets you collapse sections of code to create a hierarchical view of your code and to make it easier to read and navigate. The collapsed code is not deleted, but hidden from view. To use code folding, click the plus and minus signs next to the code.
Refactoring is the process of improving your code without changing its external functionality. For example, you can turn a selected code fragment into a method by using the extract method refactoring. The IDE moves the extracted code outside of the current method, determines the needed parameters, generates local variables if necessary, determines the return type, and replaces the code fragment with a call to the new method. Several other refactoring methods, such as renaming a symbol and declaring a variable, are also available.
The Sync Edit feature lets you simultaneously edit identical identifiers in code. As you change the first identifier, the same change is performed automatically on the other identifiers. You can also set jump points to navigate to specific sections of your code.
A To-Do List records tasks that need to be completed for a project. After you add a task to the To-Do List, you can edit the task, add it to your code as a comment, indicate that it has been completed, and then remove it from the list. You can filter the list to display only those tasks that interest you.
You can record a series of keystrokes as a macro while editing code. After you record a macro, you can play it back to repeat the keystrokes during the current IDE session. Recording a macro replaces the previously recorded macro.
Bookmarks provide a convenient way to navigate long files. You can mark a location in your code with a bookmark and jump to that location from anywhere in the file. You can use up to ten bookmarks, numbered 0 through 9, within a file. When you set a bookmark, a book icon is displayed in the left gutter of the Code Editor.
You can comment-out a section of code by selecting the code in the Code Editor and pressing CTRL+/ (slash). Each line of the selected code is prefixed with // and is ignored by the compiler. Pressing CTRL+/ adds or removes the slashes, based on whether the first line of the code is prefixed with //. When using the Visual Studio or Visual Basic key mappings, use CTRL+K+C to add and remove comment slashes.
RAD Studio allows you to create multiple custom template libraries to use as the basis for creating future projects. Template libraries let you to declare how projects can look, and they enable you to add new types of projects to the Object Repository.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|