Clean up ParametricCallable.

This commit is contained in:
sk89q 2014-07-01 13:50:49 -07:00
parent 1b0a6bfcd8
commit 7ba002ac8d

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.util.command.parametric;
import com.google.common.base.Joiner;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
@ -109,8 +108,7 @@ class ParametricCallable implements CommandCallable {
}
// Special annotation bindings
} else if (parameter.getBinding() == null) {
parameter.setBinding(builder.getBindings().get(
annotation.annotationType()));
parameter.setBinding(builder.getBindings().get(annotation.annotationType()));
parameter.setClassifier(annotation);
}
}
@ -188,7 +186,6 @@ class ParametricCallable implements CommandCallable {
// Provide help if -? is specified
if (context.hasFlag('?')) {
String title = Joiner.on(" ").join(parentCommands);
throw new InvalidUsageException(null, this, true);
}
@ -314,8 +311,7 @@ class ParametricCallable implements CommandCallable {
CommandContext context = existing.getContext();
if (parameter.isValueFlag()) {
return new StringArgumentStack(
context, context.getFlag(parameter.getFlag()), false);
return new StringArgumentStack(context, context.getFlag(parameter.getFlag()), false);
} else {
String v = context.hasFlag(parameter.getFlag()) ? "true" : "false";
return new StringArgumentStack(context, v, true);
@ -370,17 +366,14 @@ class ParametricCallable implements CommandCallable {
* @throws ParameterException on an error
* @throws CommandException on an error
*/
private Object getDefaultValue(int i, ContextArgumentStack scoped)
throws ParameterException, CommandException, InvocationTargetException {
private Object getDefaultValue(int i, ContextArgumentStack scoped) throws ParameterException, CommandException, InvocationTargetException {
CommandContext context = scoped.getContext();
ParameterData parameter = parameters[i];
String[] defaultValue = parameter.getDefaultValue();
if (defaultValue != null) {
try {
return parameter.getBinding().bind(
parameter, new StringArgumentStack(
context, defaultValue, false), false);
return parameter.getBinding().bind(parameter, new StringArgumentStack(context, defaultValue, false), false);
} catch (MissingParameterException e) {
throw new ParametricException(
"The default value of the parameter using the binding " +
@ -399,8 +392,7 @@ class ParametricCallable implements CommandCallable {
* @param scoped the argument scope
* @throws UnconsumedParameterException thrown if parameters were not consumed
*/
private void checkUnconsumed(ContextArgumentStack scoped)
throws UnconsumedParameterException {
private void checkUnconsumed(ContextArgumentStack scoped) throws UnconsumedParameterException {
CommandContext context = scoped.getContext();
String unconsumed;
String unconsumedFlags = getUnusedFlags(context);