CompletionSorter (CompletionParameters parameters, PrefixMatcher matcher) { CompletionLocation location = new CompletionLocation(parameters); CompletionSorterImpl sorter = emptySorter(); sorter = addWeighersBefore(sorter); //sorter = sorter.withClassifier(CompletionSorterImpl.weighingFactory(LiveTemplateWeigher())) sorter = sorter.withClassifier(CompletionSorterImpl.weighingFactory(new PreferStartMatching())); for (final Weigher weigher : WeighingService.getWeighers(RELEVANCE_KEY)) { final String id = weigher.toString(); if ("prefix".equals(id)) { sorter = sorter.withClassifier(CompletionSorterImpl.weighingFactory(new RealPrefixMatchingWeigher())); } else if ("stats".equals(id)) { sorter = processStatsWeigher(sorter, weigher, location); } else { sorter = sorter.weigh(new LookupElementWeigher(id, true, false) { @Override public @Nullable Comparable weigh(@NotNull LookupElement element) { //noinspection unchecked return weigher.weigh(element, location); } }); } } return sorter.withClassifier("priority", true, new ClassifierFactory<>("liftShorter") { @Override public Classifier<LookupElement> createClassifier(Classifier<LookupElement> next) { return new LiftShorterItemsClassifier("liftShorter", next, new LiftShorterItemsClassifier.LiftingCondition(), false); } }); }