ABOUT
This plug-in declares properties based on a field declaration on the current line. The developer is given near-complete control over the creation of the new properties, including specifying Accessor methods, Scope, and Dispatch.
whether you want to have Get and Set methods. You can also specify scope and dispatch (static, virtual, etc.).
FEATURES
Instant Property Declaration registers a new string function ("InstantProperty") that displays a dialog allowing you to specify the details of the property being created, such as:
- Accessors: Supports using either, neither, or both of the accessors. The plug-in adapts between using field or accessor combinations depending on your selections. From this dialog, you are also able to specify the scope of the Accessor methods (private, protected, etc).
- Dispatch: Allows you to set the Dispatch (static, virtual, override, etc).
- Implementation: Optionally creates skeleton code for the property's Get and Set methods.
- Property: Allows you to specify the scope of the property being created (public, published, etc). In addition, the property can be declared Read Only; if this is selected the Write clause is omitted from the property declaration.
- Uses your code-style settings for colons, semicolons, and parentheses.
Instant Property Declaration is invoked via a Keyboard Shortcut. By default, the shortcut is IP. This shortcut's expansion is "%?InstantProperty()%" which launches the string function "InstantProperty".
When invoked, this plug-in grabs the two preceding tokens off the same line. It uses them as the basis for creating the new property (for example, on the line "FSize: Integer;", InstantProperty would read a Field token of "FSize" and a Type token of "Integer"). A standard naming convention in Delphi is to precede field variables with the letter "F" and to name their associated properties as the field variable minus the leading "F". InstantProperty supports this naming convention.
If the field token starts with the letter "F", the plug-in will strip it when assigning the property name (in the example above, this would create a property named Size of type Integer). If the field token does not begin with an "f" or "F", this plug-in prompts the user for a property name, as is shown in the dialog below.
This user-entered name is then used when creating the property.
The New Property dialog (shown at the top) appears next for the developer to fine-tune the details of the new property.
Convert Variable to Property
This plug-in provides one additional advanced feature; this is the Convert Variable to Property function. If the field variable selected when InstantProperty is invoked has either Public or Published scope it is unlikely that this is a new field variable; rather, it is more likely that it is actually an existing public variable that the user would like to "convert" to a property. In this case, a dialog appears to prompt the user if they would like to convert the variable to a property and, if so, what should be the scope for the new field variable.
If the user declines, the plug-in operates as normal. If user confirms, the variable is renamed by prefixing its existing name with an "F." The renamed variable is moved to the user-indicated scope and the plug-in continues as normal.