Skip to content

API reference

Leon Matthes edited this page May 4, 2020 · 3 revisions

Public API functions

Enabling/Disabling Autocompletion

To enable or disable Autocompletion for a given PluggableTextMorphPlus, just overwrite the wantsAutocompletion function in the Model that is provided to the PluggableTextMorphPlus and return a boolean accordingly.

Example:

wantsAutcompletion
    ^ true

or enable Autocompletion depending on custom conditions:

wantsAutocompletion
    ^ self isCodeInEditor "Any condition that returns a Boolean can be used"

Providing custom names to Smalltalk code

If your tool creates Smalltalk objects that are accessible by name, your tool will probably want to provide type information for the Autocompletion. A good example of this is the Workspace, in which you can create persistent variables by assigning something to an unused name.

myvar := 1.

So the Autocompletion can provide useful completions when sending messages to the variable, the model must tell it what class is behind a given name. For that purpose, the model can override the guessTypeForName: function. A good example is the implementation in the Workspace class:

guessTypeForName: aString 
	| binding |
	bindings ifNotNil: 
		[ binding := bindings 
			at: aString
			ifAbsent: [  ].
		binding ifNotNil: [ ^ binding class ] ].
	^ super guessTypeForName: aString

As you can see, it accesses the variable bindings and returns the class of the name if it is found. And the result: A picture showing the Autocompletion correctly guessing the class of a variable created in the Workspace

Clone this wiki locally