Package jline

Examples of jline.ArgumentCompletor$ArgumentList


      }
    };

    // The ArgumentCompletor allows us to match multiple tokens
    // in the same line.
    final ArgumentCompletor ac = new ArgumentCompletor(sc, delim);
    // By default ArgumentCompletor is in "strict" mode meaning
    // a token is only auto-completed if all prior tokens
    // match. We don't want that since there are valid tokens
    // that are not in our wordlist (eg. table and column names)
    ac.setStrict(false);

    // ArgumentCompletor always adds a space after a matched token.
    // This is undesirable for function names because a space after
    // the opening parenthesis is unnecessary (and uncommon) in Hive.
    // We stack a custom Completor on top of our ArgumentCompletor
    // to reverse this.
    Completor completor = new Completor () {
      public int complete (String buffer, int offset, List completions) {
        List<String> comp = (List<String>) completions;
        int ret = ac.complete(buffer, offset, completions);
        // ConsoleReader will do the substitution if and only if there
        // is exactly one valid completion, so we ignore other cases.
        if (completions.size() == 1) {
          if (comp.get(0).endsWith("( ")) {
            comp.set(0, comp.get(0).trim());
View Full Code Here


      }
    };

    // The ArgumentCompletor allows us to match multiple tokens
    // in the same line.
    final ArgumentCompletor ac = new ArgumentCompletor(sc, delim);
    // By default ArgumentCompletor is in "strict" mode meaning
    // a token is only auto-completed if all prior tokens
    // match. We don't want that since there are valid tokens
    // that are not in our wordlist (eg. table and column names)
    ac.setStrict(false);

    // ArgumentCompletor always adds a space after a matched token.
    // This is undesirable for function names because a space after
    // the opening parenthesis is unnecessary (and uncommon) in Hive.
    // We stack a custom Completor on top of our ArgumentCompletor
    // to reverse this.
    Completor completor = new Completor () {
      public int complete (String buffer, int offset, List completions) {
        List<String> comp = (List<String>) completions;
        int ret = ac.complete(buffer, offset, completions);
        // ConsoleReader will do the substitution if and only if there
        // is exactly one valid completion, so we ignore other cases.
        if (completions.size() == 1) {
          if (comp.get(0).endsWith("( ")) {
            comp.set(0, comp.get(0).trim());
          }
        }
        return ret;
      }
    };

    HiveConf.ConfVars[] confs = HiveConf.ConfVars.values();
    String[] vars = new String[confs.length];
    for (int i = 0; i < vars.length; i++) {
      vars[i] = confs[i].varname;
    }
    SimpleCompletor conf = new SimpleCompletor(vars);
    conf.setDelimiter(".");

    SimpleCompletor set = new SimpleCompletor("set") {
      @Override
      public int complete(String buffer, int cursor, List clist) {
        return buffer != null && buffer.equals("set") ? super.complete(buffer, cursor, clist) : -1;
      }
    };
    ArgumentCompletor propCompletor = new ArgumentCompletor(new Completor[]{set, conf}) {
      @Override
      @SuppressWarnings("unchecked")
      public int complete(String buffer, int offset, List completions) {
        int ret = super.complete(buffer, offset, completions);
        if (completions.size() == 1) {
View Full Code Here

    final String extraNameCharacters =
        getDatabaseMetaData() == null || getDatabaseMetaData().getExtraNameCharacters() == null ? ""
            : getDatabaseMetaData().getExtraNameCharacters();

    // setup the completor for the database
    sqlCompletor = new ArgumentCompletor(
        new SQLCompletor(beeLine, skipmeta),
        new ArgumentCompletor.AbstractArgumentDelimiter() {
          // delimiters for SQL statements are any
          // non-letter-or-number characters, except
          // underscore and characters that are specified
View Full Code Here

        }
        commandNames.add("exit");
        commandNames.add("quit");
       
        // first part is the command, then all arguments will get children tab completion
        reader.addCompletor(new ArgumentCompletor( new Completor[] {
                new SimpleCompletor(commandNames.toArray(new String[] {} )),
                new JcrChildrenCompletor()
        }));
       
        while (!exit) {
View Full Code Here

    }

    public static Completor extractCompletor(Map<String, CommandExecutable> cmdTable) {
        SimpleCompletor cmdCompletor = new SimpleCompletor(getAllCommands(cmdTable));
        SimpleCompletor argCompletor = new SimpleCompletor(getAllArguments(cmdTable));
        return new ArgumentCompletor(new Completor [] { cmdCompletor, argCompletor, new NullCompletor() });
    }
View Full Code Here

      }
    };

    // The ArgumentCompletor allows us to match multiple tokens
    // in the same line.
    final ArgumentCompletor ac = new ArgumentCompletor(sc, delim);
    // By default ArgumentCompletor is in "strict" mode meaning
    // a token is only auto-completed if all prior tokens
    // match. We don't want that since there are valid tokens
    // that are not in our wordlist (eg. table and column names)
    ac.setStrict(false);

    // ArgumentCompletor always adds a space after a matched token.
    // This is undesirable for function names because a space after
    // the opening parenthesis is unnecessary (and uncommon) in Hive.
    // We stack a custom Completor on top of our ArgumentCompletor
    // to reverse this.
    Completor completor = new Completor () {
      public int complete (String buffer, int offset, List completions) {
        List<String> comp = (List<String>) completions;
        int ret = ac.complete(buffer, offset, completions);
        // ConsoleReader will do the substitution if and only if there
        // is exactly one valid completion, so we ignore other cases.
        if (completions.size() == 1) {
          if (comp.get(0).endsWith("( ")) {
            comp.set(0, comp.get(0).trim());
View Full Code Here

            // Setup the command line completers for listed actions for the user before login
            // completes initial commands available
            Completor commandCompletor = new SimpleCompletor(commands.keySet().toArray(new String[commands.size()]));
            // completes help arguments (basically, help <command>)
            Completor helpCompletor = new ArgumentCompletor(new Completor[] { new SimpleCompletor("help"),
                new SimpleCompletor(commands.keySet().toArray(new String[commands.size()])) });

            this.codeCompletion = ScriptEngineFactory.getCodeCompletion(getLanguage());
            if (codeCompletion == null) {
                //the language module for this language doesn't support code completion
View Full Code Here

    public void setCompletors(List<Completor> completors) {
        this.completors = completors;
    }

    public void afterPropertiesSet() throws Exception {
        this.consoleReader.addCompletor(new ArgumentCompletor(completors));
    }
View Full Code Here

        consoleReader = new jline.ConsoleReader();
        consoleReader.addCompletor(
                new SimpleCompletor(COMMANDS.keySet().toArray(new String[COMMANDS.size()])));
        consoleReader.addCompletor(
                new ArgumentCompletor(
                        new Completor[]{
                                new SimpleCompletor("help"),
                                new SimpleCompletor(COMMANDS.keySet().toArray(new String[COMMANDS.size()]))}));

        consoleReader.setUsePagination(true);
View Full Code Here

      }
    };

    // The ArgumentCompletor allows us to match multiple tokens
    // in the same line.
    final ArgumentCompletor ac = new ArgumentCompletor(sc, delim);
    // By default ArgumentCompletor is in "strict" mode meaning
    // a token is only auto-completed if all prior tokens
    // match. We don't want that since there are valid tokens
    // that are not in our wordlist (eg. table and column names)
    ac.setStrict(false);

    // ArgumentCompletor always adds a space after a matched token.
    // This is undesirable for function names because a space after
    // the opening parenthesis is unnecessary (and uncommon) in Hive.
    // We stack a custom Completor on top of our ArgumentCompletor
    // to reverse this.
    Completor completor = new Completor () {
      public int complete (String buffer, int offset, List completions) {
        List<String> comp = (List<String>) completions;
        int ret = ac.complete(buffer, offset, completions);
        // ConsoleReader will do the substitution if and only if there
        // is exactly one valid completion, so we ignore other cases.
        if (completions.size() == 1) {
          if (comp.get(0).endsWith("( ")) {
            comp.set(0, comp.get(0).trim());
          }
        }
        return ret;
      }
    };

    HiveConf.ConfVars[] confs = HiveConf.ConfVars.values();
    String[] vars = new String[confs.length];
    for (int i = 0; i < vars.length; i++) {
      vars[i] = confs[i].varname;
    }
    SimpleCompletor conf = new SimpleCompletor(vars);
    conf.setDelimiter(".");

    SimpleCompletor set = new SimpleCompletor("set") {
      @Override
      public int complete(String buffer, int cursor, List clist) {
        return buffer != null && buffer.equals("set") ? super.complete(buffer, cursor, clist) : -1;
      }
    };
    ArgumentCompletor propCompletor = new ArgumentCompletor(new Completor[]{set, conf}) {
      @Override
      @SuppressWarnings("unchecked")
      public int complete(String buffer, int offset, List completions) {
        int ret = super.complete(buffer, offset, completions);
        if (completions.size() == 1) {
View Full Code Here

TOP

Related Classes of jline.ArgumentCompletor$ArgumentList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.