Do not reformat expressions in ReplaceCallWithBinaryOperatorInspection and SpecifySuperTypeFix

This commit is contained in:
Yan Zhulanow
2020-05-26 17:40:30 +09:00
parent 5a53c6ebf1
commit 0c71c681e5
2 changed files with 4 additions and 4 deletions
@@ -141,16 +141,16 @@ class ReplaceCallWithBinaryOperatorInspection : AbstractApplicabilityBasedInspec
return when (operation) {
KtTokens.EXCLEQ -> {
val prefixExpression = element.getWrappingPrefixExpressionIfAny() ?: return null
val newExpression = factory.createExpressionByPattern("$0 != $1", receiver, argument)
val newExpression = factory.createExpressionByPattern("$0 != $1", receiver, argument, reformat = false)
prefixExpression to newExpression
}
in OperatorConventions.COMPARISON_OPERATIONS -> {
val binaryParent = element.parent as? KtBinaryExpression ?: return null
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument, reformat = false)
binaryParent to newExpression
}
else -> {
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument, reformat = false)
element to newExpression
}
}
@@ -94,7 +94,7 @@ class SpecifySuperTypeFix(
val fqName = kotlinType.fqName ?: return@mapNotNull null
val fqNameAsString = fqName.asString()
val name = if (typeElement.text.startsWith(fqNameAsString)) fqNameAsString else fqName.shortName().asString()
val newQualifiedExpression = psiFactory.createExpressionByPattern("super<$name>.$0", selectorExpression)
val newQualifiedExpression = psiFactory.createExpressionByPattern("super<$name>.$0", selectorExpression, reformat = false)
val newContext = newQualifiedExpression.analyzeAsReplacement(qualifiedExpression, context)
if (newQualifiedExpression.getResolvedCall(newContext)?.resultingDescriptor == null) return@mapNotNull null
if (newContext.diagnostics.noSuppression().forElement(newQualifiedExpression).isNotEmpty()) return@mapNotNull null