Groovy 2.2.0

org.codehaus.groovy.tools.shell.completion
[Groovy] Class ReflectionCompletor

java.lang.Object
  org.codehaus.groovy.tools.shell.completion.ReflectionCompletor

class ReflectionCompletor

Completes fields and methods of Classes or instances. Does not quite respect the contract of IdentifierCompletor, as last Token may be a dot or not, thus also returns as int the cursor position.


Property Summary
Groovysh shell

 
Constructor Summary
ReflectionCompletor(Groovysh shell)

 
Method Summary
static boolean acceptName(String name, String prefix)

int complete(List tokens, List candidates)

Object getInvokerClassOrInstance(List groovySourceTokens)

Takes the last ?

static List getInvokerTokens(List groovySourceTokens)

return the last tokens of a list that form an expression to be completed after the next dot, or null if expression cannot be detected.

static Collection getPublicFieldsAndMethods(Object instance, String prefix)

Build a list of public fields and methods for an object that match a given prefix.

static String tokenListToEvalString(List groovySourceTokens)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Property Detail

shell

Groovysh shell


 
Constructor Detail

ReflectionCompletor

ReflectionCompletor(Groovysh shell)


 
Method Detail

acceptName

static boolean acceptName(String name, String prefix)


complete

int complete(List tokens, List candidates)


getInvokerClassOrInstance

Object getInvokerClassOrInstance(List groovySourceTokens)
Takes the last ? tokens of the list that form a simple expression, evaluates it and returns a result. "Simple" means evaluation is known to be side-effect free.


getInvokerTokens

static List getInvokerTokens(List groovySourceTokens)
return the last tokens of a list that form an expression to be completed after the next dot, or null if expression cannot be detected. This discards Expressions that could easily have side effects or be long in evaluation. However it assumes that operators can be evaluated without side-effect or long running operation. Users who use operators for which this does not hold should not use tab completion.
Parameters:
groovySourceTokens
Returns:


getPublicFieldsAndMethods

static Collection getPublicFieldsAndMethods(Object instance, String prefix)
Build a list of public fields and methods for an object that match a given prefix.
Parameters:
instance - the object
prefix - the prefix that must be matched
Returns:
the list of public methods and fields that begin with the prefix


tokenListToEvalString

static String tokenListToEvalString(List groovySourceTokens)


 

Copyright © 2003-2013 The Codehaus. All rights reserved.