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
@@ -79,4 +79,8 @@ public fun <T> Iterable<Iterable<T>>.flatten(): List<T> {
return flatMapTo(ArrayList<T>(), {it})
}
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)
}
@@ -370,6 +370,4 @@ private fun PsiElement.isInCopiedArea(fileCopiedFrom: JetFile, startOffsets: Int
val (start, end) = it
range in TextRange(start, end)
}
}
private fun <T : Any> MutableCollection<T>.addIfNotNull(el: T?) = ContainerUtil.addIfNotNull(this, el)
}