Refactoring |
Top Previous Next |
User interface > Translation options > Refactoring The refactoring dialog is reached from the button on the options dialog. The Dialog shows the list of refactoring items:
Another dialog with the details of a refactoring item is shown, if a new item is added or an existing item is edited:
Variables, functions and constants which shall be changed are looked up according to the criteria, which are given by the control elements the on the left side of the dialog. At least the original name has to be specified, the other criteria are optional. On the right side of the dialogs the resulting properties can be set. Again at least a new name has to be set and the other properties are optional.
"Original name" and "New name"
The original name of a variable, function or constant in the Delphi source code will be changed to the new name in the C# output. The input in the field is treated case insensitive in the same way as the source code by the pre-processor. For example with input in the image above all occurrences of "Min" in the source code will be changed to to "Math.Min", regardless whether "Min"; "min", "mIN" or any other case occurs in the code. If the identifier for the original name isn't contained in the list of notations, it's notation will be used for all notations of the identifier in the generated code.
"Original type is:"
The general kind of type of the variable, function or constant which shall be changed can be specified, to exclude all other kinds from this refactoring. If, as in the image above, "Min" is specified as a function, variables or constants with the name "Min" will not be changed. If all occurrences of "Min" shall be changed regardless of the kind, it can be set to "unspecified": In contrast to the other fields in the dialog, the general kind of type cannot be changed and will remain the same in the output as in the source code.
"Original type" and "New type"
If "function" is selected "Original type" and "New type" are specifying the result type of the function. otherwise "Original type" and "New type" specify the type of an built-in type, if this item is selected. Normally the type should be identical, but there might be cases where it is desired to avoid or to force typecasts by means of a change of the result type.
For the new type also a free identifier can be set.
"Original pointer" and "New pointer"
Again, normally the pointer of the type should not be changed.
Generics
By use of the "Generics" option Delphi2C# distinguishes between generic and non generic types. In the following example only the generic type is substituted:
uses System.Classes, System.Generics.Collections;
var L1 : TList; L2 : TList<Integer>;
->
TList L1 = null; TMyList<int> L2 = null;
Original unit
The input in the field for the original unit is treated case insensitive in the same way as the source code by the pre-processor and "Original name" in the dialog.
Using
In contrast to the "Original unit" field, the input in the "Using" field is case sensitive. Therefore the "System.math" will produce the output lines
using System.math; using static System.math.mathClass;
Remove original declaration
If this option is set the original declaration of the refactored type is omitted at the translation of the file where it was declared.
----------
The table items can be loaded and saved via the popup menu.
|
This page belongs to the Delphi2C# Documentation |
Delphi2C# home Content |