List<LookupElement> (ChainCompletionContext context) { CompilerReferenceService compilerReferenceService = CompilerReferenceService.getInstanceIfEnabled(context.getProject()); if (compilerReferenceService == null) { return Collections.emptyList(); } CompilerReferenceServiceEx compilerReferenceServiceEx = (CompilerReferenceServiceEx) compilerReferenceService; ChainSearchTarget target = context.getTarget(); List<OperationChain> searchResult = ChainSearcher.search(ChainSearchMagicConstants.MAX_CHAIN_SIZE, target, ChainSearchMagicConstants.MAX_SEARCH_RESULT_SIZE, context, compilerReferenceServiceEx); int maxWeight = searchResult.stream().mapToInt(OperationChain::getChainWeight).max().orElse(0); return searchResult .stream() .filter(ch -> ch.getChainWeight() * ChainSearchMagicConstants.FILTER_RATIO >= maxWeight) .map(ch -> MethodChainLookupRangingHelper.toLookupElement(ch, context)) .collect(Collectors.toList()); }