1 /*
   2  * Copyright (c) 2002-2012, the original author or authors.
   3  *
   4  * This software is distributable under the BSD license. See the terms of the
   5  * BSD license in the documentation provided with this software.
   6  *
   7  * http://www.opensource.org/licenses/bsd-license.php
   8  */
   9 package jdk.internal.jline.console.completer;
  10 
  11 import java.util.List;
  12 
  13 /**
  14  * A completer is the mechanism by which tab-completion candidates will be resolved.
  15  *
  16  * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
  17  * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
  18  * @since 2.3
  19  */
  20 public interface Completer
  21 {
  22     //
  23     // FIXME: Check if we can use CharSequece for buffer?
  24     //
  25 
  26     /**
  27      * Populates <i>candidates</i> with a list of possible completions for the <i>buffer</i>.
  28      *
  29      * The <i>candidates</i> list will not be sorted before being displayed to the user: thus, the
  30      * complete method should sort the {@link List} before returning.
  31      *
  32      * @param buffer        The buffer
  33      * @param cursor        The current position of the cursor in the <i>buffer</i>
  34      * @param candidates    The {@link List} of candidates to populate
  35      * @return              The index of the <i>buffer</i> for which the completion will be relative
  36      */
  37     int complete(String buffer, int cursor, List<CharSequence> candidates);
  38 }