changing java files within main/groovy into groovy files.
This is for consistency and for development ease

Note I removed the "assert parent != null",
which seemed to have been unjustified anyway (Code does null checks)
Extract class shared between Main and Groovy
Groovysh shell completion tests
changed a few asserts to explicit null checks and changed visibility of Groovysh.reader to allow easier unit testing
do not show lines of exception trace related to evaluation script.
Those get old very fast, and take away 2 lines of screen for zero value.
verbose or debug settings still display them
robust error handler call
code Style refactorings, mostly allows @CompileStatic and @TypeChecked

This declares types in several places, does some casting too.
Gave unique name to iterators in closures

Could not fix all Type checking and static compile problems,
due to weird hacks around command registry

Not including @CompileStatic and @TypeChecked annotations
because maybe this is to be backported to groovy 1.x, and also
I did not see other code here use them
refactoring: static compile fix: displayBuffer called from within DisplayCommand cannot be private
refactoring: fix static check Runtime Error:
Caught: BUG! exception in phase 'class generation'
On receiver: history.historyList with message: getAt and arguments: id

Not sure what caused this, really
ReflectionCompletor raises Exceptions when evaluation failed

e.g. when completing "println(java."
shorter Error when user users a var he has not defined
unused var
Colors need to be set via fg/bg, else this happens:
an =  Ansi.ansi().a(INTENSITY_BOLD).a(GREEN).a("Hello")
===> GREENHello
display Arrays pretty.

groovy:000> ["foo"].toArray()
Before:  ===> [Ljava.lang.Object;
After:   ===> [foo]

groovy:000> Object.fields
Before:  ===> [Ljava.lang.Object;@68a48abd
After:   ===> [] (class java.lang.reflect.Field)
using io on abnormalShutdown causes java.lang.IllegalStateException: Shutdown in progress
and breaks Terminal on linux

Can be tested by pressinc Control-C
Robustness: All Throwables during completion must be handled, unless in debug mode
refactoring code Style, fixes indentation, "if" with brackets,
unnecessary var, and no unnecessary call to getProperty
better groovish reactions to bad functions.

Before:

groovy:000> show
ERROR org.codehaus.groovy.tools.shell.CommandException:
Command 'show' requires at least one argument
        at java_lang_Runnable$run.call (Unknown Source)
groovy:000> show foo
ERROR org.codehaus.groovy.tools.shell.CommandException:
Unknown function name: foo
        at java_lang_Runnable$run.call (Unknown Source)

After:

groovy:000> show
Command 'show' requires at least one argument of [variables, classes, imports, preferences, all]
groovy:000> show foo
Unknown function name: 'foo'. Valid arguments: [variables, classes, imports, preferences, all]
error message when invoking record with too many arguments
Refactor: CodeStyle ComplexCommandSupport
Also small fix: do_all returned "all" as well, probably not intended

functions field accessed via constructor and getter
executeFunction method called with function name as separate argument
Many Unit tests added
fix ComplexCommandSupport:
catch clause catches wrong Exception
Unit tested