Sign in Join

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

Mailing lists / lazarus / 2019-11

Annoying code completion failure

8 messages · 4 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,

TStrings has a property

     property Values[const Name: string]: string read GetValue write SetValue;

The setter is defined as:

procedure SetValue(const Name, Value: string);

Note that both arguments are 'const'

When adding a new property, and pressing 'CTRL-C', the IDE adds the new property, but also insists on adding a new SetValue:

procedure SetValue(const Name: string; AValue: string);

Note the missing const on the second parameter.

It does this of course not only for TStrings, but for all such properties.

Michael.

Reply by email

Ondrej Pokorny
to Michael Van Canneyt
Michael Van Canneyt wrote 19 lines
TStrings has a property     property Values[const Name: string]: string read GetValue write SetValue; The setter is defined as: procedure SetValue(const Name, Value: string); Note that both arguments are 'const' When adding a new property, and pressing 'CTRL-C', the IDE adds the new property, but also insists on adding a new SetValue: procedure SetValue(const Name: string; AValue: string); Note the missing const on the second parameter. It does this of course not only for TStrings, but for all such properties.

The problem is not the const - Lazarus can ignore it. The problem is that the parameters are joined - that is what Lazarus cannot handle.

Replace
     procedure SetValue(const Name, Value: string);
with
     procedure SetValue(const Name: string; const Value: string);

then Lazarus won't add it every time you do class completion. I know - it's not what you currently have in the interface, but the difference is just cosmetic. I usually let Lazarus do its job and don't care that the parameters are separated.

Furthermore, you can make Lazarus to add the "const" automatically in IDE options -> Codetools -> Class Completion -> Property completion -> use const. You can also define an own parameter name or prefix (I use a prefix).

Ondrej

Reply by email

Sven Barth
to Ondrej Pokorny

Ondrej Pokorny via lazarus schrieb am So.,
3. Nov. 2019, 11:21:

Show quoted text 35 lines
On 02.11.2019 11:23, Michael Van Canneyt via lazarus wrote: > TStrings has a property > > property Values[const Name: string]: string read GetValue write > SetValue; > > The setter is defined as: > > procedure SetValue(const Name, Value: string); > > Note that both arguments are 'const' > > When adding a new property, and pressing 'CTRL-C', the IDE adds the new > property, but also insists on adding a new SetValue: > > procedure SetValue(const Name: string; AValue: string); > > Note the missing const on the second parameter. > > It does this of course not only for TStrings, but for all such properties. The problem is not the const - Lazarus can ignore it. The problem is that the parameters are joined - that is what Lazarus cannot handle. Replace procedure SetValue(const Name, Value: string); with procedure SetValue(const Name: string; const Value: string); then Lazarus won't add it every time you do class completion. I know - it's not what you currently have in the interface, but the difference is just cosmetic. I usually let Lazarus do its job and don't care that the parameters are separated.

This is not what one wants to hear. Lazarus really likes to mess with existing code and it's one of the main reasons I'm *not* using class completion inside the compiler, cause otherwise I can be sure that the whole remaining class is changed as well -.-

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20191103/059bcfa9/attachment.html>

Reply by email

Ondrej Pokorny
to Sven Barth
Sven Barth wrote 45 lines
Ondrej Pokorny via lazarus < <mailto:>> schrieb am So., 3. Nov. 2019, 11:21: On 02.11.2019 11:23, Michael Van Canneyt via lazarus wrote: > TStrings has a property > >     property Values[const Name: string]: string read GetValue write > SetValue; > > The setter is defined as: > > procedure SetValue(const Name, Value: string); > > Note that both arguments are 'const' > > When adding a new property, and pressing 'CTRL-C', the IDE adds the new > property, but also insists on adding a new SetValue: > > procedure SetValue(const Name: string; AValue: string); > > Note the missing const on the second parameter. > > It does this of course not only for TStrings, but for all such properties. The problem is not the const - Lazarus can ignore it. The problem is that the parameters are joined - that is what Lazarus cannot handle. Replace      procedure SetValue(const Name, Value: string); with      procedure SetValue(const Name: string; const Value: string); then Lazarus won't add it every time you do class completion. I know - it's not what you currently have in the interface, but the difference is just cosmetic. I usually let Lazarus do its job and don't care that the parameters are separated. This is not what one wants to hear.

Well, I just explained the current state. It doesn't mean it cannot be improved.

Lazarus really likes to mess with existing code and it's one of the main reasons I'm *not* using class completion inside the compiler, cause otherwise I can be sure that the whole remaining class is changed as well -.-

