comparator.compare(completions.get(pos), text)==0) { retVal.add(completions.get(pos)); pos--;
comparator.compare(choices.get(pos), text)==0) { retVal.add(choices.get(pos)); pos--;
comparator.compare(completions.get(start-1), text)==0) { start--;
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") protected List<Completion> getCompletionsImpl(JTextComponent comp) { completions.clear(); CodeBlock ast = createAst(comp); int dot = comp.getCaretPosition(); recursivelyAddLocalVars(completions, ast, dot); Collections.sort(completions); // Cut down the list to just those matching what we've typed. String text = getAlreadyEnteredText(comp); int start = Collections.binarySearch(completions, text, comparator); if (start<0) { start = -(start+1); } else { // There might be multiple entries with the same input text. while (start>0 && comparator.compare(completions.get(start-1), text)==0) { start--; } } int end = Collections.binarySearch(completions, text+'{', comparator); end = -(end+1); return completions.subList(start, end); }
@SuppressWarnings("unchecked") private List<Completion> resolveCompletions(String text, Set<Completion> set) { completions.addAll(set); // Do a sort of all of our completions to put into case insensitive order and we're good to go! Collections.sort(completions, comparator); // Only match based on stuff after the final '.', since that's what // is // displayed for all of our completions. text = text.substring(text.lastIndexOf('.') + 1); int start = Collections.binarySearch(completions, text, comparator); if (start < 0) { start = -(start + 1); } else { // There might be multiple entries with the same input text. while (start > 0 && comparator.compare(completions.get(start - 1), text) == 0) { start--; } } int end = Collections.binarySearch(completions, text + '{', comparator); end = -(end + 1); return completions.subList(start, end); }
/** * Returns a list of <tt>Completion</tt>s in this provider with the * specified input text. * * @param inputText The input text to search for. * @return A list of {@link Completion}s, or <code>null</code> if there * are no matching <tt>Completion</tt>s. */ @SuppressWarnings("unchecked") public List<Completion> getCompletionByInputText(String inputText) { // Find any entry that matches this input text (there may be > 1). int end = Collections.binarySearch(completions, inputText, comparator); if (end<0) { return null; } // There might be multiple entries with the same input text. int start = end; while (start>0 && comparator.compare(completions.get(start-1), inputText)==0) { start--; } int count = completions.size(); while (++end<count && comparator.compare(completions.get(end), inputText)==0); return completions.subList(start, end); // (inclusive, exclusive) }
public PropertyValueCompletionProvider(boolean isLess) { setAutoActivationRules(true, "@: "); // While we don't have functions per-se in CSS, we do in Less setParameterizedCompletionParams('(', ", ", ')'); this.isLess = isLess; try { this.valueCompletions = new HashMap<String, List<Completion>>(); this.valueCompletionGenerators = new HashMap<String, List<CompletionGenerator>>(); loadPropertyCompletions(); this.htmlTagCompletions = loadHtmlTagCompletions(); } catch (IOException ioe) { // Never happens throw new RuntimeException(ioe); } comparator = new AbstractCompletionProvider.CaseInsensitiveComparator(); }
/** * Constructor. */ public AbstractCompletionProvider() { comparator = new CaseInsensitiveComparator(); clearParameterizedCompletionParams(); completions = new ArrayList<Completion>(); }