mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[^romka] IDEA-68894 Usages in switch case don't count for unused definition inspection(cherry picked from commit 884425d)
This commit is contained in:
+5
@@ -586,6 +586,11 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitCaseSection(GrCaseSection caseSection) {
|
||||
GrExpression value = caseSection.getCaseLabel().getValue();
|
||||
if (value != null) {
|
||||
value.accept(this);
|
||||
}
|
||||
|
||||
for (GrStatement statement : caseSection.getStatements()) {
|
||||
statement.accept(this);
|
||||
}
|
||||
|
||||
@@ -187,6 +187,7 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testUnusedVariable() throws Exception { doTest(new UnusedDefInspection()); }
|
||||
public void testDefinitionUsedInClosure() throws Exception { doTest(new UnusedDefInspection()); }
|
||||
public void testDefinitionUsedInClosure2() throws Exception { doTest(new UnusedDefInspection()); }
|
||||
public void testDefinitionUsedInSwitchCase() throws Exception { doTest(new UnusedDefInspection()); }
|
||||
public void testDuplicateInnerClass() throws Throwable{doTest();}
|
||||
|
||||
public void testThisInStaticContext() throws Throwable {doTest();}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
def m = [a: 1, b: 2]
|
||||
def <warning descr="Assignment is not used">m1</warning> = [a: 1, b: 2]
|
||||
def val = 'a'
|
||||
|
||||
switch (val) {
|
||||
case m: "key in map"; break
|
||||
// equivalent to case { val in m }: ...
|
||||
default: "not in map"
|
||||
}
|
||||
Reference in New Issue
Block a user