LeonMatthes / Autocompletion

A modern Autocompletion for your Squeak image
8 stars 3 forks source link

Correctly autocomplete continued parts of keyword selectors #55

Open LinqLover opened 10 months ago

LinqLover commented 10 months ago

Example:

image

becomes:

image

instead of:

image

Would be very useful!

LeonMatthes commented 10 months ago

This is one of the parts of Autocompletion I find most annoying. Totally agree this is an issue.

The reasons that this is hard to solve are unfortunately many-fold:

This makes it very hard to figure out correctly, as we'd need to:

  1. Find all possible receivers
    • For continuation of existing selectors
    • Depending on precedence (Receivers for n-ary functions can be different than for binary functions or unary functions *)
  2. For each potential receiver, inject the valid selectors (and only those valid in this context) into the suggestions
  3. When completing, only inject the missing parts of the selector

In this case the selector do: displayingProgress: is actually even inserted correctly. #yourself is a collection, so you can indeed call do: displayingProgress on it! The correct solution here would probably actually be to suggest both: do:displayingProgress: on #yourself and then inserting parentheses:

#() do: (#yourself do: ___ displayingProgress: ___) 

and also suggest displayingProgress: separately.

* Determining the receiver for a common comparison is actually stupidly difficult

conditions addLast: 1 > 5 "| <--- CURSOR"
"                       ^ receiver for unary messages (e.g. negated) or maybe n-ary messages when adding parens"
"                   ^^^^^ receiver for binary messages (e.g. &) or maybe n-ary messages (e.g. and:), when adding parens"
"^^^^^^^^^ receiver for certain n-ary messages due to continuation (e.g. addLast:times:)"

Any suggestions to handle this in a sane way are highly welcome :see_no_evil: