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