private List<Completion> getCandidates(String buffer) {
    List<Completion> candidates = new ArrayList<>();
    // always pass the buffer length as the cursor position for simplicity purpose
    super.completeAdvanced(buffer, buffer.length(), candidates);
    // trimming the candidates
    candidates.replaceAll(completion -> new Completion(completion.getValue().trim()));
    return candidates;
  }
@param buffer use the buffer to find the completion candidates

       Note the cursor may not be the size the buffer
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java