Package: org.apache.groovy.groovysh.completion.antlr4

## [Groovy] Class ReflectionCompleter

- org.apache.groovy.groovysh.completion.antlr4.ReflectionCompleter

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

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `private Groovysh` | `shell`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ReflectionCompleter (Groovysh shell)` Parameters: shell
    `ReflectionCompleter ()`

  - ### Methods Summary

    Methods
    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, boolean all)` 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 Parameters: candidates
    `` | `static String` | `tokenListToEvalString(List groovySourceTokens)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Property Detail

    - #### private final Groovysh shell

  - ### Constructor Detail

    - #### ReflectionCompleter(Groovysh shell)

      Parameters:
        shell
        `metaclass_completion_prefix_length` - how long the prefix must be to display candidates from metaclass

    - #### ReflectionCompleter()

  - ### Method Detail

    - #### 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. 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.

    - #### static CharSequence getFieldnameForAccessor(String accessor, int parameterLength)

    - #### 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.

    - #### 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.

      Returns:
        Parameters:
          groovySourceTokens

    - #### static Collection getMetaclassMethods(Object instance, String prefix, boolean includeMetaClassImplMethods)

    - #### static Collection getPublicFieldsAndMethods(Object instance, String prefix, boolean all)

      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

    - #### static Object removeStandardMethods(Collection candidates)

      removes candidates that, most of the times, a programmer does not want to see in completion

      Parameters:
        candidates

    - #### static String tokenListToEvalString(List groovySourceTokens)