mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
[java-inspections] IDEA-360429 Support guards in switch UAST
GitOrigin-RevId: 6679acb5d8380073f75ef7be8a8261c59e6b392b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6b1374f4e3
commit
cccb22d78e
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Main.java</file>
|
||||
<line>3</line>
|
||||
<offset>6</offset>
|
||||
<length>4</length>
|
||||
<highlighted_element>Test</highlighted_element>
|
||||
<description>Class is not instantiated.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.io.Serializable;
|
||||
|
||||
class Test {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private <T extends Serializable> Object toConflictDetail(String controlClass, T conflict) {
|
||||
return switch (conflict) {
|
||||
case String ruleConflict when hasSameControlClass(controlClass, ruleConflict) -> conflict;
|
||||
case Number nestingConflict when hasSameControlClass(controlClass, nestingConflict) -> null;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean hasSameControlClass(String controlClass, Object ruleConflict) {
|
||||
return controlClass.equals(ruleConflict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user