Skip to content

Commit

Permalink
FORGE-1414: Fixed completion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jan 3, 2014
1 parent 96cb48f commit 8a57289
Showing 1 changed file with 21 additions and 5 deletions.
Expand Up @@ -18,7 +18,9 @@
import org.jboss.aesh.cl.parser.CommandLineCompletionParser;
import org.jboss.aesh.cl.parser.CommandLineParser;
import org.jboss.aesh.cl.parser.CommandPopulator;
import org.jboss.aesh.cl.parser.ParsedCompleteObject;
import org.jboss.aesh.cl.validator.OptionValidatorException;
import org.jboss.aesh.complete.CompleteOperation;
import org.jboss.aesh.console.InvocationProviders;
import org.jboss.aesh.console.command.Command;
import org.jboss.aesh.console.command.CommandResult;
Expand All @@ -44,17 +46,14 @@
@Vetoed
public class AeshUICommand implements UICommand
{

private final Command<CommandInvocation> command;
private final CommandPopulator commandPopulator;
private final CommandLineParser commandLineParser;

@SuppressWarnings("unchecked")
public AeshUICommand(CommandContainer container)
{
this.command = container.getCommand();
this.commandLineParser = container.getParser();
this.commandPopulator = commandLineParser.getCommandPopulator();
}

@Override
Expand Down Expand Up @@ -110,7 +109,24 @@ public ProcessedCommand getCommand()
@Override
public CommandLineCompletionParser getCompletionParser()
{
return commandLineParser.getCompletionParser();
return new CommandLineCompletionParser()
{
@Override
@SuppressWarnings("rawtypes")
public void injectValuesAndComplete(ParsedCompleteObject completeObject, Command originalCommand,
CompleteOperation completeOperation, InvocationProviders invocationProviders)
{
commandLineParser.getCompletionParser().injectValuesAndComplete(completeObject,
AeshUICommand.this.command,
completeOperation, invocationProviders);
}

@Override
public ParsedCompleteObject findCompleteObject(String line, int cursor) throws CommandLineParserException
{
return commandLineParser.getCompletionParser().findCompleteObject(line, cursor);
}
};
}

@Override
Expand All @@ -122,7 +138,7 @@ public CommandPopulator getCommandPopulator()
public void populateObject(Object instance, CommandLine line, InvocationProviders invocationProviders,
boolean validate) throws CommandLineParserException, OptionValidatorException
{
commandPopulator.populateObject(command, line, invocationProviders, validate);
commandLineParser.getCommandPopulator().populateObject(command, line, invocationProviders, validate);
}
};
}
Expand Down

0 comments on commit 8a57289

Please sign in to comment.