Minor. Utility moved to a common place

This commit is contained in:
Andrey Breslav
2014-06-06 15:00:11 +04:00
parent 346c491ebd
commit 42aa9e2378
2 changed files with 6 additions and 4 deletions
@@ -80,3 +80,7 @@ public fun <T> Iterable<Iterable<T>>.flatten(): List<T> {
} }
public fun <T: Any> emptyOrSingletonList(item: T?): List<T> = if (item == null) listOf() else listOf(item) public fun <T: Any> emptyOrSingletonList(item: T?): List<T> = if (item == null) listOf() else listOf(item)
public fun <T: Any> MutableCollection<T>.addIfNotNull(t: T?) {
if (t != null) add(t)
}
@@ -371,5 +371,3 @@ private fun PsiElement.isInCopiedArea(fileCopiedFrom: JetFile, startOffsets: Int
range in TextRange(start, end) range in TextRange(start, end)
} }
} }
private fun <T : Any> MutableCollection<T>.addIfNotNull(el: T?) = ContainerUtil.addIfNotNull(this, el)