/** * Perform a completion operation across all aggregated completers. * * @see Completer#complete(String, int, java.util.List) * @return the highest completion return value from all completers */ public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) { // buffer could be null checkNotNull(candidates); List<Completion> completions = new ArrayList<Completion>(completers.size()); // Run each completer, saving its completion results int max = -1; for (Completer completer : completers) { Completion completion = new Completion(candidates); completion.complete(completer, buffer, cursor); // Compute the max cursor position max = Math.max(max, completion.cursor); completions.add(completion); } // Append candidates from completions which have the same cursor position as max for (Completion completion : completions) { if (completion.cursor == max) { candidates.addAll(completion.candidates); } } return max; }
/** * Perform a completion operation across all aggregated completers. * * @see Completer#complete(String, int, java.util.List) * @return the highest completion return value from all completers */ public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) { // buffer could be null checkNotNull(candidates); List<Completion> completions = new ArrayList<Completion>(completers.size()); // Run each completer, saving its completion results int max = -1; for (Completer completer : completers) { Completion completion = new Completion(candidates); completion.complete(completer, buffer, cursor); // Compute the max cursor position max = Math.max(max, completion.cursor); completions.add(completion); } // Append candidates from completions which have the same cursor position as max for (Completion completion : completions) { if (completion.cursor == max) { candidates.addAll(completion.candidates); } } return max; }