diff --git a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties index 34e6c799210e..52d74b0756f4 100644 --- a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties +++ b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties @@ -342,4 +342,5 @@ compiler.cache.option.max.download.time.units= mins notification.title.jps.caches.downloader=Jps caches downloader notification.content.internal.authentication.plugin.required.for.correct.work=JetBrains Internal Authentication is required for the correct work of JPS Caches notification.title.git.crlf.config=Wrong Git line-endings configuration -notification.content.git.crlf.config=To have working compiler caches you need to execute {0} command and force checkout the project \ No newline at end of file +notification.content.git.crlf.config=To have working compiler caches you need to execute {0} command and force checkout the project +class.can.be.record.suppress.conversion.if.annotated.description=Specify class names or package wildcards like com.example.* \ No newline at end of file diff --git a/java/java-impl-inspections/src/com/intellij/codeInspection/classCanBeRecord/ClassCanBeRecordInspection.java b/java/java-impl-inspections/src/com/intellij/codeInspection/classCanBeRecord/ClassCanBeRecordInspection.java index 01239d9c1ba0..eb634f64b31c 100644 --- a/java/java-impl-inspections/src/com/intellij/codeInspection/classCanBeRecord/ClassCanBeRecordInspection.java +++ b/java/java-impl-inspections/src/com/intellij/codeInspection/classCanBeRecord/ClassCanBeRecordInspection.java @@ -1,16 +1,17 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.classCanBeRecord; import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature; import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.classCanBeRecord.ConvertToRecordFix.RecordCandidate; -import com.intellij.codeInspection.ui.InspectionOptionsPanel; +import com.intellij.codeInspection.options.OptPane; import com.intellij.codeInspection.util.InspectionMessage; -import com.intellij.codeInspection.util.SpecialAnnotationsUtil; import com.intellij.java.JavaBundle; +import com.intellij.openapi.compiler.JavaCompilerBundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.NlsSafe; +import com.intellij.openapi.util.text.HtmlChunk; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; import com.intellij.psi.PsiAnnotation; import com.intellij.psi.PsiClass; @@ -18,21 +19,19 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiIdentifier; import com.intellij.util.ObjectUtils; import com.intellij.util.SmartList; -import com.intellij.util.ui.CheckBox; -import com.intellij.util.ui.JBUI; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; import one.util.streamex.StreamEx; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; -import javax.swing.*; import java.util.ArrayList; import java.util.List; +import static com.intellij.codeInspection.options.OptPane.*; + public class ClassCanBeRecordInspection extends BaseInspection { private static final List IGNORED_ANNOTATIONS = List.of("io.micronaut.*", "jakarta.*", "javax.*", "org.springframework.*"); @@ -96,26 +95,13 @@ public class ClassCanBeRecordInspection extends BaseInspection { } @Override - public @Nullable JComponent createOptionsPanel() { - InspectionOptionsPanel panel = new InspectionOptionsPanel(); - panel.add(new CheckBox(JavaBundle.message("class.can.be.record.suggest.renaming.accessors"), this, - "suggestAccessorsRenaming")); - - panel.add(new JLabel(JavaBundle.message("class.can.be.record.conversion.make.member.more.accessible"))); - ButtonGroup butGr = new ButtonGroup(); - for (ConversionStrategy strategy : ConversionStrategy.values()) { - JRadioButton radioBut = new JRadioButton(strategy.getMessage(), strategy == myConversionStrategy); - radioBut.addActionListener(e -> myConversionStrategy = strategy); - radioBut.setBorder(JBUI.Borders.emptyLeft(20)); - butGr.add(radioBut); - panel.add(radioBut); - } - - JPanel annotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl( - myIgnoredAnnotations, JavaBundle.message("class.can.be.record.suppress.conversion.if.annotated"), true); - panel.addGrowing(annotationsPanel); - - return panel; + public @NotNull OptPane getOptionsPane() { + return pane( + checkbox("suggestAccessorsRenaming", JavaBundle.message("class.can.be.record.suggest.renaming.accessors")), + dropdown("myConversionStrategy", JavaBundle.message("class.can.be.record.conversion.make.member.more.accessible"), + ConversionStrategy.class, ConversionStrategy::getMessage), + stringList("myIgnoredAnnotations", JavaBundle.message("class.can.be.record.suppress.conversion.if.annotated")) + .description(HtmlChunk.raw(JavaCompilerBundle.message("class.can.be.record.suppress.conversion.if.annotated.description")))); } private static class ClassCanBeRecordVisitor extends BaseInspectionVisitor {