ExclExclCallFixes: reformat

This commit is contained in:
Mikhail Glukhikh
2018-01-19 10:54:41 +03:00
parent 2472966749
commit 725704e70f
@@ -55,7 +55,7 @@ class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement
override fun getText(): String = KotlinBundle.message("remove.unnecessary.non.null.assertion")
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean =
getExclExclPostfixExpression() != null
getExclExclPostfixExpression() != null
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return
@@ -74,8 +74,7 @@ class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement
}
companion object : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction
= RemoveExclExclCallFix(diagnostic.psiElement)
override fun createAction(diagnostic: Diagnostic): IntentionAction = RemoveExclExclCallFix(diagnostic.psiElement)
}
}
@@ -85,7 +84,7 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo
override fun getText() = KotlinBundle.message("introduce.non.null.assertion")
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean =
getExpressionForIntroduceCall() != null
getExpressionForIntroduceCall() != null
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return
@@ -130,13 +129,12 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo
if (checkImplicitReceivers && psiElement.getResolvedCall(context)?.getImplicitReceiverValue() != null) {
val expressionToReplace = psiElement.parent as? KtCallExpression ?: psiElement
expressionToReplace.expressionForCall(implicitReceiver = true)
}
else {
} else {
context[BindingContext.EXPRESSION_TYPE_INFO, psiElement]?.let {
val type = it.type
if (type != null) {
val nullability = it.dataFlowInfo.getStableNullability(
DataFlowValueFactory.createDataFlowValue(psiElement, type, context, psiElement.findModuleDescriptor())
DataFlowValueFactory.createDataFlowValue(psiElement, type, context, psiElement.findModuleDescriptor())
)
if (!nullability.canBeNonNull()) return null
}
@@ -153,7 +151,7 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo
}
}
object SmartCastImpossibleExclExclFixFactory: KotlinSingleIntentionActionFactory() {
object SmartCastImpossibleExclExclFixFactory : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
if (diagnostic.factory !== Errors.SMARTCAST_IMPOSSIBLE) return null
val element = diagnostic.psiElement as? KtExpression ?: return null
@@ -179,10 +177,10 @@ object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory()
val analyze = element.analyze(BodyResolveMode.PARTIAL)
val type = analyze.getType(element)
if (type == null || !TypeUtils.isNullableType(type)) return null
val descriptor = type.constructor.declarationDescriptor
fun hasIteratorFunction(classifierDescriptor: ClassifierDescriptor?) : Boolean {
fun hasIteratorFunction(classifierDescriptor: ClassifierDescriptor?): Boolean {
if (classifierDescriptor !is ClassDescriptor) return false
val memberScope = classifierDescriptor.unsubstitutedMemberScope