@Override public Map<LookupElement, StringBuilder> getRelevanceStrings() { final LinkedHashMap<LookupElement, StringBuilder> map = new LinkedHashMap<LookupElement, StringBuilder>(); for (LookupElement item : myItems) { map.put(item, new StringBuilder()); } final MultiMap<CompletionSorterImpl, LookupElement> inputBySorter = groupItemsBySorter(new ArrayList<LookupElement>(map.keySet())); if (inputBySorter.size() > 1) { for (LookupElement element : map.keySet()) { map.get(element).append(obtainSorter(element)).append(": "); } } for (CompletionSorterImpl sorter : inputBySorter.keySet()) { final LinkedHashMap<LookupElement, StringBuilder> subMap = new LinkedHashMap<LookupElement, StringBuilder>(); for (LookupElement element : inputBySorter.get(sorter)) { subMap.put(element, map.get(element)); } Classifier<LookupElement> classifier = myClassifiers.get(sorter); if (classifier != null) { classifier.describeItems(subMap, createContext(false)); } } return map; }
@Override public void addElement( Lookup lookup, LookupElement element, LookupElementPresentation presentation) { StatisticsWeigher.clearBaseStatisticsInfo(element); final String invariant = presentation.getItemText() + "###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText(); element.putUserData(PRESENTATION_INVARIANT, invariant); CompletionSorterImpl sorter = obtainSorter(element); Classifier<LookupElement> classifier = myClassifiers.get(sorter); if (classifier == null) { myClassifiers.put(sorter, classifier = sorter.buildClassifier(new AlphaClassifier(lookup))); } classifier.addElement(element); super.addElement(lookup, element, presentation); }