3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Removed ParametricCallable's getSuggestions() which isn't quite working.

Dieser Commit ist enthalten in:
sk89q 2014-06-28 17:32:48 -07:00
Ursprung c7988c7ad9
Commit e261e720b6

Datei anzeigen

@ -253,92 +253,7 @@ class ParametricCallable implements CommandCallable {
@Override
public List<String> getSuggestions(String stringArguments, CommandLocals locals) throws CommandException {
String[] split = CommandContext.split(stringArguments);
CommandContext context = new CommandContext(split, getValueFlags());
ContextArgumentStack scoped = new ContextArgumentStack(context);
SuggestionContext suggestable = context.getSuggestionContext();
// For /command -f |
// For /command -f flag|
if (suggestable.forFlag()) {
for (ParameterData parameter : parameters) {
if (parameter.getFlag() == suggestable.getFlag()) {
String prefix = context.getFlag(parameter.getFlag());
if (prefix == null) {
prefix = "";
}
return parameter.getBinding().getSuggestions(parameter, prefix);
}
}
// This should not happen
return new ArrayList<String>();
}
int consumerIndex = 0;
ParameterData lastConsumer = null;
String lastConsumed = null;
for (ParameterData parameter : parameters) {
if (parameter.getFlag() != null) {
continue; // We already handled flags
}
try {
scoped.mark();
parameter.getBinding().bind(parameter, scoped, true);
if (scoped.wasConsumed()) {
lastConsumer = parameter;
lastConsumed = scoped.getConsumed();
consumerIndex++;
}
} catch (MissingParameterException e) {
// For /command value1 |value2
// For /command |value1 value2
if (suggestable.forHangingValue()) {
return parameter.getBinding().getSuggestions(parameter, "");
} else {
// For /command value1| value2
if (lastConsumer != null) {
return lastConsumer.getBinding()
.getSuggestions(lastConsumer, lastConsumed);
// For /command| value1 value2
// This should never occur
} else {
throw new RuntimeException("Invalid suggestion context");
}
}
} catch (ParameterException e) {
if (suggestable.forHangingValue()) {
String name = getDescription().getParameters()
.get(consumerIndex).getName();
throw new InvalidUsageException("For parameter '" + name + "': "
+ e.getMessage(), getDescription());
} else {
return parameter.getBinding().getSuggestions(parameter, "");
}
}
}
// For /command value1 value2 |
if (suggestable.forHangingValue()) {
// There's nothing that we can suggest because there's no more parameters
// to add on, and we can't change the previous parameter
return new ArrayList<String>();
} else {
// For /command value1 value2|
if (lastConsumer != null) {
return lastConsumer.getBinding()
.getSuggestions(lastConsumer, lastConsumed);
// This should never occur
} else {
throw new RuntimeException("Invalid suggestion context");
}
}
return Collections.emptyList();
}
@Override