Change priority of the quick fixes
#KT-30233 Fixed
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
@@ -32,7 +31,7 @@ abstract class AbstractChopListIntention<TList : KtElement, TElement : KtElement
|
||||
private val listClass: Class<TList>,
|
||||
private val elementClass: Class<TElement>,
|
||||
text: String
|
||||
) : SelfTargetingOffsetIndependentIntention<TList>(listClass, text), LowPriorityAction {
|
||||
) : SelfTargetingOffsetIndependentIntention<TList>(listClass, text) {
|
||||
|
||||
override fun isApplicableTo(element: TList): Boolean {
|
||||
val elements = element.elements()
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
@@ -28,11 +27,10 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import java.lang.RuntimeException
|
||||
|
||||
class ConvertToBlockBodyIntention : SelfTargetingIntention<KtDeclarationWithBody>(
|
||||
KtDeclarationWithBody::class.java, "Convert to block body"
|
||||
), LowPriorityAction {
|
||||
KtDeclarationWithBody::class.java, "Convert to block body"
|
||||
) {
|
||||
override fun isApplicableTo(element: KtDeclarationWithBody, caretOffset: Int): Boolean {
|
||||
if (element is KtFunctionLiteral || element.hasBlockBody() || !element.hasBody()) return false
|
||||
|
||||
@@ -66,7 +64,7 @@ class ConvertToBlockBodyIntention : SelfTargetingIntention<KtDeclarationWithBody
|
||||
if (bodyType != null && bodyType.isUnit() && body is KtNameReferenceExpression) return factory.createEmptyBody()
|
||||
val unitWhenAsResult = (bodyType == null || bodyType.isUnit()) && body.resultingWhens().isNotEmpty()
|
||||
val needReturn = returnsValue &&
|
||||
(bodyType == null || (!bodyType.isUnit() && !bodyType.isNothing()))
|
||||
(bodyType == null || (!bodyType.isUnit() && !bodyType.isNothing()))
|
||||
val statement = if (needReturn || unitWhenAsResult) factory.createExpressionByPattern("return $0", body) else body
|
||||
return factory.createSingleStatementBlock(statement)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
@@ -33,7 +34,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ClassQualifier
|
||||
|
||||
class ImportAllMembersIntention : SelfTargetingIntention<KtElement>(KtElement::class.java, "Import members with '*'"){
|
||||
class ImportAllMembersIntention : SelfTargetingIntention<KtElement>(KtElement::class.java, "Import members with '*'"), HighPriorityAction {
|
||||
override fun isApplicableTo(element: KtElement, caretOffset: Int): Boolean {
|
||||
val receiverExpression = element.receiverExpression() ?: return false
|
||||
if (!receiverExpression.range.containsOffset(caretOffset)) return false
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
@@ -34,7 +35,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
class ImportMemberIntention : SelfTargetingOffsetIndependentIntention<KtNameReferenceExpression>(
|
||||
KtNameReferenceExpression::class.java,
|
||||
"Add import for member"
|
||||
) {
|
||||
), HighPriorityAction {
|
||||
|
||||
private fun getFullQualifier(element: KtNameReferenceExpression): KtQualifiedExpression? = element.getTopmostParentOfType()
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
@@ -34,7 +35,7 @@ import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
|
||||
class IntroduceVariableIntention : SelfTargetingRangeIntention<PsiElement>(
|
||||
PsiElement::class.java, CodeInsightBundle.message("intention.introduce.variable.text")
|
||||
) {
|
||||
), HighPriorityAction {
|
||||
private fun getExpressionToProcess(element: PsiElement): KtExpression? {
|
||||
if (element is PsiFileSystemItem) return null
|
||||
val startElement = PsiTreeUtil.skipSiblingsBackward(element, PsiWhiteSpace::class.java) ?: element
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -30,7 +31,7 @@ import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
class RemoveExplicitTypeIntention : SelfTargetingRangeIntention<KtCallableDeclaration>(
|
||||
KtCallableDeclaration::class.java,
|
||||
"Remove explicit type specification"
|
||||
) {
|
||||
), HighPriorityAction {
|
||||
|
||||
override fun applicabilityRange(element: KtCallableDeclaration): TextRange? {
|
||||
return getRange(element)
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
@@ -30,7 +29,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
|
||||
class ReplaceItWithExplicitFunctionLiteralParamIntention : SelfTargetingOffsetIndependentIntention<KtNameReferenceExpression>(
|
||||
KtNameReferenceExpression::class.java, "Replace 'it' with explicit parameter"
|
||||
), LowPriorityAction {
|
||||
) {
|
||||
override fun isApplicableTo(element: KtNameReferenceExpression) = isAutoCreatedItUsage(element)
|
||||
|
||||
override fun applyTo(element: KtNameReferenceExpression, editor: Editor?) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.codeInsight.template.*
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.Editor
|
||||
@@ -46,7 +47,7 @@ import org.jetbrains.kotlin.utils.ifEmpty
|
||||
class SpecifyTypeExplicitlyIntention : SelfTargetingRangeIntention<KtCallableDeclaration>(
|
||||
KtCallableDeclaration::class.java,
|
||||
"Specify type explicitly"
|
||||
) {
|
||||
), HighPriorityAction {
|
||||
|
||||
override fun applicabilityRange(element: KtCallableDeclaration): TextRange? {
|
||||
if (element.containingFile is KtCodeFragment) return null
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
@@ -54,7 +56,7 @@ abstract class ExclExclCallFix(psiElement: PsiElement) : KotlinQuickFixAction<Ps
|
||||
override fun startInWriteAction(): Boolean = true
|
||||
}
|
||||
|
||||
class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement), CleanupFix {
|
||||
class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement), CleanupFix, HighPriorityAction {
|
||||
override fun getText(): String = KotlinBundle.message("remove.unnecessary.non.null.assertion")
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean =
|
||||
@@ -81,7 +83,7 @@ class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement
|
||||
}
|
||||
}
|
||||
|
||||
class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boolean) : ExclExclCallFix(psiElement) {
|
||||
class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boolean) : ExclExclCallFix(psiElement), LowPriorityAction {
|
||||
constructor(psiElement: PsiElement) : this(psiElement, true)
|
||||
|
||||
override fun getText() = KotlinBundle.message("introduce.non.null.assertion")
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -34,7 +35,7 @@ import org.jetbrains.kotlin.types.typeUtil.isNullabilityMismatch
|
||||
class WrapWithSafeLetCallFix(
|
||||
expression: KtExpression,
|
||||
nullableExpression: KtExpression
|
||||
) : KotlinQuickFixAction<KtExpression>(expression) {
|
||||
) : KotlinQuickFixAction<KtExpression>(expression), HighPriorityAction {
|
||||
private val nullableExpressionPointer = nullableExpression.createSmartPointer()
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
Reference in New Issue
Block a user