Skip to content

Groovy language REPL

mattirn edited this page Jul 14, 2020 · 4 revisions

JLine version > 3.15.0

Groovy language REPL offers 1) tab completions for variables, packages and 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:

  • canonicalNames boolean. If true canonical name types are used in method signatures.
  • GROOVY_COLORS string variable that defines highlighting of error messages on status bar. Default value ti=1;34:me=31.
  • nanorcSyntax nanorc syntaxfile. Used for methods signature highlighting. Default classpath:/org/jline/groovy/java.nanorc
  • nanorcValue nanorc syntaxfile. Used by groovy commands grab and inspect. Default classpath:/org/jline/groovy/gron.nanorc

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.

Clone this wiki locally