elan-language / LanguageAndIDE

Apache License 2.0
3 stars 0 forks source link

Auto-complete: confused when there is a property and parameter of same name #677

Closed stirlingstout closed 2 months ago

stirlingstout commented 3 months ago

image press Enter and the first field is filled in with property.name image press Enter and the second field is also filled in with property.name.

I can just type name in the second field and get the required result.

richardpawson commented 2 months ago

After discussion, the agree solution is:

1) Whenever you access a property in an assignablefield (which is, by definition, only inside the same class or a sub-class) you must now prefix it with property. Failing to do so will be a compile error - with helpful message saying e.g. assigning to a property requires prefix 'property.'

2) In an assignment field, properties are always listed in the auto-complete options as property.propName even if you start typing propName.

3) In an expression field, the property. is required only to disambiguate - but if there is a property and param (or local variable) with the same name, then the property will be shown in auto-complete with the prefix.

stirlingstout commented 2 months ago

We can't assign to parameters, so in the situation where you try to assign to a name which clashes, instead of saying that's an error, you've got to have property. in front of the identifier could we insert the property. automatically?

It always irritates me when a system says, basically, there's a mistake here, I know what it is, and this is how it needs correcting, but you've got to do it!

Or is this too much like AI and breaks the guarantee of "No AI!"

John

On Mon, 26 Aug 2024, 14:05 Richard Pawson, @.***> wrote:

After discussion, the agree solution is:

1.

Whenever you access a property in an assignable field (which is, by definition, only inside the same class or a sub-class) you must now prefix it with property. Failing to do so will be a compile error - with helpful message saying e.g. assigning to a property requires prefix 'property.' 2.

In an assignment field, properties are always listed in the auto-complete options as property.propName even if you start typing propName. 3.

In an expression field, the property. is required only to disambiguate

  • but if there is a property and param (or local variable) with the same name, then the property will be shown in auto-complete with the prefix.

— Reply to this email directly, view it on GitHub https://github.com/elan-language/LanguageAndIDE/issues/677#issuecomment-2310168132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQQAB3RO44OK5QR2CFHEB3ZTMRYLAVCNFSM6AAAAABL7C7NQ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJQGE3DQMJTGI . You are receiving this because you authored the thread.Message ID: @.***>

richardpawson commented 2 months ago

If you use the auto-complete option then the property. will be inserted automatically for you. If you insist on typing it in full yourself, and don't add the property, you will get the error message. I think that's fair. I don't like auto-correction.

richardpawson commented 2 months ago

re-assigning this to Stef as the original problem is still there. In the following example, for the assignable field it has offered only property.bar, and added it correctly, and I am now entering the RHS field:

image

but if I now hit enter with the selected bar I get:

image

which is incorrect.

scascarini commented 2 months ago

Works on procedures but not constructors. Will investigate later.