/** * Return true if the specified character is a whitespace * parameter. Check to ensure that the character is not * escaped and returns true from * {@link #isDelimiterChar}. * * @param buffer The complete command buffer. * @param pos The index of the character in the buffer. * @return True if the character should be a delimiter, false else. */ public boolean isDelimiter(final String buffer, final int pos) { return !isEscaped(buffer, pos) && isDelimiterChar(buffer, pos); }
public int complete(final String buffer, final int cursor, final List<String> candidates) { ArgumentList list = delimit(buffer, cursor); int argpos = list.getArgumentPosition(); int argIndex = list.getCursorArgumentIndex(); if (!verifyCompleter(commandCompleter, args[index])) { return -1; if (!verifyCompleter(optionsCompleter, args[index])) { return -1; while (index < argIndex) { Completer sub = argsCompleters.get(indexArg >= argsCompleters.size() ? argsCompleters.size() - 1 : indexArg); if (!verifyCompleter(sub, args[index])) { return -1; if ((buffer != null) && (cursor != buffer.length()) && isDelimiter(buffer, cursor)) { for (int i = 0; i < candidates.size(); i++) { String val = candidates.get(i); && isDelimiter(val, val.length() - 1)) { val = val.substring(0, val.length() - 1);
this.function = function; commandCompleter = new StringsCompleter(getNames(session, command)); final Map<Integer, Object> values = getCompleterValues(function); argsCompleters = new ArrayList<>(); boolean multi = false; completer = getDefaultCompleter(session, field);
public boolean isEscaped(final String buffer, final int pos) { return pos > 0 && buffer.charAt(pos) == '\\' && !isEscaped(buffer, pos - 1); }
if (function instanceof CommandWithAction) { try { global.put(command, new ArgumentCompleter(session, (CommandWithAction) function, command)); local.put(command, new ArgumentCompleter(session, (CommandWithAction) function, rawCommand)); } catch (Throwable t) { LOGGER.debug("Unable to create completers for command '" + command + "'", t);