mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-26 20:50:54 +07:00
IDEA-323910 Implement parser for "JEP 443: Unnamed Patterns and Variables (Preview)" IDEA-323960 Support error highlighting for unnamed variables (JEP 443) GitOrigin-RevId: 1b9ee424063dfd4d32c2215fc8b0a9838dbdcd95
35 lines
1.0 KiB
Java
35 lines
1.0 KiB
Java
import java.util.function.*;
|
|
|
|
public class UnnamedVariables {
|
|
void testParameter(int <error descr="Variable '_' is already defined in the scope">_</error>, String <error descr="Variable '_' is already defined in the scope">_</error>) {
|
|
System.out.println(_);
|
|
}
|
|
|
|
void testOneParam(String _) {
|
|
System.out.println(_);
|
|
}
|
|
|
|
int _ = 123;
|
|
<error descr="Incompatible types. Found: 'int', required: 'java.lang.String'">String s = _;</error>
|
|
|
|
void testLocal() {
|
|
int _ = 10;
|
|
int <error descr="Variable '_' is already defined in the scope">_</error> = 20;
|
|
for (int <error descr="Variable '_' is already defined in the scope">_</error> = 1;;) {}
|
|
}
|
|
|
|
void testCatch() {
|
|
try {
|
|
System.out.println();
|
|
}
|
|
catch (Exception _) {
|
|
System.out.println("ignore");
|
|
}
|
|
catch (Error _) {
|
|
int <error descr="Variable '_' is already defined in the scope">_</error> = 1;
|
|
for(int <error descr="Variable '_' is already defined in the scope">_</error>:new int[10]) {
|
|
System.out.println("oops");
|
|
}
|
|
}
|
|
}
|
|
} |