Skip to content

Commit

Permalink
Better Code legibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 22, 2013
1 parent ac8bf25 commit c1691b2
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,30 @@ public List<String> getCompletionOptions(String typed, String line)
{
List<String> result = new ArrayList<String>();
boolean unvalued = Strings.isNullOrEmpty(typed);
int idx = steps.size() - 1;
STEP: for (; idx > 0; idx--)
int size = steps.size();

int idx;

STEP_LOOP: for (idx = size - 1; idx > 0; idx--)
{
for (String option : steps.get(idx).inputs.keySet())
{
if (line.contains("--" + option))
{
break STEP;
break STEP_LOOP;
}
}
}
Set<String> candidates = new HashSet<String>();
for (int i = idx; i < steps.size(); i++)
for (int i = idx; i < size; i++)
{
candidates.addAll(steps.get(i).inputs.keySet());
}
for (String option : candidates)
{
if (unvalued || option.startsWith(typed))
{
String dashedOption = "--" + option;
result.add(dashedOption);
result.add("--" + option);
}
}
removeExistingOptions(line, result);
Expand Down

0 comments on commit c1691b2

Please sign in to comment.