[Cuis-dev] Code completion
Hernán Wilkinson
hernan.wilkinson at 10pines.com
Wed Dec 28 05:33:00 PST 2022
Hi Hilaire,
the code complete tool uses the "class" of the receiver to show the
selectors. If you have this code:
DrGeoSketch new seg...
the receiver is the returned object of the message #new, but there is no
way to know what #new is going to return. That is why it shows all the
selectors starting with seg. Ok ok, you could say that it will return an
instance of DrGeoSketch, but the code completion of cuis does not do that
kind of inference, the code completion of Cuis with LiveTyping does.
If you have this code:
| t |
t := DrGeoSketch new.
t seg...
The result will depend on where you are typing that code and on the
binding of the variable t (that is, if t is referencing an object or not).
If you are writing that code in the smalltalk browser, t will never have a
binding while typing (the code does not run in the browser), so the code
completion will show you all the selectors starting with seg
If you are writing that code in an editor where variables are bound while
editing the code (a workspace, a debugger, an inspector, etc), then two
things can happen:
a) if the code was never ran, the variable t will not be referencing an
object and the code completion will show you all the selectors starting
with seg
b) if the code was run and t is referencing an instance of DrGeoSketch,
then the code completion will show you all the selectors starting with seg
that a DrGeoSketch instance knows how to answer.
At the end, everything comes down to knowing the class of the receiver.
When the code completion has that info, the selectors it will show will be
right ones, when it does not, it will show all the selectors that start
with what you typed.
As I said before, if you have LiveTyping installed, knowing the class of
the receiver is what LiveTyping does so the code completion works as in a
statically typed language.
I tried this example in a DrGeo image and it works as I mentioned, but I
see why the code completion is not working as you expected.
The class DrGSmalltalkSketchEditor does not behave as a workspace,
therefore when parsing the code, it is expecting the method name pattern
that it does not have. If you put a halt in the method
#computeMessageEntriesIn:ofTempVarNamed: of that class, you will see that
it never halts.
To make DrGSmalltalkSketchEditor you should implement the message #is:
like this:
is: aSymbol
aSymbol == #providesBindings or: [ super is: aSymbol ]
And then implement the messages it is expecting for an object that
provides bindings like #hasBindingOf:, etc.
I would make the model of DrGSmalltalkSketchEditor to be an instance of
Workspace, that way the code completion will behave as in the workspace
that is what you are trying to accomplish.
I hope this help!
Hernan.
On Tue, Dec 27, 2022 at 4:34 PM Hilaire Fernandes via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:
> Hi Hernán,
>
> Yes, you can try from the latest DrGeo release 22.12 (
> https://launchpad.net/drgeo/+download)
>
> In the menu go to: 'Herramientas>Editor de boceto Smalltalk'
>
> You will have the Smalltalk sketch editor.
>
> If you make completion after 'DrGeoSketch new segm...' you will have
> messages not related to DrGeoSketch class. Only #segment:to is related to
> DrGeoSketch.
>
> I guess I have some missing peace in my tool (DrGSmalltalkSketchEditor)
>
> Hilaire
> Le 27/12/2022 à 16:00, Hernán Wilkinson via Cuis-dev a écrit :
>
> that is weird.
> It should show you the same selectors because the autocomplete has no clue
> about the receiver's type...
> I tried it in a Cuis image with another class and it shows me the same
> selectors in both cases.
> Do you have an image I can download to try to reproduce that behavior?
> Do you do it in a workspace or a browser?
>
> --
> GNU Dr. Geohttp://drgeo.euhttp://blog.drgeo.eu
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
--
*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20221228/26632123/attachment-0001.htm>
More information about the Cuis-dev
mailing list