SearchInitializer (ChainSearchTarget target, CompilerReferenceServiceEx referenceServiceEx, ChainCompletionContext context) { SortedSet<ChainOpAndOccurrences<? extends RefChainOperation>> operations = new TreeSet<>(); for (byte kind : target.getArrayKind()) { SortedSet<ChainOpAndOccurrences<MethodCall>> methods = referenceServiceEx.findMethodReferenceOccurrences(target.getClassQName(), kind, context); operations.addAll(methods); } if (operations.isEmpty()) { ChainOpAndOccurrences<TypeCast> typeCast = referenceServiceEx.getMostUsedTypeCast(target.getClassQName()); if (typeCast != null) { operations.add(typeCast); } } return new SearchInitializer(operations, context); }