[Cuis-dev] Code completion

Hilaire Fernandes hfern at free.fr
Thu Dec 22 11:13:33 PST 2022


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. Geo
http://drgeo.eu
http://blog.drgeo.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20221222/0e3bef13/attachment.htm>


More information about the Cuis-dev mailing list