-
Notifications
You must be signed in to change notification settings - Fork 9
Code Completion and Content Assist
Content Assist is a general concept encompassing:
- Code completion,
- Text hover, and
- Contextual information.
All of these features are supported by SchemeScript.
At startup time, SchemeScript populates a dictionary (symbol table) with all
the top-level definitions found in all Scheme source files
found in the current workspace (files with the extension .scm
).
This dictionary contains information on the
source location of the various definitions, a description of the
definition (is it a variable? a function? syntax? etc.).
Also, each time a file is saved, the dictionary is updated to reflect the changes.
The set of top-level forms that are recognized by the editor for content assist purposes can be adapted to the user's needs. By default, all Scheme forms are recognized, as well as some Kawa extensions, like module forms, class definitions, record (SRFI-9) definitions, etc.
To add (or remove) forms supported, the file conf/forms.scm
, found in
the plug-in directory, must be edited.
To add a supported form, simply add a call to the SchemeScript function define-form-processor
.
The first argument must be a symbol (the name of the supported form), while the second
argument is a lambda
-expression called to process top-level forms
beginning with the specified symbol. This lambda
-expression must
accept 4 parameters (the dictionary, the matched form, the Eclipse resource
containing the form, and the line number of the form), and is responsible for
populating the dictionary by calling the add-entry!
procedure
(defined at the beginning of conf/forms.scm
).
Here is an example for the define-syntax
special form:
(define-form-processor 'define-syntax (lambda (dictionary form resource line-number) (when (and (pair? (cdr form)) (symbol? (cadr form))) (let* ((name (cadr form)) (description (format #f "~a - user syntax" name))) (add-entry! dictionary name description 'syntax resource line-number)))))