Skip to content

Commit

Permalink
Revert "Modify and use parse index func for edit"
Browse files Browse the repository at this point in the history
This reverts commit b125c9a.
  • Loading branch information
ravishwetha committed Nov 6, 2016
1 parent b125c9a commit ca5118a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/seedu/gtd/logic/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ private Command prepareEdit(String args) {
return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE));
}

Optional<Integer> index = parseIndex(args, EDIT_DATA_ARGS_FORMAT);

Optional<Integer> index = Optional.of(Integer.parseInt(matcher.group("targetIndex")));
final String[] splitNewDetails = matcher.group("newDetails").split("\\s+");
ArrayList<String> combinedDetails = combineSameDetails(splitNewDetails);

Hashtable<String, String> newDetailsSet = new Hashtable<String, String>();

for (String detail : combinedDetails) {
String detailType = extractDetailType(detail);
String preparedNewDetail = prepareNewDetail(detailType, detail);
Expand All @@ -228,7 +228,7 @@ private Command prepareEdit(String args) {
}

return new EditCommand(
index.get() - 1,
index.get()-1,
newDetailsSet
);
}
Expand Down Expand Up @@ -333,7 +333,7 @@ else if(priorityMatcher.matches()) {
*/
private Command prepareDelete(String args) {

Optional<Integer> index = parseIndex(args, TASK_INDEX_ARGS_FORMAT);
Optional<Integer> index = parseIndex(args);
if(!index.isPresent()){
return new IncorrectCommand(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE));
Expand All @@ -344,7 +344,7 @@ private Command prepareDelete(String args) {

private Command prepareDone(String args) {

Optional<Integer> index = parseIndex(args, TASK_INDEX_ARGS_FORMAT);
Optional<Integer> index = parseIndex(args);
System.out.println("index at preparedone:" + index.get());
if(!index.isPresent()){
return new IncorrectCommand(
Expand All @@ -361,7 +361,7 @@ private Command prepareDone(String args) {
* @return the prepared command
*/
private Command prepareSelect(String args) {
Optional<Integer> index = parseIndex(args, TASK_INDEX_ARGS_FORMAT);
Optional<Integer> index = parseIndex(args);
if(!index.isPresent()){
return new IncorrectCommand(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SelectCommand.MESSAGE_USAGE));
Expand All @@ -374,8 +374,8 @@ private Command prepareSelect(String args) {
* Returns the specified index in the {@code command} IF a positive unsigned integer is given as the index.
* Returns an {@code Optional.empty()} otherwise.
*/
private Optional<Integer> parseIndex(String command, final Pattern matcherFormat) {
final Matcher matcher = matcherFormat.matcher(command.trim());
private Optional<Integer> parseIndex(String command) {
final Matcher matcher = TASK_INDEX_ARGS_FORMAT.matcher(command.trim());
if (!matcher.matches()) {
return Optional.empty();
}
Expand Down

0 comments on commit ca5118a

Please sign in to comment.