Cleanup: apply "cascade if..." inspection (+ some others)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
9c06739594
commit
1d2017b0fc
@@ -212,14 +212,13 @@ class OptimizedImportsBuilder(
|
||||
val explicitImportPath = ImportPath(fqName, false)
|
||||
val starImportPath = ImportPath(fqName.parent(), true)
|
||||
val importPaths = file.importDirectives.map { it.importPath }
|
||||
if (explicitImportPath in importPaths) {
|
||||
importRules.add(ImportRule.Add(explicitImportPath))
|
||||
}
|
||||
else if (starImportPath in importPaths) {
|
||||
importRules.add(ImportRule.Add(starImportPath))
|
||||
}
|
||||
else { // there is no import for this descriptor in the original import list, so do not allow to import it by star-import
|
||||
importRules.add(ImportRule.DoNotAdd(starImportPath))
|
||||
when {
|
||||
explicitImportPath in importPaths ->
|
||||
importRules.add(ImportRule.Add(explicitImportPath))
|
||||
starImportPath in importPaths ->
|
||||
importRules.add(ImportRule.Add(starImportPath))
|
||||
else -> // there is no import for this descriptor in the original import list, so do not allow to import it by star-import
|
||||
importRules.add(ImportRule.DoNotAdd(starImportPath))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,14 +276,10 @@ class OptimizedImportsBuilder(
|
||||
val iterator1 = tower1.iterator()
|
||||
val iterator2 = tower2.iterator()
|
||||
while (true) {
|
||||
if (!iterator1.hasNext()) {
|
||||
return !iterator2.hasNext()
|
||||
}
|
||||
else if (!iterator2.hasNext()) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
if (!areTargetsEqual(iterator1.next(), iterator2.next())) return false
|
||||
when {
|
||||
!iterator1.hasNext() -> return !iterator2.hasNext()
|
||||
!iterator2.hasNext() -> return false
|
||||
else -> if (!areTargetsEqual(iterator1.next(), iterator2.next())) return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,18 +271,18 @@ class PartialBodyResolveFilter(
|
||||
val left = condition.left ?: return emptyResult
|
||||
val right = condition.right ?: return emptyResult
|
||||
|
||||
fun smartCastInEq(): Pair<Set<SmartCastName>, Set<SmartCastName>> {
|
||||
if (left.isNullLiteral()) {
|
||||
return Pair(setOf(), right.smartCastExpressionName().singletonOrEmptySet())
|
||||
fun smartCastInEq(): Pair<Set<SmartCastName>, Set<SmartCastName>> = when {
|
||||
left.isNullLiteral() -> {
|
||||
Pair(setOf(), right.smartCastExpressionName().singletonOrEmptySet())
|
||||
}
|
||||
else if (right.isNullLiteral()) {
|
||||
return Pair(setOf(), left.smartCastExpressionName().singletonOrEmptySet())
|
||||
right.isNullLiteral() -> {
|
||||
Pair(setOf(), left.smartCastExpressionName().singletonOrEmptySet())
|
||||
}
|
||||
else {
|
||||
else -> {
|
||||
val leftName = left.smartCastExpressionName()
|
||||
val rightName = right.smartCastExpressionName()
|
||||
val names = listOfNotNull(leftName, rightName).toSet()
|
||||
return Pair(names, setOf())
|
||||
Pair(names, setOf())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user