Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-01

Code completion improved

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi all,

I improved the code completion for parameters. It can now create methods/procedures for parameters and variables for pointers for parameters.

Here is an example for a procedure:

procedure TForm1.FormCreate(Sender: TObject);
var
  List: TList;
begin
  List:=TList.Create;
  List.Sort(@MySortFunction|);
end;

Place the cursor on 'MySortFunction' and press Ctrl+Shift+C for code completion. You get a new procedure:

function MySortFunction(Item1, Item2: Pointer): Integer;
begin
  |
end;
procedure TForm1.FormCreate(Sender: TObject);
var
  List: TList;
begin
  List:=TList.Create;
  List.Sort(@MySortFunction);
end;

Here is an example for a pointer to a variable:

  procedure TForm1.FormCreate(Sender: TObject);
  begin
    CreateIconIndirect(@IconInfo|);
  end;

Place the cursor on 'IconInfo' and code completion will create:

  procedure TForm1.FormCreate(Sender: TObject);
  var
    IconInfo: TIconInfo;
  begin
    CreateIconIndirect(@IconInfo|);
  end;

Mattias

Reply by email

Paul Ishenin
to Mattias Gaertner

17.01.12 1:40, Mattias Gaertner ?????:

Show quoted text 21 lines
I improved the code completion for parameters. It can now create methods/procedures for parameters and variables for pointers for parameters. Here is an example for a procedure: procedure TForm1.FormCreate(Sender: TObject); var List: TList; begin List:=TList.Create; List.Sort(@MySortFunction|); end; Place the cursor on 'MySortFunction' and press Ctrl+Shift+C for code completion. You get a new procedure: function MySortFunction(Item1, Item2: Pointer): Integer; begin | end;

Wow. You makes us lazy. To go further your completion code needs to guess what to write in implementation of MySortFunction :) Ideally it would be to auto write implementations on completion of well known procedures as Button1Click or Form1Create ;)

Best regards,
Paul Ishenin.

Reply by email

Martin
to Paul Ishenin
Paul Ishenin wrote
Wow. You makes us lazy. To go further your completion code needs to guess what to write in implementation of MySortFunction :) Ideally it would be to auto write implementations on completion of well known procedures as Button1Click or Form1Create ;)

Well actually, talking about automatically writing some code. There are of course cases where this would make sense.

TFoo = class
private
   TBar: TList
end

Now if one were to create a constructor or destructor (or rather both of them), then automatically creating and destroying the list would be nice.

Though this is probably something that requires a dialogue, so one can choose which fields to add and which ones not. The constructor or destructor would then be created if required.

Or there could be a new key stoke(Actually, the current one would work of two), and the cursor would have to be located on TBar.

Reply by email