Sign in Join

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

Mailing lists / lazarus / 2016-11

ctrl-c code completion

14 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Van Canneyt

Hi,

Why does the IDE insist on reformatting existing declarations ?

I added 1 method to TStrings, press ctrl-c to do command-completion, and it changes the headers of all methods, changing

- Function to function,

- Procedure to procedure

- and the setter in

   property Values[const Name: string]: string read GetValue write SetValue;
   is changed from
   procedure SetValue(const Name, Value: string);
   to
   procedure SetValue(const Name : string; Const Value: string);
   Causing the compiler to generate an error...

I can appreciate that the latter is difficult to handle, but the former is really annoying. An svn diff consists out of 90%+ junk after that :/

Michael.

Reply by email

Michael Van Canneyt
to Bart
Bart wrote 7 lines
On 11/6/16, Michael Van Canneyt via Lazarus wrote: > Why does the IDE insist on reformatting existing declarations ? Tools->Options->Codetools->Class Completion Uncheck: "Update all method signatures" ?

Well, thank you very much.
I should visit those options pages more often...

Michael.

Reply by email

Bart
to Lars
Lars wrote 5 lines
On Sun, November 6, 2016 10:05 am, Michael Van Canneyt via Lazarus wrote: > > press ctrl-c to do command-completion If ctrl - c is for copying, how does this not interfere?

It is Shift+Ctrl+C by default.

Bart

Reply by email

Mattias Gaertner
to Michael Van Canneyt: Why does the IDE insist on reformatting existing declarations ? I added 1 method to…
Show quoted text 18 lines
[...] - Function to function, - Procedure to procedure - and the setter in property Values[const Name: string]: string read GetValue write SetValue; is changed from procedure SetValue(const Name, Value: string); to procedure SetValue(const Name : string; Const Value: string); Causing the compiler to generate an error...

Why does that cause a compiler error?

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 23 lines
On Sun, 6 Nov 2016 18:05:39 +0100 (CET) Michael Van Canneyt via Lazarus wrote: > [...] > - Function to function, > > - Procedure to procedure > > - and the setter in > > property Values[const Name: string]: string read GetValue write SetValue; > > is changed from > > procedure SetValue(const Name, Value: string); > > to > > procedure SetValue(const Name : string; Const Value: string); > > Causing the compiler to generate an error... Why does that cause a compiler error?

Because both procedures remained in the sources.

Open classes unit, press code completion shortcut while in TStrings (or was it TStringlist?), and observe the effect... I noticed this while fixing a bug report.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
> > > > Why does that cause a compiler error? Because both procedures remained in the sources.

I can confirm, I've seen this quite a few times recently too.

Not sure if this is related:
Another way to reproduce this is to change the parameters of two overloaded methods and then do Ctrl+Shift+C to class complete (update their implementation signatures). Instead of updating the existing methods, it defines new ones.

Regards,
Graeme

Reply by email

Mattias Gaertner
to Michael Van Canneyt: Because both procedures remained in the sources. Open classes unit, press code completion…
Show quoted text 30 lines
On Tue, 8 Nov 2016, Mattias Gaertner via Lazarus wrote: > On Sun, 6 Nov 2016 18:05:39 +0100 (CET) > Michael Van Canneyt via Lazarus wrote: > >> [...] >> - Function to function, >> >> - Procedure to procedure >> >> - and the setter in >> >> property Values[const Name: string]: string read GetValue write SetValue; >> >> is changed from >> >> procedure SetValue(const Name, Value: string); >> >> to >> >> procedure SetValue(const Name : string; Const Value: string); >> >> Causing the compiler to generate an error... > > Why does that cause a compiler error? Because both procedures remained in the sources. Open classes unit, press code completion shortcut while in TStrings (or was it TStringlist?), and observe the effect... I noticed this while fixing a bug report.

Please create a bug report.

Mattias

Reply by email

Mattias Gaertner
to Graeme Geldenhuys: I can confirm, I've seen this quite a few times recently too. Not sure if this is related:
Show quoted text 8 lines
[...] I can confirm, I've seen this quite a few times recently too. Not sure if this is related: Another way to reproduce this is to change the parameters of two overloaded methods and then do Ctrl+Shift+C to class complete (update their implementation signatures). Instead of updating the existing methods, it defines new ones.

In this case codetools don't have enough information. Because it does not know the former connection. It only sees two declarations without bodies and two bodies without declarations. It can't know for sure which belong together. The non-interactive-code-completion should stop with an error. The interactive can ask.

Please create a report.

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote
In this case codetools don't have enough information. Because it does not know the former connection.

By why does it work if I do them one at a time. eg: Change the first interface declaration and do code completion. Change the second interface declaration and do code completion. That works.

But doing them at the same time it doesn't.

So in the first case, CodeTools somehow knows the connection, even though the interface and implementation declarations don't match (until code completion is invoked). It then magically knows which implementation declaration to update.

So why would CodeTools not know the connection when both interface declarations are updated at the same time? I don't know how CodeTools works, but I would imagine it has some memory lookup (line numbers) where interface declaration xyz has an implementation at line 123. So when the declaration xyz changes (by the developer), go to line 123 and change it there too?

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Ondrej Pokorny
to Graeme Geldenhuys
Graeme Geldenhuys wrote 13 lines
On 2016-11-08 13:14, Mattias Gaertner via Lazarus wrote: > In this case codetools don't have enough information. Because it does > not know the former connection. By why does it work if I do them one at a time. eg: Change the first interface declaration and do code completion. Change the second interface declaration and do code completion. That works. But doing them at the same time it doesn't. So in the first case, CodeTools somehow knows the connection, even though the interface and implementation declarations don't match (until code completion is invoked). It then magically knows which implementation declaration to update.

No the incompatibility ratio of interface methods : implementation methods is 1:1 then the connection is more than obvious. It doesn't work only with overloads. You can rename the method and it works as well.

Just do changes one by one and you are good to go.

Ondrej

Reply by email

Mattias Gaertner
to Graeme Geldenhuys: By why does it work if I do them one at a time. eg: Change the first interface…
Show quoted text 7 lines
On 2016-11-08 13:14, Mattias Gaertner via Lazarus wrote: > In this case codetools don't have enough information. Because it does > not know the former connection. By why does it work if I do them one at a time. eg: Change the first interface declaration and do code completion. Change the second interface declaration and do code completion. That works.

Because this case is unambiguous. There is only one possible mapping.

But doing them at the same time it doesn't.

Yes, with two you have two possible mappings. Three has six and so forth. Basic math: n!

So, as Ondrej wrote:
Just do changes one by one and you are good to go.

Show quoted text 7 lines
[...] So why would CodeTools not know the connection when both interface declarations are updated at the same time? I don't know how CodeTools works, but I would imagine it has some memory lookup (line numbers) where interface declaration xyz has an implementation at line 123. So when the declaration xyz changes (by the developer), go to line 123 and change it there too?

Codetools only sees the sources when the IDE invokes it (e.g. code completion). It has no idea what happens since last time in the IDE and it does not store old states, so it can't compare versions.

Theoretically something similar to synedits Syncro-Edit could be implemented for procedure declaration/implementation. Or even better: something similar to rename-identifier, but for procedures: rename, remove parameter, move parameter, insert parameter, and all references are updated too. I started that, but it needs much work.

Mattias

Reply by email