From 475eaf475464063307c9847fef5e200a7297f040 Mon Sep 17 00:00:00 2001 From: "Andrey.Cherkasov" Date: Tue, 8 Feb 2022 00:50:15 +0300 Subject: [PATCH] [java-highlighting] Use 'SetVariableTypeFix' for the "The receiver type does not match the enclosing class type" error GitOrigin-RevId: f60f37d148c81dfe0fb86d56a385c2561ad9bb07 --- .../impl/config/QuickFixFactoryImpl.java | 28 +++++++++++-------- .../afterReceiverParameter.java | 0 .../beforeReceiverParameter.java | 0 3 files changed, 17 insertions(+), 11 deletions(-) rename java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/{variableType => setVariableType}/afterReceiverParameter.java (100%) rename java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/{variableType => setVariableType}/beforeReceiverParameter.java (100%) diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java index 2d8a91e1841a..644f7aa2118e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.intention.impl.config; import com.intellij.codeInsight.CodeInsightWorkspaceSettings; @@ -1052,17 +1052,23 @@ public final class QuickFixFactoryImpl extends QuickFixFactory { @Override public @NotNull IntentionAction createReceiverParameterTypeFix(@NotNull PsiReceiverParameter receiverParameter, @NotNull PsiType enclosingClassType) { - return new VariableTypeFix(receiverParameter, enclosingClassType) { - @Override - public @NotNull String getText() { - return QuickFixBundle.message("fix.receiver.parameter.type.text"); - } + return new ReceiverParameterTypeFix(receiverParameter, enclosingClassType); + } - @Override - public @NotNull String getFamilyName() { - return QuickFixBundle.message("fix.receiver.parameter.type.family"); - } - }; + private final static class ReceiverParameterTypeFix extends SetVariableTypeFix { + private ReceiverParameterTypeFix(@NotNull PsiReceiverParameter receiverParameter, @NotNull PsiType enclosingClassType) { + super(receiverParameter, enclosingClassType); + } + + @Override + public @NotNull String getText() { + return QuickFixBundle.message("fix.receiver.parameter.type.text"); + } + + @Override + public @NotNull String getFamilyName() { + return QuickFixBundle.message("fix.receiver.parameter.type.family"); + } } @Override diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/variableType/afterReceiverParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/setVariableType/afterReceiverParameter.java similarity index 100% rename from java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/variableType/afterReceiverParameter.java rename to java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/setVariableType/afterReceiverParameter.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/variableType/beforeReceiverParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/setVariableType/beforeReceiverParameter.java similarity index 100% rename from java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/variableType/beforeReceiverParameter.java rename to java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/setVariableType/beforeReceiverParameter.java