Sign in Join

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

Mailing lists / lazarus / 2013-06

Updating procedure signatures

11 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,

Code completion can now update procedure signatures. For example:

procedure DoSomething;
implementation
procedure DoSomething;
begin
end;

Now add a parameter c:char to the interface procedure:

procedure DoSomething(c: char);

Place cursor on this declaration and invoke code completion (Ctrl+Shift+C). This will replace the signature in the implementation section.

procedure DoSomething(c: char);
implementation
procedure DoSomething(c: char);
begin
end;

Note: It does not work backward from implementation to interface.

How it works:
codetools tries to map all interface and implementation procedures. First by name+param list then by name. If this is ambiguous (e.g. there are two DoSomething and you changed both parameters) then codetools will not update the signature and instead create a new implementation. You can undo this.

Options:
By default code completion updates all signatures it can map. If you only want single updates, disable the option Tools / Options / Codetools / Code Creation / Update multiple procedure signatures.

There is now an option to disable the same for methods: Tools / Options / Codetools / Class Completion / Update all method signatures

Mattias

Reply by email

Vojtěch Čihák
to Mattias Gaertner

Hello,
?
it isn't a new feature, or am I missing something? I think this exist?at least one year.
?
@ Note: It does not work backward from implementation to interface. ?
Furthermore, I tried to add parameter in implementation and it updates the interface here. ?
Lazarus 1.1 r41867M FPC 2.7.1 x86_64-linux-qt?
?
Vojt?ch?
______________________________________________________________

Show quoted text 5 lines
Od: "Mattias Gaertner" Komu: Datum: 25.06.2013 13:09 P?edm?t: [Lazarus] Updating procedure signatures

Hi all,

Code completion can now update procedure signatures. For example:

procedure DoSomething;
implementation
procedure DoSomething;
begin
end;

Now add a parameter c:char to the interface procedure:

procedure DoSomething(c: char);

Place cursor on this declaration and invoke code completion (Ctrl+Shift+C). This will replace the signature in the implementation section.

procedure DoSomething(c: char);
implementation
procedure DoSomething(c: char);
begin
end;

Note: It does not work backward from implementation to interface.

Mattias

Reply by email

Mattias Gaertner
to Vojtěch Čihák
Hello, ? it isn't a new feature, or am I missing something? I think this exist?at least one year.

Yes, for methods. Not for procedures.

?

@ Note: It does not work backward from implementation to interface. ? Furthermore, I tried to add parameter in implementation and it updates the interface here.

It works for one *method*.

Mattias

Reply by email

Vojtěch Čihák
to Mattias Gaertner

Thanks. I understand now.
?
I tested it a little (Lazarus 1.1 r41895M FPC 2.7.1 x86_64-linux-qt) and I have two issues: ?
1) Inconsistent behaviour when both options are UNchecked (Update all method signatures and Update multiple procedure signatured are OFF) ?
this:
procedure A(a: string); | //hit CTRL+SHIFT+C here
procedure B(a: string);

implementation
procedure A;
begin
end;
procedure B;
begin

end; ?
?
leads to this:
?
procedure A(a: string); |
procedure B(a: string);

implementation
procedure A(a: string);
begin
end;
procedure B;
begin
end;
?
BUT this:
?
public
 { public declarations }
 procedure A(a: string); | ?//hit CTRL+SHIFT+C here
 procedure B(a: string);
 end;
var
 Form1: TForm1;
implementation

{ TForm1 }

procedure TForm1.A;
begin
end;
procedure TForm1.B;
begin

end; ?
?
leads to this:
?
public
{ public declarations }
procedure A(a: string); |
procedure B(a: string);
end;

var
 Form1: TForm1;
implementation

{ TForm1 }

procedure TForm1.A(a: string);
begin
end;
procedure TForm1.B(a: string);
begin
end;
procedure TForm1.B;
begin

end;
?
i.e. the third method is created
?
2) Attempt to update signature of procedure (not method) backwards from implememtation to interface leads to Acces Violation or Out of memory error, it sometimes kills IDE. It works well for one method, as you mentioned in your mail. ?
Vojt?ch
?
______________________________________________________________

Show quoted text 5 lines
Od: "Mattias Gaertner" Komu: Datum: 25.06.2013 16:26 P?edm?t: Re: [Lazarus] Updating procedure signatures

On Tue, 25 Jun 2013 13:34:59 +0200
Vojt?ch ?ih?k wrote:

Yes, for methods. Not for procedures.

Mattias

Reply by email

Mattias Gaertner
to Vojtěch Čihák
Show quoted text 38 lines
Thanks. I understand now. ? I tested it a little (Lazarus 1.1 r41895M FPC 2.7.1 x86_64-linux-qt) and I have two issues: ? 1) Inconsistent behaviour when both options are UNchecked (Update all method signatures and Update multiple procedure signatured are OFF) ? this: procedure A(a: string); | //hit CTRL+SHIFT+C here procedure B(a: string); implementation procedure A; begin end; procedure B; begin end; ? ? leads to this: ? procedure A(a: string); | procedure B(a: string); implementation procedure A(a: string); begin end; procedure B; begin end;

Correct.

?

