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;