ReflectionCompleter (Groovy 4.0.15)

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

## [Groovy] Class ReflectionCompleter

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

-     class ReflectionCompleter
      extends Object

  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
    --- | ---
    `Groovysh` | `shell`

  - ### Constructor Summary

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

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static boolean` | `acceptName(String name, String prefix)`
    `` | `int` | `complete(List<Token> tokens, List<CharSequence> candidates)`
    `` | `static List<String>` | `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<Token> groovySourceTokens)` Takes the last ?
    `` | `static List<Token>` | `getInvokerTokens(List<Token> tokens)` 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<String>` | `getMetaclassMethods(Object instance, String prefix, boolean includeMetaClassImplMethods)`
    `` | `static Collection<ReflectionCompletionCandidate>` | `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<ReflectionCompletionCandidate> candidates)` removes candidates that, most of the times, a programmer does not want to see in completion
    `` | `static String` | `tokenListToEvalString(List<Token> groovySourceTokens)`

  - ### Inherited Methods Summary

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

- - ### Property Detail

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

  - ### Method Detail

    - #### static boolean acceptName(String name, String prefix)

    - #### int complete(List<Token> tokens, List<CharSequence> candidates)

    - #### static List<String> 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<Token> 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<Token> getInvokerTokens(List<Token> tokens)

      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. @return

      Parameters:
        tokens

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

    - #### static Collection<ReflectionCompletionCandidate> 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<ReflectionCompletionCandidate> candidates)

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

      Parameters:
        candidates

    - #### static String tokenListToEvalString(List<Token> groovySourceTokens)