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.
Constructor and description |
---|
ReflectionCompletor
(Groovysh shell)
|
ReflectionCompletor
() |
Type Params | Return Type | Name and description |
---|---|---|
|
static boolean |
acceptName(String name, String prefix) |
|
int |
complete(List tokens, List candidates) |
|
static List |
getDefaultMethods(Object instance, String prefix) Offering all DefaultGroovyMethods on any object is too verbose, hiding all removes user-friendliness. |
|
static CharSequence |
getFieldnameForAccessor(String accessor, int parameterLength) |
|
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 |
getMetaclassMethods(Object instance, String prefix, boolean includeMetaClassImplMethods) |
|
static Collection |
getPublicFieldsAndMethods(Object instance, String prefix) Build a list of public fields and methods for an object that match a given prefix. |
|
static Object |
removeStandardMethods(Collection candidates) removes candidates that, most of the times, a programmer does not want to see in completion
|
|
static String |
tokenListToEvalString(List groovySourceTokens) |
metaclass_completion_prefix_length
- how long the prefix must be to display candidates from metaclassOffering all DefaultGroovyMethods on any object is too verbose, hiding all removes user-friendliness. So here util methods will be added to candidates if the instance is of a suitable type. This does not need to be strictly complete, only the most useful functions may appear.
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.
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.
Build a list of public fields and methods for an object that match a given prefix.
instance
- the objectprefix
- the prefix that must be matchedremoves candidates that, most of the times, a programmer does not want to see in completion
Copyright © 2003-2020 The Apache Software Foundation. All rights reserved.