diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyVariableCanBeFinalTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyVariableCanBeFinalTest.java
index cbfa18ae37a9..8d7a14149376 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyVariableCanBeFinalTest.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyVariableCanBeFinalTest.java
@@ -1,241 +1,240 @@
-// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
-package org.jetbrains.plugins.groovy.lang.highlighting
+// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
+package org.jetbrains.plugins.groovy.lang.highlighting;
-import com.intellij.codeInspection.InspectionProfileEntry
-import org.jetbrains.plugins.groovy.codeInspection.dataflow.GroovyVariableCanBeFinalInspection
-
-class GroovyVariableCanBeFinalTest extends GrHighlightingTestBase {
+import com.intellij.codeInspection.InspectionProfileEntry;
+import org.jetbrains.plugins.groovy.codeInspection.dataflow.GroovyVariableCanBeFinalInspection;
+public class GroovyVariableCanBeFinalTest extends GrHighlightingTestBase {
@Override
- InspectionProfileEntry[] getCustomInspections() {
- return [new GroovyVariableCanBeFinalInspection()]
+ public InspectionProfileEntry[] getCustomInspections() {
+ return new InspectionProfileEntry[]{new GroovyVariableCanBeFinalInspection()};
}
- void testSimpleLocalVariable() {
- doTestHighlighting('''
-def simpleLocalVariableTest() {
- def a = 1
- final def b = a
- println b
-}
-''')
+ public void testSimpleLocalVariable() {
+ doTestHighlighting("""
+ def simpleLocalVariableTest() {
+ def a = 1
+ final def b = a
+ println b
+ }
+ """);
}
- void testClosureParam() {
- doTestHighlighting('''
-def closureParamTest() {
- { a -> print a }
-}
-''')
+ public void testClosureParam() {
+ doTestHighlighting("""
+ def closureParamTest() {
+ { a -> print a }
+ }
+ """);
}
- void testClosureOuterScope() {
- doTestHighlighting('''
-def closureOuterScopeTest() {
- def outer = 1
- def outer2 = 2
- final def outer3 = 3
- return { final aa ->
- outer2 = 2
- print aa
- aa + outer2 + outer + outer3
- }
-}
+ public void testClosureOuterScope() {
+ doTestHighlighting("""
+ def closureOuterScopeTest() {
+ def outer = 1
+ def outer2 = 2
+ final def outer3 = 3
+ return { final aa ->
+ outer2 = 2
+ print aa
+ aa + outer2 + outer + outer3
+ }
+ }
-''')
+ """);
}
- void testAnonymousClass() {
- doTestHighlighting('''
-Runnable foo() {
- def a = 1
- def b = 2 // more than 1 assignment
- final def c = 3 // already final
- new Runnable() {
- @Override
- void run() {
- b = 3
- print a
- print b
- print c
- }
- }
-}
-''')
+ public void testAnonymousClass() {
+ doTestHighlighting("""
+ Runnable foo() {
+ def a = 1
+ def b = 2 // more than 1 assignment
+ final def c = 3 // already final
+ new Runnable() {
+ @Override
+ void run() {
+ b = 3
+ print a
+ print b
+ print c
+ }
+ }
+ }
+ """);
}
- void testMethodParameter() {
- doTestHighlighting('''
-def methodParameterTest(String s, String ss, final String sss) {
- ss = s
- println ss
- println sss
-}
-''')
+ public void testMethodParameter() {
+ doTestHighlighting("""
+ def methodParameterTest(String s, String ss, final String sss) {
+ ss = s
+ println ss
+ println sss
+ }
+ """);
}
- void testFor() {
- doTestHighlighting('''
-def forTest() {
- for (int i in 1..<10) {
- println i
- }
- for (def a : arr) {
- print a
- }
- for (i = 0; i < 10; i++) {
- println i
- }
- for (final def a : arr) {
- print a
- }
-}
-''')
+ public void testFor() {
+ doTestHighlighting("""
+ def forTest() {
+ for (int i in 1..<10) {
+ println i
+ }
+ for (def a : arr) {
+ print a
+ }
+ for (i = 0; i < 10; i++) {
+ println i
+ }
+ for (final def a : arr) {
+ print a
+ }
+ }
+ """);
}
- void testTernary() {
- doTestHighlighting('''
-def ternaryTest() {
- def ternary = rand() ? rand() : 500
- final f = ternary
- println f
-}
-''')
+ public void testTernary() {
+ doTestHighlighting("""
+ def ternaryTest() {
+ def ternary = rand() ? rand() : 500
+ final f = ternary
+ println f
+ }
+ """);
}
- void testTernaryDeep() {
- doTestHighlighting('''
-def deepTernaryTest() {
- def ternary = rand() ? (rand() ? 100 : 500) : (rand() ? { -> } : 300)
- final f = ternary
- println f
-}
-''')
+ public void testTernaryDeep() {
+ doTestHighlighting("""
+ def deepTernaryTest() {
+ def ternary = rand() ? (rand() ? 100 : 500) : (rand() ? { -> } : 300)
+ final f = ternary
+ println f
+ }
+ """);
}
- void testSwitch() {
- doTestHighlighting('''
-def switchTest() {
- def sw
- switch (rand()) {
- case true:
- sw = 3
- break
- case false:
- sw = "I'm false"
- break
- default:
- throw new RuntimeException()
- }
- println sw
-}
-''')
+ public void testSwitch() {
+ doTestHighlighting("""
+ def switchTest() {
+ def sw
+ switch (rand()) {
+ case true:
+ sw = 3
+ break
+ case false:
+ sw = "I'm false"
+ break
+ default:
+ throw new RuntimeException()
+ }
+ println sw
+ }
+ """);
}
- void testDeepSwitch() {
- doTestHighlighting('''
-def deepSwitchTest() {
- def sw
- switch (rand()) {
- case true:
- sw = 1;
- break
- case false:
- switch (rand()) {
- case true:
- sw = "True";
- break
- case false:
- sw = " False ";
- break
- default:
- throw new RuntimeException()
- }
- break
- default:
- sw = 2;
- break
- }
- println sw
-}
-''')
+ public void testDeepSwitch() {
+ doTestHighlighting("""
+ def deepSwitchTest() {
+ def sw
+ switch (rand()) {
+ case true:
+ sw = 1;
+ break
+ case false:
+ switch (rand()) {
+ case true:
+ sw = "True";
+ break
+ case false:
+ sw = " False ";
+ break
+ default:
+ throw new RuntimeException()
+ }
+ break
+ default:
+ sw = 2;
+ break
+ }
+ println sw
+ }
+ """);
}
- void testIf() {
- doTestHighlighting('''
-def ifTest() {
- def a
- if (rand()) a = 1
- else a = "lol"
- final def b = a //already final
- println b
-}
-''')
+ public void testIf() {
+ doTestHighlighting("""
+ def ifTest() {
+ def a
+ if (rand()) a = 1
+ else a = "lol"
+ final def b = a //already final
+ println b
+ }
+ """);
}
- void testIfTriBranch() {
- doTestHighlighting('''
-def triBranchIfTest() {
- def a
- if (rand()) {
- a = 1
- } else if (rand()) {
- a = "lol"
- } else {
- a = "non-lol"
- }
- def b = a
- println b
-}
-''')
+ public void testIfTriBranch() {
+ doTestHighlighting("""
+ def triBranchIfTest() {
+ def a
+ if (rand()) {
+ a = 1
+ } else if (rand()) {
+ a = "lol"
+ } else {
+ a = "non-lol"
+ }
+ def b = a
+ println b
+ }
+ """);
}
- void testIfDeep() {
- doTestHighlighting('''
-def deepIfTest() {
- def a
- if (rand()) {
- if (rand()) {
- a = 1
- } else {
- a = "lol"
- }
- } else {
- if (rand()) {
- a = "2"
- } else {
- a = "za"
- }
- }
- final def b = a // already final
- println b
-}
-''')
+ public void testIfDeep() {
+ doTestHighlighting("""
+ def deepIfTest() {
+ def a
+ if (rand()) {
+ if (rand()) {
+ a = 1
+ } else {
+ a = "lol"
+ }
+ } else {
+ if (rand()) {
+ a = "2"
+ } else {
+ a = "za"
+ }
+ }
+ final def b = a // already final
+ println b
+ }
+ """);
}
- void testSameVariableName() {
- doTestHighlighting('''
- def testSameVariableName() {
- if (rand()) {
- def a = 5
- print a
- }
- if (rand()) {
- def a = 6
- print a
- }
-}
-''')
+ public void testSameVariableName() {
+ doTestHighlighting("""
+ def testSameVariableName() {
+ if (rand()) {
+ def a = 5
+ print a
+ }
+ if (rand()) {
+ def a = 6
+ print a
+ }
+ }
+ """);
}
- void testSeveralAssignments() {
- doTestHighlighting('''
-def testSeveralAssignments() {
- def a = 1
- a = 2
- a = b
- print a
-}
-''')
+ public void testSeveralAssignments() {
+ doTestHighlighting("""
+ def testSeveralAssignments() {
+ def a = 1
+ a = 2
+ a = b
+ print a
+ }
+ """);
}
}