src/main/java/seedu/address/ui/autocompleter/Autocompleter.java
private void updateState(String commandBoxText) {
        if (commandBoxText.equals(EMPTY_STRING)) {
            state = AutocompleteState.EMPTY;
            return;
        }

        String[] currentTextArray = parser.parseCommandAndPrefixes(commandBoxText);
        String commandWord = currentTextArray[CommandBoxParser.COMMAND_INDEX];
        String arguments = currentTextArray[CommandBoxParser.ARGUMENT_INDEX];
        currentCommand = AutocompleteCommand.getInstance(commandWord);

        // First word does not match any commands
        if (currentCommand.equals(AutocompleteCommand.NONE)) {
            autocompleteCommandWord(commandBoxText);
            return;
        }

        // Autocompleter is currently cycling through possible commands
        if (isCyclingThroughCommands(commandWord)) {
            return;
        }

        // Current command word has an index parameter in its arguments
        if (AutocompleteCommand.hasIndexParameter(commandWord)
                && (!AutocompleteCommand.hasPrefixParameter(commandWord)
                || needIndex(arguments))) {
            resetCountingAndMaxIndexIfNeeded();
            state = AutocompleteState.INDEX;
            return;
        }

        // Current command word has a prefix parameter in its arguments
        if (AutocompleteCommand.hasPrefixParameter(commandWord)) {
            updateStateForCommandsWithPrefixes(commandBoxText, arguments);
            return;
        } else {
            state = AutocompleteState.COMMAND;
        }

    }
/**
     * Updates the {@code state} and {@code currentCommand} according their current values
     * as well as the current text inside the {@code commandBoxText}
     *
     * @param commandBoxText the current text inside the {@code CommandBox}
     */
Updates the  state and  currentCommand according their current values
as well as the current text inside the  commandBoxText

@param commandBoxText the current text inside the  CommandBox
Updates the state and currentCommand according their current values as well as the current text inside the commandBoxText @param commandBoxText the current text inside the CommandBox
private void updateState(String commandBoxText) {
        if (commandBoxText.equals(EMPTY_STRING)) {
            state = AutocompleteState.EMPTY;
            return;
        }
        String[] currentTextArray = parser.parseCommandAndPrefixes(commandBoxText);
        String commandWord = currentTextArray[CommandBoxParser.COMMAND_INDEX];
        String arguments = currentTextArray[CommandBoxParser.ARGUMENT_INDEX];
        currentCommand = AutocompleteCommand.getInstance(commandWord);
        if (currentCommand.equals(AutocompleteCommand.NONE)) {
            autocompleteCommandWord(commandBoxText);
            return;
        }
        if (isCyclingThroughCommands(commandWord)) {
            return;
        }
        if (AutocompleteCommand.hasIndexParameter(commandWord)
                && (!AutocompleteCommand.hasPrefixParameter(commandWord)
                || needIndex(arguments))) {
            resetCountingAndMaxIndexIfNeeded();
            state = AutocompleteState.INDEX;
            return;
        }
        if (AutocompleteCommand.hasPrefixParameter(commandWord)) {
            updateStateForCommandsWithPrefixes(commandBoxText, arguments);
            return;
        } else {
            state = AutocompleteState.COMMAND;
        }
    }
private void updateState ( String commandBoxText ) { if ( commandBoxText . equals ( EMPTY_STRING ) ) { state = AutocompleteState . EMPTY ; return ; } String [ ] currentTextArray = parser . parseCommandAndPrefixes ( commandBoxText ) ; String commandWord = currentTextArray [ CommandBoxParser . COMMAND_INDEX ] ; String arguments = currentTextArray [ CommandBoxParser . ARGUMENT_INDEX ] ; currentCommand = AutocompleteCommand . getInstance ( commandWord ) ; if ( currentCommand . equals ( AutocompleteCommand . NONE ) ) { autocompleteCommandWord ( commandBoxText ) ; return ; } if ( isCyclingThroughCommands ( commandWord ) ) { return ; } if ( AutocompleteCommand . hasIndexParameter ( commandWord ) && ( ! AutocompleteCommand . hasPrefixParameter ( commandWord ) || needIndex ( arguments ) ) ) { resetCountingAndMaxIndexIfNeeded ( ) ; state = AutocompleteState . INDEX ; return ; } if ( AutocompleteCommand . hasPrefixParameter ( commandWord ) ) { updateStateForCommandsWithPrefixes ( commandBoxText , arguments ) ; return ; } else { state = AutocompleteState . COMMAND ; } }
Updates the {@code state} and {@code currentCommand} according their current values
 as well as the current text inside the {@code commandBoxText}
Updates the { @code state } and { @code currentCommand } according their current values as well as the current text inside the { @code commandBoxText }
// First word does not match any commands // Autocompleter is currently cycling through possible commands // Current command word has an index parameter in its arguments // Current command word has a prefix parameter in its arguments