Renamed firstOrNullIsInstance

This commit is contained in:
Valentin Kipyatkov
2014-11-21 15:22:53 +03:00
parent ddc60ac5dd
commit d334011d5d
6 changed files with 13 additions and 13 deletions
@@ -24,12 +24,12 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.PsiErrorElement
import org.jetbrains.jet.lang.psi.JetCallableDeclaration
import org.jetbrains.jet.utils.addToStdlib.firstOrNullIsInstance
import org.jetbrains.jet.utils.addToStdlib.firstIsInstanceOrNull
fun getTypeReference(declaration: JetCallableDeclaration): JetTypeReference? {
return declaration.getFirstChild()!!.siblings(forward = true)
.dropWhile { it.getNode()!!.getElementType() != JetTokens.COLON }
.firstOrNullIsInstance<JetTypeReference>()
.firstIsInstanceOrNull<JetTypeReference>()
}
fun setTypeReference(declaration: JetCallableDeclaration, addAfter: PsiElement?, typeRef: JetTypeReference?): JetTypeReference? {
@@ -34,7 +34,7 @@ import org.jetbrains.jet.storage.StorageManager
import org.jetbrains.jet.context.LazinessToken
import org.jetbrains.jet.lang.resolve.lazy.LazyEntity
import org.jetbrains.jet.lang.resolve.lazy.ForceResolveUtil
import org.jetbrains.jet.utils.addToStdlib.firstOrNullIsInstance
import org.jetbrains.jet.utils.addToStdlib.firstIsInstanceOrNull
public class TypeResolver(
private val annotationResolver: AnnotationResolver,
@@ -276,7 +276,7 @@ public class TypeResolver(
public fun resolveClass(scope: JetScope, userType: JetUserType, trace: BindingTrace): ClassifierDescriptor? {
val classifierDescriptor = qualifiedExpressionResolver.lookupDescriptorsForUserType(userType, scope, trace)
.firstOrNullIsInstance<ClassifierDescriptor>()
.firstIsInstanceOrNull<ClassifierDescriptor>()
if (classifierDescriptor != null) {
ImportsResolver.reportPlatformClassMappedToKotlin(moduleDescriptor, trace, userType, classifierDescriptor)
}
@@ -36,19 +36,19 @@ public fun <T: Any> T?.singletonOrEmptyList(): List<T> = if (this != null) Colle
public fun <T: Any> T?.singletonOrEmptySet(): Set<T> = if (this != null) Collections.singleton(this) else Collections.emptySet()
[suppress("NOTHING_TO_INLINE")]
public inline fun <reified T : Any> Stream<*>.firstOrNullIsInstance(): T? {
public inline fun <reified T : Any> Stream<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}
[suppress("NOTHING_TO_INLINE")]
public inline fun <reified T : Any> Iterable<*>.firstOrNullIsInstance(): T? {
public inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}
[suppress("NOTHING_TO_INLINE")]
public inline fun <reified T : Any> Array<*>.firstOrNullIsInstance(): T? {
public inline fun <reified T : Any> Array<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}