<< March 6, 2007 | Home | March 8, 2007 >>

GroovyEclipse code completion

I finally have stable code completion on typed data. And finally there is something to see! It's been working for a while, but getting it stable required many more test cases for interesting fringe cases. Then again, it is not just completion, but a framework to be able to add completion into text fields, consoles, and whatever else is required. And also extension points to add custom completions for features only found in Groovy, such as categories and the default Groovy methods. The same extension points can be used to add domain specific completions such as for methods injected into Grails domain classes.

The best part however is that all extension points participate in far more than code completion. Once the type inference code is completed, APIs to retrieve type data will be usable for all sorts of analysis. It will be interesting to see what people come up with.

On to the completions. This first one shows an instance variable being completed.

Completion

Here is a typed local variable.

Completion

Here is what happens when completion is used with duck types. Good old java.lang.Object completions. Once type inference is in place, this will be a far more useful completion list.

Completion

Here is a 'isActive' method being completed as a Groovy property:

Completion

And finally, a more complex completion.

Completion

A type evaluator is used to evaluate completion expressions, so eventually the evaluator will be able to evaluate complex expressions such as [1, 2, 3].collect { it.toString() } . jo_ where the underscore is the completion location. Yes, it needs to add type to the contents of the list. No it won't be happening soon :)

I am very glad I decided to avoid any hacks which would have saved time at the expense of everything going forward. A little parser extracts completion expressions. There is little it can't extract now. The previous hacky completion implementation simply looked for '.' but of course balked at any expression that was even slightly complex. And the type evaluator, while used in completion, will be extended as it is used extensively in evaluating types in the inference engine.

And onto type inference and error recovering parsers I go ...