mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[java-intentions] IDEA-363624 Create Class generates invalid and redundant annotation @NotNull @NotNull for constructor parameter
(cherry picked from commit 9c3c9c55517369e6715c65a9696c287514261a10) IJ-CR-151031 GitOrigin-RevId: 8306c8925395abd7dcee24de847335e4e9b1f535
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4331ed9295
commit
071179ffed
@@ -10,8 +10,8 @@ import com.intellij.codeInsight.intention.impl.CreateClassDialog;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.lookup.LookupFocusDegree;
|
||||
import com.intellij.codeInsight.template.ExpressionUtil;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.codeInsight.template.ExpressionUtil;
|
||||
import com.intellij.codeInspection.CommonQuickFixBundle;
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
@@ -304,7 +304,8 @@ public final class CreateFromUsageUtils {
|
||||
argType = getParameterTypeByArgumentType(argType, psiManager, resolveScope);
|
||||
PsiParameter parameter = parameterList.getParameter(i);
|
||||
if (parameter == null) {
|
||||
PsiParameter param = factory.createParameter(names[0], argType);
|
||||
// Remove top-level annotations. They will be added by setupTypeElement again
|
||||
PsiParameter param = factory.createParameter(names[0], argType.annotate(TypeAnnotationProvider.EMPTY));
|
||||
if (isInterface) {
|
||||
PsiUtil.setModifierProperty(param, PsiModifier.FINAL, false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Create class 'Baz'" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
public static void foo() {
|
||||
final @NotNull String bar = "bar";
|
||||
var baz = new Baz(bar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Baz {
|
||||
public Baz(@NotNull String bar) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Create class 'Baz'" "true"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
public static void foo() {
|
||||
final @NotNull String bar = "bar";
|
||||
var baz = new <caret>Baz(bar);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,10 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase.JAVA_21;
|
||||
|
||||
public class CreateClassFromNewTest extends LightQuickFixParameterizedTestCase {
|
||||
@Override
|
||||
@@ -16,4 +20,9 @@ public class CreateClassFromNewTest extends LightQuickFixParameterizedTestCase {
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/createClassFromNew";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_21;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user