Translating Case
A Natural source can be written in a consistent case, regardless of how the developer enters the text. As in the NaturalONE source editor, case translation is available in two forms:
Upper case translation on save: When you save the source, the editor translates the entire source to upper case.
Upper Case / Lower Case for selected text: When you select text in the Natural source editor, the context menu provides the
Upper Case and
Lower Case commands. These commands are also available with Alt+U and Alt+L, respectively, and from the Command Palette as
Natural: Upper Case and
Natural: Lower Case. Only the selected text is translated. The selection is retained, and the source remains unsaved, as after any other edit.
Both forms of case translation are based on the tokens of the source rather than on its text. For example, a selection that ends in the middle of a string constant still recognizes the selected part as belonging to a string constant. Similarly, if only part of a keyword is selected, only the selected part is translated.
What is Translated
Part of the source | Translated |
Statements, keywords, identifiers, numbers, formats such as a20, and operators | Always. This is what translating the source means. |
Hexadecimal, date, time, and extended date/time constants | Always. Their content consists of digits rather than text. For example, h'4142' becomes H'4142'. |
The U prefix of U'...' and U"..." | Always. The prefix is syntax, rather than text. With the constant itself excluded from translation, u'unicode' becomes U'unicode'. |
Comments | Only when the comments option is enabled. |
Single-quoted string constants '...' | Only when the singleQuoteStrings option is enabled. |
Double-quoted string constants "..." | Only when the doubleQuoteStrings option is enabled. |
Note:
The Natural source header is never translated, not even if the comments option is enabled.
Case Translation Preferences
Case translation is enabled with the natural.editor.caseTranslation.enabled preference (default: false). This preference controls both translation on save and the Upper Case and Lower Case commands, just as the Enable case translation check box does in NaturalONE.
The three options described above, together with
upperCaseOnSave (default:
true), are keys of
natural.editor.caseTranslation.options; see also
Preparing the Workspace.
If upperCaseOnSave is disabled, saving the source does not change its case. Case translation is then available only through the Upper Case and Lower Case commands for selected text.
The options have no effect on their own. They apply only when case translation is enabled.