Variable Completion

From The Oxygene Language Wiki

Jump to:navigation, search

This is an IDE topic
Feel free to add your notes to this topic below.


Variable completion is the facility to automatically declare a local variable or class field.


How the Variable Completion Works

Ás an example, assume the following code:

namespace VariableCompletion;

interface

type
  Test = class
  public
    method SayHello;
  end;

implementation

method Test.SayHello;
begin
    lGreeting := 'Hello world';
    Console.WriteLine(lGreeting);
    fHelloSaid := true;
end;

end.

As you can see, there are two undeclared symbols: lGreeting and fHelloSaid. The first symbol is intended to be a local variable, the second a class instance field. After invoking Variable completion for both symbols, the code will be modified as follows:

namespace VariableCompletion;

interface

type
  Test = class
  public
    method SayHello;
  private
  fHelloSaid: Boolean;
  end;

implementation

method Test.SayHello;
var
  lGreeting: String;
begin
  lGreeting := 'Hello world';
  Console.WriteLine(lGreeting);
  fHelloSaid := true;
end;

end.

Notice the fHelloSaid field declaration stub and the local variable lGreeting declaration. Variable completion correctly guesses:

User can manually correct fields visibility level, though it is a good practice to declare all fields private.

NOTE: Variables and fields are distinguished by name when using Variable completion. The symbol should begin with 'l' character to become a local variable or with 'f' to become a field.

Variable Completion Invocation

Variable completion is invoked either with the hot keys CTRL+SHIFT+V or via the editor context menu, when caret in the Code Editor is positioned on the undeclared symbol.


Oxygene-48.png

Area: Oxygene IDE

IDE GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox