-
Notifications
You must be signed in to change notification settings - Fork 3
API reference
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"
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: