mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] IDEA-365031 Propose on info level convert to record for classes without getters
GitOrigin-RevId: 77f56876a99f3e924bf39232f9cf5a32fb174211
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a77f2ccd60
commit
d3e75c5951
+8
-3
@@ -3,6 +3,7 @@ package com.intellij.codeInspection.classCanBeRecord;
|
||||
|
||||
import com.intellij.codeInspection.AddToInspectionOptionListFix;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.classCanBeRecord.ConvertToRecordFix.RecordCandidate;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.codeInspection.util.InspectionMessage;
|
||||
@@ -116,11 +117,15 @@ public final class ClassCanBeRecordInspection extends BaseInspection {
|
||||
if (classIdentifier == null) return;
|
||||
RecordCandidate recordCandidate = ConvertToRecordFix.getClassDefinition(aClass, mySuggestAccessorsRenaming, myIgnoredAnnotations);
|
||||
if (recordCandidate == null) return;
|
||||
if (myConversionStrategy == ConversionStrategy.DO_NOT_SUGGEST ||
|
||||
if (myConversionStrategy == ConversionStrategy.DO_NOT_SUGGEST ||
|
||||
myConversionStrategy == ConversionStrategy.SHOW_AFFECTED_MEMBERS && !isOnTheFly()) {
|
||||
if (!ConvertToRecordProcessor.findConflicts(recordCandidate).isEmpty()) return;
|
||||
if (!ConvertToRecordProcessor.findConflicts(recordCandidate).isEmpty()){
|
||||
registerError(classIdentifier, ProblemHighlightType.INFORMATION, isOnTheFly(), aClass);
|
||||
}
|
||||
}
|
||||
else {
|
||||
registerError(classIdentifier, isOnTheFly(), aClass);
|
||||
}
|
||||
registerError(classIdentifier, isOnTheFly(), aClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Convert to record class" "true"
|
||||
|
||||
package my.annotation2;
|
||||
|
||||
|
||||
record A(java.util.Date date) {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Convert to record class" "true"
|
||||
|
||||
package my.annotation2;
|
||||
|
||||
|
||||
class A<caret>{
|
||||
private final java.util.Date date;
|
||||
|
||||
A(java.util.Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// "Convert to record class" "INFORMATION"
|
||||
record R(int first) {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Convert to record class" "INFORMATION"
|
||||
record R(int first) {
|
||||
}
|
||||
|
||||
class AA{
|
||||
public static void main(String[] args) {
|
||||
R r = new R(1);
|
||||
System.out.println(r.first());
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// "Convert to record class" "INFORMATION"
|
||||
public record R(int first) {
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Convert to record class" "false"
|
||||
// "Convert to record class" "INFORMATION"
|
||||
class <caret>R {
|
||||
final int first;
|
||||
|
||||
|
||||
+8
-1
@@ -1,8 +1,15 @@
|
||||
// "Convert to record class" "false"
|
||||
// "Convert to record class" "INFORMATION"
|
||||
class <caret>R {
|
||||
final int first;
|
||||
|
||||
private R(int first) {
|
||||
this.first = first;
|
||||
}
|
||||
}
|
||||
|
||||
class AA{
|
||||
public static void main(String[] args) {
|
||||
R r = new R(1);
|
||||
System.out.println(r.first);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Convert to record class" "false"
|
||||
// "Convert to record class" "INFORMATION"
|
||||
public class <caret>R {
|
||||
private final int first;
|
||||
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ public class ClassCanBeRecordInspectionWeakenAccessibilityTest extends LightQuic
|
||||
return LightJavaCodeInsightFixtureTestCase.JAVA_LATEST;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/inspection/classCanBeRecord/weakenAccessibility";
|
||||
|
||||
Reference in New Issue
Block a user