Package jline

Examples of jline.Completor


    // 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.
View Full Code Here


                private jline.ConsoleReader console = jlineConsole;
                private CommandHistory history = new HistoryImpl();

                @Override
                public void addCompleter(final CommandLineCompleter completer) {
                    console.addCompletor(new Completor(){
                        @SuppressWarnings({ "rawtypes", "unchecked" })
                        @Override
                        public int complete(String buffer, int cursor, List candidates) {
                            return completer.complete(cmdCtx, buffer, cursor, candidates);
                        }});
View Full Code Here

                private jline.ConsoleReader console = jlineConsole;
                private CommandHistory history = new HistoryImpl();

                @Override
                public void addCompleter(final CommandLineCompleter completer) {
                    console.addCompletor(new Completor(){
                        @SuppressWarnings({ "rawtypes", "unchecked" })
                        @Override
                        public int complete(String buffer, int cursor, List candidates) {
                            return completer.complete(cmdCtx, buffer, cursor, candidates);
                        }});
View Full Code Here

    // 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.
View Full Code Here

    // 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.
View Full Code Here

            // Initialize JLine console elements.
            consoleReader = new jline.ConsoleReader();

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

            lastArg = list.getArguments()[argIndex-1];
            if (lastArg != null) lastArg = lastArg.trim();
        }
        allArgs = Arrays.asList(list.getArguments());
       
        final Completor comp;
       
        Completor[] completors = getCompletors(buffer);

        // if we are beyond the end of the completors, just use the last one
        if (argIndex >= completors.length) {
            comp = completors[completors.length - 1];
        } else {
            comp = completors[argIndex];
        }

        // ensure that all the previous completors are successful before
        // allowing this completor to pass (only if strict is true).
        for (int i = 0; getStrict() && (i < argIndex); i++) {
            Completor sub =
                completors[(i >= completors.length) ? (completors.length - 1) : i];
            String[] args = list.getArguments();
            String arg = ((args == null) || (i >= args.length)) ? "" : args[i];

            List subCandidates = new LinkedList();

            if (sub.complete(arg, arg.length(), subCandidates) == -1) {
                return -1;
            }

            if (subCandidates.size() == 0) {
                return -1;
View Full Code Here

            lastArg = list.getArguments()[argIndex-1];
            if (lastArg != null) lastArg = lastArg.trim();
        }
        allArgs = Arrays.asList(list.getArguments());
       
        final Completor comp;
       
        Completor[] completors = getCompletors(buffer);

        // if we are beyond the end of the completors, just use the last one
        if (argIndex >= completors.length) {
            comp = completors[completors.length - 1];
        } else {
            comp = completors[argIndex];
        }

        // ensure that all the previous completors are successful before
        // allowing this completor to pass (only if strict is true).
        for (int i = 0; getStrict() && (i < argIndex); i++) {
            Completor sub =
                completors[(i >= completors.length) ? (completors.length - 1) : i];
            String[] args = list.getArguments();
            String arg = ((args == null) || (i >= args.length)) ? "" : args[i];

            List subCandidates = new LinkedList();

            if (sub.complete(arg, arg.length(), subCandidates) == -1) {
                return -1;
            }

            if (subCandidates.size() == 0) {
                return -1;
View Full Code Here

    // 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.
View Full Code Here

    // 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.
View Full Code Here

TOP

Related Classes of jline.Completor

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.