Skip to content

Groovy language REPL

mattirn edited this page May 6, 2021 · 4 revisions

JLine version > 3.15.0

Groovy language REPL offers 1) tab completions for identifiers, variables, packages, methods and meta methods, 2) auto suggestion: display method signatures and syntax errors on status bar and highlight errors on command line.

Screenshot from 2020-07-11 19-40-24

Screenshot from 2020-07-11 19-42-05

Configuration Variables

GROOVY_OPTIONS

A map that contains Groovy configuration options:

option key value type description default value
allClassesCompletion Boolean If true then completions are offered also for protected and private classes. false
allConstructorsCompletion Boolean If true then completions are offered also for protected and private constructors. false
allFieldsCompletion Boolean If true then completions are offered also for protected and private fields false
allMethodsCompletion Boolean If true then completions are offered also for protected and private methods false
canonicalNames Boolean If true canonical name types are used in method signatures false
GROOVY_COLORS String variable that defines highlighting of error messages on status bar ti=1;34:me=31
identifiersCompletion Boolean If true then completions are offered also for Groovy identifiers false
metaMethodsCompletion Boolean If true then completions are offered also Groovy meta methods false
nanorcSyntax String nanorc syntaxfile. Used for methods signature highlighting classpath:/org/jline/groovy/java.nanorc
nanorcValue String nanorc syntaxfile. Used by groovy commands grab and inspect classpath:/org/jline/groovy/gron.nanorc
noSyntaxCheck Boolean If true then statement syntax will not be checked while writing statement false
restrictedCompletion Boolean If true then no completions are offered for chained (meta) methods false
syntheticMethodsCompletion Boolean If true then completions are offered also for synthetic methods false

Object Cloner

Method completion data is retrieved using reflection. Class of the completable object and syntax errors are obtained by evaluating part of the entered command line. Evaluation is done on Inspector instance which is created in completion()/scriptDescription() method. In the constructor of the Inspector the console variables are cloned using Cloner implementation in order not to modify mutable variables. Cloned variables can be cached by Cloner.

Warn: GroovyEngine default Cloner implementation do only a shallow clone of the object in a case when object implements clone() interface otherwise no cloning at all will be done. Method tab completion and syntax checking can change the state of the console variable.

GroovyEngine default Cloner implementation can be changed by using the method setObjectCloner(cloner).

The decision for which objects can be performed method tab-completion is done by Cloner. If Cloner assigns null value for cloned object no method completion will be performed. In case when Cloner assigns null value for all cloned console variables then method completion can be performed only for objects created inside a code block.

Note: Setting configuration options noSyntaxCheck = true and restrictedCompletion = true no statement evaluations will be performed before the final statement execution. Nevertheless object cloner will clone console variables and it can be used to make decision for which objects are offered completions.

Clone this wiki locally