To be honest, the compiler code style is very quirky :)

Ondrej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20191103/f68e8ad4/attachment.html>

Reply by email

Sven Barth
to Ondrej Pokorny

Ondrej Pokorny via lazarus schrieb am So.,
3. Nov. 2019, 23:15:

Show quoted text 47 lines
On 03.11.2019 17:49, Sven Barth via lazarus wrote: Ondrej Pokorny via lazarus schrieb am So., 3. Nov. 2019, 11:21: > On 02.11.2019 11:23, Michael Van Canneyt via lazarus wrote: > > TStrings has a property > > > > property Values[const Name: string]: string read GetValue write > > SetValue; > > > > The setter is defined as: > > > > procedure SetValue(const Name, Value: string); > > > > Note that both arguments are 'const' > > > > When adding a new property, and pressing 'CTRL-C', the IDE adds the new > > property, but also insists on adding a new SetValue: > > > > procedure SetValue(const Name: string; AValue: string); > > > > Note the missing const on the second parameter. > > > > It does this of course not only for TStrings, but for all such > properties. > > The problem is not the const - Lazarus can ignore it. The problem is > that the parameters are joined - that is what Lazarus cannot handle. > > Replace > procedure SetValue(const Name, Value: string); > with > procedure SetValue(const Name: string; const Value: string); > > then Lazarus won't add it every time you do class completion. I know - > it's not what you currently have in the interface, but the difference is > just cosmetic. I usually let Lazarus do its job and don't care that the > parameters are separated. > This is not what one wants to hear. Well, I just explained the current state. It doesn't mean it cannot be improved.

Maybe Michael should file a bug report then... (and I should collect my annoyances as well :P)

Show quoted text 15 lines
Lazarus really likes to mess with existing code and it's one of the main reasons I'm *not* using class completion inside the compiler, cause otherwise I can be sure that the whole remaining class is changed as well -.- To be honest, the compiler code style is very quirky :) Ondrej -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20191103/bf647884/attachment-0001.html>

Reply by email

Sven Barth
to Ondrej Pokorny: Well, I just explained the current state. It doesn't mean it cannot be improved. To be…

Ondrej Pokorny via lazarus schrieb am So.,
3. Nov. 2019, 23:15:

Show quoted text 55 lines
On 03.11.2019 17:49, Sven Barth via lazarus wrote: Ondrej Pokorny via lazarus schrieb am So., 3. Nov. 2019, 11:21: > On 02.11.2019 11:23, Michael Van Canneyt via lazarus wrote: > > TStrings has a property > > > > property Values[const Name: string]: string read GetValue write > > SetValue; > > > > The setter is defined as: > > > > procedure SetValue(const Name, Value: string); > > > > Note that both arguments are 'const' > > > > When adding a new property, and pressing 'CTRL-C', the IDE adds the new > > property, but also insists on adding a new SetValue: > > > > procedure SetValue(const Name: string; AValue: string); > > > > Note the missing const on the second parameter. > > > > It does this of course not only for TStrings, but for all such > properties. > > The problem is not the const - Lazarus can ignore it. The problem is > that the parameters are joined - that is what Lazarus cannot handle. > > Replace > procedure SetValue(const Name, Value: string); > with > procedure SetValue(const Name: string; const Value: string); > > then Lazarus won't add it every time you do class completion. I know - > it's not what you currently have in the interface, but the difference is > just cosmetic. I usually let Lazarus do its job and don't care that the > parameters are separated. > This is not what one wants to hear. Well, I just explained the current state. It doesn't mean it cannot be improved. Lazarus really likes to mess with existing code and it's one of the main reasons I'm *not* using class completion inside the compiler, cause otherwise I can be sure that the whole remaining class is changed as well -.- To be honest, the compiler code style is very quirky :)

Pressed "Send" too soon -.-

I won't argue that point. Nevertheless the IDE should not generate more work :P

Regards,
Sven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20191103/e5452c7c/attachment.html>

Reply by email

Juha Manninen
to Ondrej Pokorny
AM Ondrej Pokorny wrote 6 lines
On 03.11.2019 23:31, Sven Barth via lazarus wrote: > Maybe Michael should file a bug report then... (and I should collect > my annoyances as well :P) Yes, that is definitely a good idea. I face myself 1-2 annoyances as well that I haven't fixed yet.

These are related:
https://bugs.freepascal.org/view.php?id=35413
https://bugs.freepascal.org/view.php?id=23324
https://bugs.freepascal.org/view.php?id=31299
and maybe this one:
https://bugs.freepascal.org/view.php?id=17216

Regards,
Juha

Reply by email