[Cuis-dev] Code completion

Hernán Wilkinson hernan.wilkinson at 10pines.com
Thu Dec 22 11:26:55 PST 2022


Hi Hilaire,
 it is a pity it is difficult to understand... I tried my best to make it
more understandable from what we had before 😓
 The mail message is #computeEntries, that is the one that has to set the
message you want to show to the variable entries.
 If you download CuisUniveristy, you will see
a DenotativeObjectNameCompleter or a DenotativeObjectCompleter that
customizes how the completer works. Also, you  will find
the LiveTypingSmalltalkCompleter that uses the typing information collected
by live typing to improve the shown entries.

 PluggableTextModel is the one that uses the auto completer, and for that
to be customized you have to look at autoCompleterClass and
#autoCompleterClassFor: send to a textProvider with the textGetter.

 My suggestion, to understand how it works is to put a #halt in the method
SmalltalkCompleter>>computeEntries and the press tab for the debugger to
appear. That way you will be able to follow in the debugger how it works.
That is what I did to understand it a couple of years ago.

  If you let me know what you need I may help you a bit.

Cheers!
Hernan.


On Thu, Dec 22, 2022 at 4:13 PM Hilaire Fernandes via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> Hi Juan et al.
>
> I took a look a this class and messages and I understand mostly nothing.
> It is not easy code to read. Zero comment in the class on how to use it,
> hard :( We can do better, easily :-).
>
> Particularly it is not clear to me if the my view should be referenced
> somehow in the Completer.
>
> I know that my computeMessageEntriesIn:ofTempVarNamed:is not called, so
> the context of the class I want for code completion of method names does
> not work, for sure.
>
> Do I need to register my view as a model to get completion on it?  I can
> read in the method below there is a specificModel variable:
>
> computeMessageEntriesFor: allSource at: range in: contextClass and:
> specificModel
>
>     | id rangeType |
>
>     canShowSelectorDocumentation true.
>     id allSource copyFrom: range start to: range end.
>     rangeType range rangeType.
>
>     rangeType == #globalVar
>         ifTrue: [ self computeMessageEntriesForClass: (Smalltalk at: id
> asSymbol) class ].
>     rangeType == #self
>         ifTrue: [ self computeMessageEntriesForClass: contextClass ].
>     rangeType == #super
>         ifTrue: [ self computeMessageEntriesForClass: contextClass
> superclass ].
>     rangeType == #true
>         ifTrue: [ self computeMessageEntriesForClass: True ].
>     rangeType == #false
>         ifTrue: [ self computeMessageEntriesForClass: False ].
>     rangeType == #nil
>         ifTrue: [ self computeMessageEntriesForClass: UndefinedObject ].
>     rangeType == #character
>         ifTrue: [ self computeMessageEntriesForClass: id first class ].
> ../..
>
>     rangeType == #instVar
>         ifTrue: [ specificModel computeMessageEntriesIn: self
> ofInstVarNamed: id ].
>     rangeType == #methodArg
>         ifTrue: [ specificModel computeMessageEntriesIn: self
> ofTempVarNamed: id ].
>     rangeType == #tempVar
>         ifTrue: [ specificModel computeMessageEntriesIn: self
> ofTempVarNamed: id ].
>     rangeType == #blockArg
>         ifTrue: [ specificModel computeMessageEntriesIn: self
> ofBlockArgNamed: id ].
>     rangeType == #blockTempVar
>         ifTrue: [ specificModel computeMessageEntriesIn: self
> ofBlockTempVarNamed: id ].
>
>
> Or/and do I need to define a few more methods in my view, as computeMessageEntriesIn:ofBlockArgNamed:...
> ?
>
> So far my view contains these two specific methods for code completion:
>
> computeMessageEntriesIn: aDynamicTypingSmalltalkCompleter ofTempVarNamed:
> aString
>
>     aDynamicTypingSmalltalkCompleter
>         computeMessageEntriesForClassOrNil: (DrGeoSystem preferences at:
> #programmingCodeCompletion)
> autoCompleterClassFor: textGetter
>     ^ SmalltalkCompleter
>
> Idea, pointer?
>
> Hopefully this thread will document a bit this very narrow topic but
> nevertheless useful in some circumstance.
>
> Thanks !
>
> Hilaire
> Le 22/12/2022 à 14:24, Juan Vuletich a écrit :
>
>
> Take a look at the AutoCompleter hierarchy. See, for instance,
> ClassNameCompleter, added by Hernán some time ago. You can build your own
> in a similar fashion.
>
> If you follow #computeEntries in SmalltalkCompleter, you'll see how the
> set of messages offered is restricted to the receiver, when we know about
> it.
>
> Hope this helps.
>
> --
> 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/20221222/0452b4fe/attachment-0001.htm>


More information about the Cuis-dev mailing list