List<LocalInspectionToolWrapper> (@NotNull Collection<? extends LocalInspectionToolWrapper> tools, @NotNull Set<String> elementDialectIds) { Map<String, Boolean> resultsWithDialects = new HashMap<>(); Map<String, Boolean> resultsNoDialects = new HashMap<>(); return ContainerUtil.filter(tools, tool -> { String toolLanguageId = tool.getLanguage(); if (toolLanguageId == null || toolLanguageId.isBlank() || "any".equals(toolLanguageId)) return true; boolean applyToDialects = tool.applyToDialects(); Map<String, Boolean> map = applyToDialects ? resultsWithDialects : resultsNoDialects; return map.computeIfAbsent(toolLanguageId, __ -> ToolLanguageUtil.isToolLanguageOneOf(elementDialectIds, toolLanguageId, applyToDialects)); }); }