Replace map { ... }.filterNotNull() with mapNotNull { ... }

This commit is contained in:
Ilya Gorbunov
2015-11-13 23:43:05 +03:00
parent 5b02a59cb7
commit 32151c077e
112 changed files with 197 additions and 269 deletions
@@ -92,13 +92,13 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
}
override fun findClassOrObjectDeclarations(fqName: FqName, searchScope: GlobalSearchScope): Collection<KtClassOrObject> {
return ResolveSessionUtils.getClassDescriptorsByFqName(module, fqName).map {
return ResolveSessionUtils.getClassDescriptorsByFqName(module, fqName).mapNotNull {
val element = DescriptorToSourceUtils.getSourceFromDescriptor(it)
if (element is KtClassOrObject && PsiSearchScopeUtil.isInScope(searchScope, element)) {
element
}
else null
}.filterNotNull()
}
}
override fun findFilesForPackage(fqName: FqName, searchScope: GlobalSearchScope): Collection<KtFile> {
@@ -216,7 +216,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
override fun getFacadeClassesInPackage(packageFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
return PackagePartClassUtils.getFilesWithCallables(findFilesForPackage(packageFqName, scope)).groupBy {
JvmFileClassUtil.getFileClassInfoNoResolve(it).facadeClassFqName
}.map { KtLightClassForFacade.createForFacade(psiManager, it.key, scope, it.value) }.filterNotNull()
}.mapNotNull { KtLightClassForFacade.createForFacade(psiManager, it.key, scope, it.value) }
}
override fun getFacadeNames(packageFqName: FqName, scope: GlobalSearchScope): Collection<String> {
@@ -28,9 +28,9 @@ public class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePar
val roots by lazy {
env.configuration.getList(CommonConfigurationKeys.CONTENT_ROOTS).
filterIsInstance<JvmClasspathRoot>().
map {
mapNotNull {
env.contentRootToVirtualFile(it);
}.filter { it?.findChild("META-INF") != null }.filterNotNull()
}.filter { it.findChild("META-INF") != null }
}
override fun findPackageParts(packageFqName: String): List<String> {
@@ -43,10 +43,10 @@ public class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePar
else parent.findChild(part) ?: return@filter false
}
true
}.map {
}.mapNotNull {
it.findChild("META-INF")
}.filterNotNull().flatMap {
it.children.filter { it.name.endsWith(ModuleMapping.MAPPING_FILE_EXT) }.toList<VirtualFile>()
}.flatMap {
it.children.filter<VirtualFile> { it.name.endsWith(ModuleMapping.MAPPING_FILE_EXT) }
}.map {
try {
ModuleMapping.create(it.contentsToByteArray())
@@ -55,6 +55,6 @@ public class JvmPackagePartProvider(val env: KotlinCoreEnvironment) : PackagePar
}
}
return mappings.map { it.findPackageParts(packageFqName) }.filterNotNull().flatMap { it.parts }.distinct()
return mappings.mapNotNull { it.findPackageParts(packageFqName) }.flatMap { it.parts }.distinct()
}
}