Show quoted text 56 lines
BUT this: ? public { public declarations } procedure A(a: string); | ?//hit CTRL+SHIFT+C here procedure B(a: string); end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.A; begin end; procedure TForm1.B; begin end; ? ? leads to this: ? public { public declarations } procedure A(a: string); | procedure B(a: string); end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.A(a: string); begin end; procedure TForm1.B(a: string); begin end; procedure TForm1.B; begin end; ? i.e. the third method is created

Correct. Disabling the option gets the old behavior.

?

2) Attempt to update signature of procedure (not method) backwards from implememtation to interface leads to Acces Violation or Out of memory error, it sometimes kills IDE.

Please create bug report with an example.

It works well for one method, as you mentioned in your mail.

Mattias

Reply by email

Martin
to Mattias Gaertner: Code completion can now update procedure signatures. For example: procedure DoSomething;…
Mattias Gaertner wrote
There is now an option to disable the same for methods: Tools / Options / Codetools / Class Completion / Update all method signatures

What do I need to see the option ?

I updated to 41902, I did a clean build (in fact 2 times). It is not there.

I looked at the frame, and it was not there either, svn says I have an unmodified version of that frame

Reply by email

Martin
to Mattias Gaertner: Code completion can now update procedure signatures. For example: procedure DoSomething;…
Mattias Gaertner wrote
Hi all, Code completion can now update procedure signatures. For example:

...

Show quoted text 16 lines
How it works: codetools tries to map all interface and implementation procedures. First by name+param list then by name. If this is ambiguous (e.g. there are two DoSomething and you changed both parameters) then codetools will not update the signature and instead create a new implementation. You can undo this. Options: By default code completion updates all signatures it can map. If you only want single updates, disable the option Tools / Options / Codetools / Code Creation / Update multiple procedure signatures. There is now an option to disable the same for methods: Tools / Options / Codetools / Class Completion / Update all method signatures

it would be nice to be able to set this option separate for procedure/messages that:
- are functional change (changes that fpc will notice, and can not compile, without the update)
- syntactical (change amount of whitespace, or letter-casing) (fpc will still compile corect, without codetool update)

leading to 2*2 options

Reply by email

Mattias Gaertner
to Martin: What do I need to see the option ? I updated to 41902, I did a clean build (in fact 2…
Show quoted text 11 lines
On 25/06/2013 12:04, Mattias Gaertner wrote: > There is now an option to disable the same for methods: > Tools / Options / Codetools / Class Completion / Update all method > signatures > What do I need to see the option ? I updated to 41902, I did a clean build (in fact 2 times). It is not there. I looked at the frame, and it was not there either, svn says I have an unmodified version of that frame

Maybe you are looking at fixes branch?

Mattias

Reply by email

Mattias Gaertner
to Martin: ... it would be nice to be able to set this option separate for procedure/messages that:…
Show quoted text 13 lines
On 25/06/2013 12:04, Mattias Gaertner wrote: [...] > There is now an option to disable the same for methods: > Tools / Options / Codetools / Class Completion / Update all method > signatures > it would be nice to be able to set this option separate for procedure/messages that: - are functional change (changes that fpc will notice, and can not compile, without the update) - syntactical (change amount of whitespace, or letter-casing) (fpc will still compile corect, without codetool update)

Whitespaces and comments are ignored while comparing. This leaves letter-case.

leading to 2*2 options

AFAIK either someone wants letter casing for signatures or not. Independent of methods or procedures. So it should only be one option on Code Creation.

Mattias

Reply by email

Martin
to Mattias Gaertner: On Wed, 26 Jun 2013 09:26:38 +0100 Maybe you are looking at fixes branch? Mattias
Mattias Gaertner wrote 16 lines
On Wed, 26 Jun 2013 09:26:38 +0100 Martin wrote: > On 25/06/2013 12:04, Mattias Gaertner wrote: >> There is now an option to disable the same for methods: >> Tools / Options / Codetools / Class Completion / Update all method >> signatures >> > What do I need to see the option ? > > I updated to 41902, I did a clean build (in fact 2 times). It is not there. > > I looked at the frame, and it was not there either, svn says I have an > unmodified version of that frame Maybe you are looking at fixes branch?

definitely in trunk

even deleted
ide\frames\codetools_codecreation_options.pas and lfm

still nothing.
That is I do get the checkbox for procedures. But not for messages.

I even checked the file (the svn checkout, in an external editor. So it is not a problem with a copy in the unit output dir or similar

Reply by email

Martin
to Mattias Gaertner: On Wed, 26 Jun 2013 09:31:46 +0100 Whitespaces and comments are ignored while comparing.…
Mattias Gaertner wrote 17 lines
On Wed, 26 Jun 2013 09:31:46 +0100 Martin wrote: > it would be nice to be able to set this option separate for > procedure/messages that: > - are functional change (changes that fpc will notice, and can not > compile, without the update) > - syntactical (change amount of whitespace, or letter-casing) (fpc will > still compile corect, without codetool update) Whitespaces and comments are ignored while comparing. This leaves letter-case. > leading to 2*2 options AFAIK either someone wants letter casing for signatures or not. Independent of methods or procedures. So it should only be one option on Code Creation.

OK

Reply by email