Code cleanup: several inspections applied

This commit is contained in:
Mikhail Glukhikh
2017-06-27 14:26:19 +03:00
committed by Mikhail Glukhikh
parent fdca96634e
commit 840847e47c
76 changed files with 121 additions and 147 deletions
@@ -475,7 +475,7 @@ class KotlinIndicesHelper(
private fun KtNamedDeclaration.resolveToDescriptorsWithHack(
psiFilter: (KtDeclaration) -> Boolean): Collection<DeclarationDescriptor> {
if (containingKtFile.isCompiled) { //TODO: it's temporary while resolveToDescriptor does not work for compiled declarations
return resolutionFacade.resolveImportReference(moduleDescriptor, fqName!!).filterIsInstance<DeclarationDescriptor>()
return resolutionFacade.resolveImportReference(moduleDescriptor, fqName!!)
}
else {
val translatedDeclaration = declarationTranslator(this) ?: return emptyList()
@@ -168,7 +168,7 @@ fun String.quoteIfNeeded(): String = if (KotlinNameSuggester.isIdentifier(this))
fun String.unquote(): String = KtPsiUtil.unquoteIdentifier(this)
fun FqName.quoteSegmentsIfNeeded(): String {
return pathSegments().map { it.asString().quoteIfNeeded() }.joinToString(".")
return pathSegments().joinToString(".") { it.asString().quoteIfNeeded() }
}
fun FqName.quoteIfNeeded() = FqName(quoteSegmentsIfNeeded())
@@ -176,7 +176,7 @@ fun <T : KtDeclaration> insertMembersAfter(
val body = classOrObject.getOrCreateBody()
var afterAnchor = anchor ?: findInsertAfterAnchor(editor, body) ?: return@runWriteAction emptyList<T>()
otherMembers.mapNotNullTo(insertedMembers) {
otherMembers.mapTo(insertedMembers) {
if (classOrObject is KtClass && classOrObject.isEnum()) {
val enumEntries = classOrObject.declarations.filterIsInstance<KtEnumEntry>()
val bound = (enumEntries.lastOrNull() ?: classOrObject.allChildren.firstOrNull { it.node.elementType == KtTokens.SEMICOLON })