From f7f459494891f6a2bb24f8dbc28cf460ea2370a3 Mon Sep 17 00:00:00 2001 From: Daniil Ovchinnikov Date: Tue, 23 Jan 2018 17:02:38 +0300 Subject: [PATCH] [groovy] add Consumer.plusAssign --- .../jetbrains/plugins/groovy/util/functions.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/functions.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/functions.kt index 6c0380d192bf..a285b2587b46 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/functions.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/functions.kt @@ -1,8 +1,17 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.util -import com.intellij.util.Consumer +import java.util.function.Consumer +import com.intellij.util.Consumer as JBConsumer -fun Consumer.consumeAll(items: Iterable) { +fun JBConsumer.consumeAll(items: Iterable) { items.forEach(this::consume) } + +operator fun Consumer.plusAssign(elements: Iterable) { + elements.forEach(this::plusAssign) +} + +operator fun Consumer.plusAssign(element: T) { + accept(element) +}