Code cleanup: several inspections applied
This commit is contained in:
committed by
Mikhail Glukhikh
parent
fdca96634e
commit
840847e47c
@@ -216,7 +216,7 @@ class LibraryInfo(val project: Project, val library: Library) : IdeaModuleInfo,
|
||||
get() = LibrarySourceInfo(project, library)
|
||||
|
||||
override fun getLibraryRoots(): Collection<String> =
|
||||
library.getFiles(OrderRootType.CLASSES).map(PathUtil::getLocalPath).filterNotNull()
|
||||
library.getFiles(OrderRootType.CLASSES).mapNotNull(PathUtil::getLocalPath)
|
||||
|
||||
override fun toString() = "LibraryInfo(libraryName=${library.name})"
|
||||
|
||||
|
||||
+2
-2
@@ -82,7 +82,7 @@ private fun findDeclarationInCompiledFile(file: KtClsFile, member: PsiMember, si
|
||||
file
|
||||
else {
|
||||
val topClassOrObject = file.declarations.singleOrNull() as? KtClassOrObject
|
||||
relativeClassName.fold<Name, KtClassOrObject?>(topClassOrObject) { classOrObject, name ->
|
||||
relativeClassName.fold(topClassOrObject) { classOrObject, name ->
|
||||
classOrObject?.declarations?.singleOrNull { it.name == name.asString() } as? KtClassOrObject
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ private fun PsiMember.relativeClassName(): List<Name> {
|
||||
}
|
||||
|
||||
private fun ClassDescriptor.relativeClassName(): List<Name> {
|
||||
return classId!!.relativeClassName.pathSegments().drop(1).orEmpty()
|
||||
return classId!!.relativeClassName.pathSegments().drop(1)
|
||||
}
|
||||
|
||||
private fun ClassDescriptor.desc(): String = "L" + JvmClassName.byClassId(classId!!).internalName + ";"
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ object SourceNavigationHelper {
|
||||
.mapNotNull { it.sourcesModuleInfo?.sourceScope() }.union()
|
||||
|
||||
NavigationKind.SOURCES_TO_CLASS_FILES -> getLibrarySourcesModuleInfos(declaration.project, vFile)
|
||||
.mapNotNull { it.binariesModuleInfo.binariesScope() }.union()
|
||||
.map { it.binariesModuleInfo.binariesScope() }.union()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ private fun createQuickFixes(similarDiagnostics: Collection<Diagnostic>): MultiM
|
||||
val actions = MultiMap<Diagnostic, IntentionAction>()
|
||||
|
||||
val intentionActionsFactories = QuickFixes.getInstance().getActionFactories(factory)
|
||||
for (intentionActionsFactory in intentionActionsFactories.filterNotNull()) {
|
||||
for (intentionActionsFactory in intentionActionsFactories) {
|
||||
val allProblemsActions = intentionActionsFactory.createActionsForAllProblems(similarDiagnostics)
|
||||
if (!allProblemsActions.isEmpty()) {
|
||||
actions.putValues(first, allProblemsActions)
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ private object DeclarationKindDetector : KtVisitor<AnnotationHostKind?, Unit?>()
|
||||
override fun visitProperty(d: KtProperty, data: Unit?) = detect(d, d.valOrVarKeyword.text!!)
|
||||
|
||||
override fun visitDestructuringDeclaration(d: KtDestructuringDeclaration, data: Unit?) = detect(d, d.valOrVarKeyword?.text ?: "val",
|
||||
name = d.entries.map { it.name!! }.joinToString(", ", "(", ")"))
|
||||
name = d.entries.joinToString(", ", "(", ")") { it.name!! })
|
||||
|
||||
override fun visitTypeParameter(d: KtTypeParameter, data: Unit?) = detect(d, "type parameter", newLineNeeded = false)
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ fun renderResolvedCall(resolvedCall: ResolvedCall<*>, context: RenderingContext)
|
||||
|
||||
append("<br/>$indent<i>where</i> ")
|
||||
if (!notInferredTypeParameters.isEmpty()) {
|
||||
append(notInferredTypeParameters.map { typeParameter -> renderError(typeParameter.name) }.joinToString())
|
||||
append(notInferredTypeParameters.joinToString { typeParameter -> renderError(typeParameter.name) })
|
||||
append("<i> cannot be inferred</i>")
|
||||
if (!inferredTypeParameters.isEmpty()) {
|
||||
append("; ")
|
||||
@@ -91,9 +91,9 @@ fun renderResolvedCall(resolvedCall: ResolvedCall<*>, context: RenderingContext)
|
||||
|
||||
val typeParameterToTypeArgumentMap = resolvedCall.typeArguments
|
||||
if (!inferredTypeParameters.isEmpty()) {
|
||||
append(inferredTypeParameters.map { typeParameter ->
|
||||
append(inferredTypeParameters.joinToString { typeParameter ->
|
||||
"${typeParameter.name} = ${typeRenderer.render(typeParameterToTypeArgumentMap[typeParameter]!!, context)}"
|
||||
}.joinToString())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ fun renderResolvedCall(resolvedCall: ResolvedCall<*>, context: RenderingContext)
|
||||
append(typeRenderer.render(receiverParameter.type, context)).append(".")
|
||||
}
|
||||
append(HtmlEscapers.htmlEscaper().escape(resultingDescriptor.name.asString())).append("(")
|
||||
append(resultingDescriptor.valueParameters.map(::renderParameter).joinToString())
|
||||
append(resultingDescriptor.valueParameters.joinToString(transform = ::renderParameter))
|
||||
append(if (resolvedCall.hasUnmappedArguments()) renderError(")") else ")")
|
||||
|
||||
if (!resolvedCall.candidateDescriptor.typeParameters.isEmpty()) {
|
||||
|
||||
@@ -205,8 +205,7 @@ class ResolveElementCache(
|
||||
}
|
||||
else {
|
||||
contextElements
|
||||
.map { it.getNonStrictParentOfType<KtDeclaration>() }
|
||||
.filterNotNull()
|
||||
.mapNotNull { it.getNonStrictParentOfType<KtDeclaration>() }
|
||||
.filterTo(declarationsToResolve) {
|
||||
it !is KtAnonymousInitializer && it !is KtDestructuringDeclaration && it !is KtDestructuringDeclarationEntry
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user