public CompletionMatch complete() throws CompletionException {
//
Class<? extends Completer> completerType = parameter.getCompleterType();
Completer completer = null;
if (completerType != EmptyCompleter.class) {
// If the provided completer instance matches the parameter completer type
// then we use it
if (completerType.isInstance(this.completer)) {
completer = this.completer;
} else {
// Otherwise we instantiate it
Constructor<? extends Completer> ctor;
try {
ctor = completerType.getDeclaredConstructor();
}
catch (NoSuchMethodException ignore) {
throw new CompletionException("The completer " + completerType.getName() + " does not provide a no arg constructor");
}
if (Modifier.isPublic(ctor.getModifiers())) {
try {
completer = ctor.newInstance();
}
catch (InstantiationException e) {
throw new CompletionException("The completer " + completerType.getName() + " cannot be abstract");
}
catch (InvocationTargetException e) {
throw new CompletionException(e.getCause());
}
catch (Exception e) {
throw new CompletionException(e);
}
} else {
throw new CompletionException("The completer " + completerType.getName() + " constructor must be public");
}
}
}
//
if (completer != null) {
try {
return new CompletionMatch(delimiter, completer.complete(parameter, prefix));
}
catch (Exception e) {
throw new CompletionException(e);
}
} else {